From 4a5b176b5bd302903a7baf1517e7cb9dced70d3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Wed, 22 Jul 2009 10:37:13 +0200 Subject: Anchors to center edges should also have a default spacing of 0. Since the spacing will be 0 in most cases, we therefore "invert" the if (..) to only check for the cases where the spacing will *not* be zero. --- src/gui/graphicsview/qgraphicsanchorlayout_p.cpp | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp index 9023344..e969e40 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp @@ -603,12 +603,22 @@ void QGraphicsAnchorLayoutPrivate::anchor(QGraphicsLayoutItem *firstItem, AnchorData *data; if (!spacing) { - // If we anchor to the layout edges or if we anchor - // Right->Right or Left->Left, our default spacing will be 0 - if (firstItem == q || secondItem == q || firstEdge == secondEdge) - data = new AnchorData(0); - else - data = new AnchorData; // otherwise, ask the style later + // If firstItem or secondItem is the layout itself, the spacing will default to 0. + // Otherwise, the following matrix is used (questionmark means that the spacing + // is queried from the style): + // from + // to Left HCenter Right + // Left 0 0 ? + // HCenter 0 0 0 + // Right ? 0 0 + if (firstItem != q + && secondItem != q + && pickEdge(firstEdge, Horizontal) != QGraphicsAnchorLayout::HCenter + && oppositeEdge(firstEdge) == secondEdge) { + data = new AnchorData; // ask the style later + } else { + data = new AnchorData(0); // spacing should be 0 + } addAnchor(firstItem, firstEdge, secondItem, secondEdge, data); } else if (*spacing >= 0) { data = new AnchorData(*spacing); -- cgit v0.12