summaryrefslogtreecommitdiffstats
path: root/tests/auto/qgraphicsanchorlayout
Commit message (Collapse)AuthorAgeFilesLines
* QGAL (Test): Add test to ensure persistency of user-defined spacingEduardo M. Fleury2009-11-121-0/+26
| | | | | | | | | Currently the user-defined spacing is saved inside "AnchorData->prefSize". However this value may be modified if spacing is negative or if the anchor's policy is "QSizePolicy::Ignored". Signed-off-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org> Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org>
* QGAL (Test): redundant anchors shouldn't harm simplificationCaio Marcelo de Oliveira Filho2009-11-061-0/+39
| | | | | | | | | Adds a simple test to check whether redundant anchors avoid simplification to happen. In this case, the use of addCornerAnchors generate redundant anchors. Signed-off-by: Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org> Reviewed-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org>
* QGAL (Test): Add test where center anchor is simplified by parallelEduardo M. Fleury2009-11-061-0/+26
| | | | | | | | | We were not handling the case where a parallel anchor is created to simplify a central anchor. Unfortunately no tests had shown that case yet. Signed-off-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org> Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org>
* QGAL (test): Remove expanding testsEduardo M. Fleury2009-11-041-228/+10
| | | | | | | After the removal of the expanding size hint support. Signed-off-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org> Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org>
* QGAL (Test): Disable simplification test when that is offEduardo M. Fleury2009-11-041-2/+4
| | | | | | | Prevent failures when the test is run with QT_ANCHORLAYOUT_NO_SIMPLIFICATION Signed-off-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org> Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org>
* QGAL: Update infiniteSizes test to avoid simplificationEduardo M. Fleury2009-11-041-0/+3
| | | | | | | | | | The infiniteSizes test is supposed to work w/o simplification, to ensure that I'm adding a central anchor. With this anchor we force the problem to go to the simplex solver and expect it to solve things fine anyway. Signed-off-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org> Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org>
* QGAL: Do not restrict maximum size of layout anchorsEduardo M. Fleury2009-11-041-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* QGAL: add names to the items in some testsCaio Marcelo de Oliveira Filho2009-11-041-4/+4
| | | | | | | Those are useful when dumping the graph in dot format for debugging. Signed-off-by: Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org> Reviewed-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org>
* Merge branch 'fixes' of ↵Jan-Arve Sæther2009-10-281-0/+97
|\ | | | | | | | | | | | | | | git://gitorious.org/~fleury/qt/fleury-openbossa-clone into openbossa-fleury-fixes3 Conflicts: src/gui/graphicsview/qgraphicsanchorlayout_p.cpp src/gui/graphicsview/qgraphicsanchorlayout_p.h
| * QGAL: Add test for David Boddie bugEduardo M. Fleury2009-10-261-0/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current simplification code does not handle sequences with anchors pointed to different directions could not be simplified together into a sequential anchor. A (10 / 20 / 50 ) B (20 / 20 / 20) Ex: o-----------------> <----------------o The reason we don't support it yet is shown in the example above. The resulting anchor would be either: Result_1 (-10 / 0 / 30) o------------------------------------> (or) Result_2 (-30 / 0 / 10) <------------------------------------o But the current implementation assumes no anchors can have negative sizes. Hopefully, the next commits will add support for it and then enable such simplification. :-) Signed-off-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org>
| * QGAL: identify unfeasible setups even when graph is simplifiedCaio Marcelo de Oliveira Filho2009-10-261-0/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The calculate graphs now can return early due to unfeasible anchor setups found out during simplification. This allows finding out problems in parallel anchors, when one anchor has maximum size smaller than the minimum size of the other anchor. The order for simplification and refreshing size hints also has been swaped: - First, refresh size hints for all anchors in the graph. If the graph is simplified, the refreshSizeHints() call will reach the children anchors. - Then, if the simplificated graph is invalid, rebuild it. During this rebuild, refreshSizeHints_helper() will be called for all levels. So in both situations we can identify an unfeasible setup. Note that this test alone is not enough to classify the graph as feasible, depending on the graph, it will still need to go through the Simplex. A test case was added and the function that traverse the graph refreshing now is called refreshAllSizeHints(). The old name was not so clear since the function will not fill only the anchors that have items associated. Last but not least, the lastCalculationUsedSimplex variable is cleared when starting calculateGraphs(), since we now can leave the function earlier, without reaching calculateTrunk(), which is the function that sets it. Signed-off-by: Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org> Reviewed-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org>
* | Respect the per-item layoutSpacing() if the style uses that feature.Jan-Arve Sæther2009-10-271-0/+162
|/ | | | | | | | | | We move the QLayoutStyleInfo class out of the gridlayout engine to a common header file so that anchor layout also can utilize it. Due to that we now can have a per-item spacing we have to change the 'effectiveSpacing' argument of refreshSizeHints to just take a QLayoutStyleInfo pointer that we will later query for the actual spacing used.
* API addition: Make it possible to set the size policy of an anchor.Jan-Arve Sæther2009-10-161-14/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | After this commit, when you modify the spacing of an anchor you are effectively modifying the preferred size of the anchor, since all anchors (except internal ones) have their minimumSizeHint to 0 and maximumSizeHint to QWIDGETSIZE_MAX. I also changed the sizeHintsFromItem to be more generic so that I could use it for anchors. (Thus, it was renamed to "internalSizeHints"). It now only takes care of setting the min/pref/exp/maxSize of AnchorData based on the anchor/item size hint and their size policies. As a consequence of all of this, setFixedSize changed behaviour and became setPreferredSize (since setSpacing is basically setPreferredSize). The implementation of that now only sets the prefSize. The patch also has an unrelated fix for IgnoreFlag, where it will (again) return the minimumSize for sizeHint(Qt::PreferredSize) instead of the maximumSize. This was to be more consistent with qgridlayoutengine.cpp. The docs are not very clear on this behaviour unfortunately. This API change has been discussed. Reviewed-by: alexis
* Merge branch 'fixes' of ↵Jan-Arve Sæther2009-10-161-22/+63
|\ | | | | | | | | | | | | | | | | git://gitorious.org/~fleury/qt/fleury-openbossa-clone into 4.6 Conflicts: src/gui/graphicsview/qgraphicsanchorlayout_p.cpp src/gui/graphicsview/qgraphicsanchorlayout_p.h tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
| * QGraphicsAnchorLayout: Mark expected failures in tests w/o simplificationEduardo M. Fleury2009-10-151-24/+67
| | | | | | | | | | | | | | | | | | | | | | Some tests are expected to fail when run without simplification, ie. by setting the environment var QT_ANCHORLAYOUT_NO_SIMPLIFICATION. This commit adds QEXPECT_FAIL before those tests. In some cases the failures are random therefore we must disable the test instead. Signed-off-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org> Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org>
| * QGAL: add a way to test whether simplex was used in a calculationCaio Marcelo de Oliveira Filho2009-10-151-1/+53
| | | | | | | | | | | | | | | | | | | | This is one good way to track whether simplification is doing all its job or not. However it can only track cases where the graph simplify to only one anchor. For more complex cases the graph dumps are the way to go. Signed-off-by: Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org> Reviewed-by: Artur Duque de Souza <artur.souza@openbossa.org>
| * QGraphicsAnchorLayout: Add test for 'infinite' max size widgetsEduardo M. Fleury2009-10-151-0/+49
| | | | | | | | | | | | | | | | | | | | | | | | With four items anchored side by side, each of them being allowed to grow to QWIDGETSIZE_MAX, we have a situation of fair distribution because the layout itself can grow only to QWIDGETSIZE_MAX (and not four times this amount). This test identified an error on the expanding distribution logic. Signed-off-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org> Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org>
* | QGAL: add a way to test whether simplex was used in a calculationCaio Marcelo de Oliveira Filho2009-10-091-1/+53
| | | | | | | | | | | | | | | | | | | | This is one good way to track whether simplification is doing all its job or not. However it can only track cases where the graph simplify to only one anchor. For more complex cases the graph dumps are the way to go. Signed-off-by: Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org> Reviewed-by: Artur Duque de Souza <artur.souza@openbossa.org>
* | QGraphicsAnchorLayout: Add test for 'infinite' max size widgetsEduardo M. Fleury2009-10-091-0/+49
|/ | | | | | | | | | | | With four items anchored side by side, each of them being allowed to grow to QWIDGETSIZE_MAX, we have a situation of fair distribution because the layout itself can grow only to QWIDGETSIZE_MAX (and not four times this amount). This test identified an error on the expanding distribution logic. Signed-off-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org> Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org>
* Make some lines in the autotest more readable.Jan-Arve Sæther2009-10-071-11/+6
|
* QGraphicsAnchorLayout: Adding a Float Conflict test caseJesus Sanchez-Palencia2009-10-061-0/+69
| | | | | | | | Now we don't support floating items and so we should consider that the layout has a conflict when handling this situation. Signed-off-by: Jesus Sanchez-Palencia <jesus.palencia@openbossa.org> Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org>
* QGraphicsAnchorLayout: Fix creation of internal layout anchorsEduardo M. Fleury2009-10-061-1/+1
| | | | | | | | | | | | Since the AnchorData cleanup commit (c974aca8) all anchor initialization is being done by refreshSizeHints. However that method was not able to properly initialize the internal layout anchors. This commit refactors that method both to add the functionality and improve readability. Signed-off-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org> Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org>
* QGraphicsAnchorLayout Tests: Enable expanding testsEduardo M. Fleury2009-10-061-9/+8
| | | | | | | | Removing QEXPECT_FAIL and making minor corrections on expected values. Signed-off-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org> Reviewed-by: Artur Duque de Souza <artur.souza@openbossa.org>
* QGraphicsAnchorLayout: add autotests for QSizePolicy::ExpandFlagCaio Marcelo de Oliveira Filho2009-10-061-0/+214
| | | | | | | | | Add autotests that use the ExpandFlag via QSizePolicy::Expanding policy. Those tests cover the simple cases and behaviours with sequential and parallel anchor setups. Signed-off-by: Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org> Reviewed-by: Jesus Sanchez-Palencia <jesus.palencia@openbossa.org>
* After some discussion we decided to remove hasConflicts() from the API.Jan-Arve Sæther2009-09-291-33/+19
| | | | | | | | hasConflicts() does only make sense for a tool/editor of the layout, and how this function would help the tool is only guesswork at the moment. We keep the private API though, in order to let the autotests we inherited from Orbit pass.
* QGraphicsAnchorLayout: Enable boundary feasibility testEduardo M. Fleury2009-09-251-4/+2
| | | | | | | | This test would trigger random Q_ASSERT failures but should work fine after the previous commit. Signed-off-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org> Reviewed-by: Jesus Sanchez-Palencia <jesus.palencia@openbossa.org>
* QGraphicsAnchorLayout: Adding hasConflicts() verifications on anchor testsJesus Sanchez-Palencia2009-09-251-0/+29
| | | | | Signed-off-by: Jesus Sanchez-Palencia <jesus.palencia@openbossa.org> Reviewed-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org>
* QGraphicsAnchorLayout: Removing memory leaks on anchor testsJesus Sanchez-Palencia2009-09-251-0/+12
| | | | | Signed-off-by: Jesus Sanchez-Palencia <jesus.palencia@openbossa.org> Reviewed-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org>
* Add test for to see if the layout is stable if it has several solutions.Jan-Arve Sæther2009-09-231-6/+59
| | | | Currently this fails, so we have to use QEXPECT_FAIL.
* QGraphicsAnchorLayout: Added an auto test for size policyAnselmo Lacerda S. de Melo2009-09-181-0/+86
| | | | | | | | | | Added an auto test for the currently supported size policies set. This is a simple test containing a single item anchored to the layout vertical and horizontally. The size policies are set, then the item's minimum, preferred and maximum sizes are compared to the expected ones, according to each policy. Signed-off-by: Anselmo Lacerda S. de Melo <anselmo.melo@openbossa.org>
* Implement hasConflicts().Jan-Arve Sæther2009-09-171-1/+43
|
* Test if the direction influences the returned graphics anchor object.Jan-Arve Sæther2009-09-151-1/+7
| | | | Pointed out by Caio.
* API change. This will get rid of the ugly setAnchorSpacing() method.Jan-Arve Sæther2009-09-141-118/+68
| | | | | | | | | | | | | | | | | | | | Say hello to QGraphicsAnchor, move the spacing (and removeAnchor) functionality over to that class. This also opens up for a cleaner API when we add support for size policies or min/pref/max sizes for anchors. Also remove - addLeftAndRightAnchors() - addTopAndBottomAnchors() - addAllAnchors() in favor of - addAnchors(itemA, itemB, Qt::Orientations) API change discussed with Caio and Andreas. Reviewed-by: Alexis
* Respect the layoutDirection property of the parent widget.Jan-Arve Sæther2009-09-111-0/+78
| | | | | | | Add a layoutDirection autotest, and sprinkle some of the tests with checkReverseDirection() Reviewed-by: Eduardo M. Fleury
* Update license headers again.Jason McDonald2009-09-091-4/+4
| | | | Reviewed-by: Trust Me
* Add some more tests for anchor layoutJan-Arve Sæther2009-09-021-1/+164
|
* Update tech preview license header for files that are new in 4.6.Jason McDonald2009-08-311-13/+13
| | | | Reviewed-by: Trust Me
* Fix some missing and duplicated license headers.Jason McDonald2009-08-271-0/+41
| | | | Reviewed-by: Trust Me
* update API to what was agreed on the API review meeting yesterday:Jan-Arve Sæther2009-08-191-134/+245
| | | | | | | | | | | | | | | | | | | | | | | | | | | The changes are: * Move enums in QGraphicsAnchorLayout::Edge to Qt::AnchorPoint. Prefix them with Anchor since they are not edges in general. * Rename anchor() to addAnchor() * Rename anchorCorner() -> addCornerAnchors() * Rename anchorWidth() -> addLeftAndRightAnchors() * Rename anchorHeight() -> addTopAndBottomAnchors() * Rename anchorGeometry() -> addAllAnchors() * remove the overloads that take a spacing argument, and add setAnchorSpacing() to accommodate for that. * Added anchorSpacing() (implementation missing) * Added unsetAnchorSpacing(). (implementation missing) * made sizeHint() protected. Updated all examples and autotest to reflect this API change.
* Fix one "failure" on the mac.Jan-Arve Sæther2009-08-191-0/+3
| | | | This failed on Alexis' Mac Mini (Leopard)
* QGraphicsAnchorLayout: fix calculation of sizeAt* values for SequentialCaio Marcelo de Oliveira Filho2009-08-181-4/+2
| | | | | | | | | | | | | | | | | | | | | This commit implements what's described in the previous commit QGraphicsAnchorLayout: fix expected values for parallel test When filling the sizeAt* values (the three points used for interpolation when setting geometry), now sequential anchors distribute the sizes to the children in a fair way, i.e. proportionally in relation to the existing min/pref/max hints. Each value is defined in relation of the pref (either as a shrinkage in pref or a grow in pref). In both cases the shrinking/growing factor is the same for all children. When we implement support for QSizePolicies, this distribution might be changed by setting size policies for a certain item or anchor. This makes two tests work -- so no more expected fail. Also fixed a typo in one test's expected results.
* QGraphicsAnchorLayout: add names to items in examplesCaio Marcelo de Oliveira Filho2009-08-171-33/+33
| | | | | Having the items named helps when using debugging functions to identify the anchors. Cause no harm to add them to the tests.
* QGraphicsAnchorLayout: calculate vertex positions with simplified graphCaio Marcelo de Oliveira Filho2009-08-171-1/+0
| | | | | | | | | | | | | | | | When traversing the graph looking for calculating the distances, also enter inside the complex edges to find (and calculate) the distances for the vertices that were simplified. This require a little tweak in the traversal, now we can't always skip an edge when both vertices are already visited, because complex anchors can hide vertices inside (a sequential anchor in practice remove vertices from the full graph). As a bonus we now pass on the 'example' test (as expected) and the example now works fine. Signed-off-by: Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org>
* More tests for setSpacingJan-Arve Sæther2009-08-171-0/+15
|
* Add autotest for setSpacing()Jan-Arve Sæther2009-08-171-0/+42
|
* Added QEXPECT_FAIL, for tests that we must fix, but we know they fail.Jan-Arve Sæther2009-08-141-0/+3
|
* QGraphicsAnchorLayout: fix expected values for parallel testCaio Marcelo de Oliveira Filho2009-08-131-40/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We changed the parallel example because the expected values for preferred size are wrong. Before we had a parallel anchor ("d|e") that should have the maximum preferred of the both children, so this end up being 170. This parallel is in a sequence with another item ("b") with a preferred of 150 ending up with 320. This group is in parallel with "c" that has a maximum of 300. So in the preferred size of the layout, the group was constraint to 300, which would be proportionally distributed between "b" and "d|e", and 50%/50% as the test expected. The proportional distribution is a feature and we changed the test to illustrate that more. We gave a bump in "c" maximum to 350 and "b" maximum to 300, so the preferred is 100% for both "b" and "d|e", and the proportional feature shows up in the maximum allocation, which is not 100% for the group (b and d|e). In the group, the maximum possible is 500 but the layout only allows 350, so the sizes need to be proportionally, but in relation not to zero, but to the preferred which is 320 (this is the same logic used for setGeometry()). So the growth is 30 / (500 - 320) = 30 / 180 = 1/6. This 1/6 should be the factor given to the children (b and d|e), taking their preferred sizes as starting points. Note that the test still fails, but serve as a milestone to see when the feature is correct implemented. Signed-off-by: Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org> Reviewed-by: Artur Duque de Souza <artur.souza@openbossa.org>
* QGraphicsAnchorLayout: test for proportional distributionCaio Marcelo de Oliveira Filho2009-08-131-0/+62
| | | | | | | | | | This test (which fails right now) check whether a sequential anchor is distributing proportionally the size between its parts. This should pass when we make calculateVertexPositions() work together with the simplified graph. Signed-off-by: Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org> Reviewed-by: Artur Duque de Souza <artur.souza@openbossa.org>
* QGraphicsAnchorLayout: add a few more testsCaio Marcelo de Oliveira Filho2009-08-131-0/+266
| | | | | | | | | | | | | | | | | | | | | | Adding tests that were helpful during debugging simplification - example: a replica of the anchorlayout example, which has a few interesting cases. - parallel2: a small pararell test case, subset of example. - snakeOppositeDirections: snake but with connections in the opposite directions (this will end up with anchors with opposite directions). - fairDistributionOppositeDirections: same as before, but in the end, this should be taken care by our API which makes internally the same as fairDistribution. Some work on adding QCOMPARE() statements may still be needed for this examples. Note that is interesting to notice (maybe we can make this available for the test checking automatically) whether the simplex is being used or not when simplification is active. Signed-off-by: Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org>
* Add QGraphicsLayout::anchor() overloads and query the default spacing.Jan-Arve Sæther2009-07-221-54/+70
| | | | | | | | | | | | | | | | | | | | | | | | | | This commit fixes several related issues: 1. QGAL::anchor() had a spacing argument that defaulted to 0. That made it impossible to know if the user meant that the spacing should be 0 or if the spacing should be picked from the style. Instead we have to overload anchor, so now we have one function that does not take spacing as an argument. That one will create an anchor where the spacing is queried from the style. The other overload allows the user to explicitly set the spacing, thus the default spacing is ignored. 2. Make sure we pick up the spacing correctly from the style if needed. setAnchorSizeHintsFromDefaults() will set the correct spacing on anchors that was created without specifying a spacing value. 3. Add QGAL::anchor(Qt::Corner, ...) convenience function with an overload (for the same reason as explained in 1.) 4. Added QGraphicsAnchorLayoutPrivate::anchor() as a helper function that is called from all the 4 public API anchor() functions so that we don't need to have duplicate code for argument checking etc. 5. Fix autotests. They assumed that anchor() without a spacing argument created a spacing of 0.