diff options
author | Richard Moe Gustavsen <richard.gustavsen@digia.com> | 2013-07-10 15:08:12 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-07-11 18:26:29 +0200 |
commit | 2c22f6445f69d12afac01e3fd74d21decc14d4b3 (patch) | |
tree | 5b576f868653e598bb7b1fa347c477f8e5c65f95 /src | |
parent | a741101c3cc4d8e5ceb36a299914c2e92d78e505 (diff) | |
download | qtquickcontrols-2c22f6445f69d12afac01e3fd74d21decc14d4b3.tar.gz |
SplitView: Always layout as if fillWidthItem is visible
Hiding the fillWidth item in the splitter is allowed, but
causes strange drawing/layout artifacts that can be
difficult to understand since the layout engine would ignore
all hidden items. This patch changes the implementation
by adding an exception to the rule. The layout engine
now treats the fillWidth item as if it is always visible.
Then, hiding it would just reveal a white field where the
fillItem would otherwise be, but the layout would otherwise
look correct.
Change-Id: I95ec51b595109e8f1efdc231c9a6697ee60aa483
Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/controls/SplitView.qml | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/controls/SplitView.qml b/src/controls/SplitView.qml index 29d812a4..439d9053 100644 --- a/src/controls/SplitView.qml +++ b/src/controls/SplitView.qml @@ -213,7 +213,7 @@ Item { function updateFillIndex() { - if (!lastItem.visible) + if (lastItem.visible !== root.visible) return var policy = (root.orientation === Qt.Horizontal) ? "fillWidth" : "fillHeight" for (var i=0; i<__items.length-1; ++i) { @@ -294,7 +294,7 @@ Item { var w = 0 for (var i=firstIndex; i<lastIndex; ++i) { var item = __items[i] - if (item.visible) { + if (item.visible || i == d.fillIndex) { if (i !== d.fillIndex) w += item[d.size]; else if (includeFillItemMinimum && item.Layout[minimum] !== undefined) @@ -344,7 +344,7 @@ Item { for (i=0; i<__items.length; ++i) { // Position item to the right of the previous visible handle: item = __items[i]; - if (item.visible) { + if (item.visible || i == d.fillIndex) { item[d.offset] = lastVisibleHandle ? lastVisibleHandle[d.offset] + lastVisibleHandle[d.size] : 0 item[d.otherOffset] = 0 item[d.otherSize] = clampedMinMax(root[otherSize], item.Layout[otherMinimum], item.Layout[otherMaximum]) @@ -377,7 +377,8 @@ Item { readonly property bool resizing: mouseArea.drag.active onResizingChanged: root.resizing = resizing } - visible: __items[__handleIndex + ((d.fillIndex > __handleIndex) ? 0 : 1)].visible + property bool resizeLeftItem: (d.fillIndex > __handleIndex) + visible: __items[__handleIndex + (resizeLeftItem ? 0 : 1)].visible sourceComponent: handleDelegate onWidthChanged: d.updateLayout() onHeightChanged: d.updateLayout() @@ -409,8 +410,7 @@ Item { var leftEdge, rightEdge, newWidth, leftStopX, rightStopX var i - if (d.fillIndex > __handleIndex) { - // Resize item to the left. + if (resizeLeftItem) { // Ensure that the handle is not crossing other handles. So // find the first visible handle to the left to determine the left edge: leftEdge = 0 |