From a2bec5164f81f83a291480197f5f0a92b07ca7fa Mon Sep 17 00:00:00 2001
From: Richard Moe Gustavsen <richard.gustavsen@digia.com>
Date: Fri, 3 May 2013 19:58:46 +0200
Subject: [PATCH] SplitView: always respect min/max
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

If the user sets Layout.maximumWidth on the fillWidth item, we now
respect it. This can potentially make the splitview look buggy, since
the fillWidth item might then be restrained from filling out remaining
space. The same with the height of each item; you can now control the
maximum height. This means that each item can end up with a different
height. The upshot is that if you add items to a splitview that
cannot grow, splitview will not try to resize it.

Change-Id: If1cc82aefa939898a3b159da6b006f95af42599f
Reviewed-by: Jan Arve Sæther <jan-arve.saether@digia.com>
---
 src/controls/SplitView.qml | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/controls/SplitView.qml b/src/controls/SplitView.qml
index f12513998..0c50bc3bb 100644
--- a/src/controls/SplitView.qml
+++ b/src/controls/SplitView.qml
@@ -284,8 +284,11 @@ Item {
             // it already got, and assume that SplitView ends up with implicit size as size:
             if (root[d.size] != 0) {
                 var fillItem = __items[fillIndex]
-                var min = fillItem.Layout[minimum] !== undefined ? fillItem.Layout[minimum] : 0
-                fillItem[d.size] = Math.max(min, root[d.size] - d.accumulatedSize(0, __items.length, false))
+                var superfluous = root[d.size] - d.accumulatedSize(0, __items.length, false)
+                var s = Math.max(superfluous, fillItem.Layout[minimum])
+                if (fillItem.Layout[maximum] !== -1)
+                    s = Math.min(s, fillItem.Layout[maximum])
+                fillItem[d.size] = s
             }
 
             // Position items and handles according to their width:
@@ -296,7 +299,7 @@ Item {
                 if (item.visible) {
                     item[d.offset] = lastVisibleHandle ? lastVisibleHandle[d.offset] + lastVisibleHandle[d.size] : 0
                     item[d.otherOffset] = 0
-                    item[d.otherSize] = root[d.otherSize]
+                    item[d.otherSize] = clampedMinMax(root[otherSize], item.Layout[otherMinimum], item.Layout[otherMaximum])
                     lastVisibleItem = item
 
                     handle = __handles[i]
-- 
GitLab