diff options
author | Eduardo M. Fleury <eduardo.fleury@openbossa.org> | 2009-10-19 19:36:53 (GMT) |
---|---|---|
committer | Eduardo M. Fleury <eduardo.fleury@openbossa.org> | 2009-11-04 23:27:40 (GMT) |
commit | 33faaf6fa1775dc74bb61acde8a48eae2b9f2635 (patch) | |
tree | 469a2069c17b98a016493121de8cd6e43042c17e /tests/auto/qgraphicsanchorlayout | |
parent | 41369cd2946956b9a455e4f2014dcc38ffcbad52 (diff) | |
download | Qt-33faaf6fa1775dc74bb61acde8a48eae2b9f2635.zip Qt-33faaf6fa1775dc74bb61acde8a48eae2b9f2635.tar.gz Qt-33faaf6fa1775dc74bb61acde8a48eae2b9f2635.tar.bz2 |
QGAL: Do not restrict maximum size of layout anchors
This commit improves the way QGAL handles setups where most anchors
or items do not have explicit maximum sizes.
By default the internal layout anchors and others, have maximum size
of QWIDGETSIZE_MAX. It happens though that this value is rather arbitrary
but yet, can restrict the size of other paths in the layout.
For instance, in the setup below, where the maximum sizes of A and B is
not set:
________ ________
| | item A | | item B | |
o---o--------o---o--------o---o
| |________| |________| |
| |
| (layout structural anchor) |
o-----------------------------o
| |
the bottom path, of maximum size QWIDGETSIZE_MAX, restricts the lenght
of the path at the top, of maximum size of 2 x QWIDGETSIZE_MAX.
This introduces the need of fair distribution in the path A-B. While
that's not an issue when the path is simplified to a single anchor,
it may lead to unbalanced distributions if such simplification is
not possible. As this case may arise when we have center anchors
in the top path, it may appear in real-world cases.
To work around that, we do not limit the maximum width of the layout
anchor or parallel anchors that may have taken its place. The practical
result in the example above is that the sizeAtMaximum will be set at
2 x QWIDGETSIZE_MAX, with a good distribution of A and B.
On the other hand, this oversized layout is not a problem because the
effectiveSizeHint code enforces the respect of QWIDGETSIZE_MAX. That
means the layout will interpolate only between zero and QWIDGETSIZE_MAX
even though its internal maximum size is twice that value.
Signed-off-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org>
Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org>
Diffstat (limited to 'tests/auto/qgraphicsanchorlayout')
-rw-r--r-- | tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp index 09e2ee2..ce1ffad 100644 --- a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp +++ b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp @@ -1896,15 +1896,15 @@ void tst_QGraphicsAnchorLayout::infiniteMaxSizes() QGraphicsWidget p; p.setLayout(l); + QCOMPARE(int(p.effectiveSizeHint(Qt::MaximumSize).width()), + QWIDGETSIZE_MAX); + p.resize(200, 10); QCOMPARE(a->geometry(), QRectF(0, 0, 50, 10)); QCOMPARE(b->geometry(), QRectF(50, 0, 50, 10)); QCOMPARE(c->geometry(), QRectF(100, 0, 50, 10)); QCOMPARE(d->geometry(), QRectF(150, 0, 50, 10)); - if (!hasSimplification) - QEXPECT_FAIL("", "Without simplification there is no fair distribution.", Abort); - p.resize(1000, 10); QCOMPARE(a->geometry(), QRectF(0, 0, 450, 10)); QCOMPARE(b->geometry(), QRectF(450, 0, 50, 10)); |