From a416a5b58c7733f52d4ea1a6c7e58df507dfe9d0 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen <richard.gustavsen@nokia.com> Date: Mon, 23 May 2011 10:14:55 +0200 Subject: [PATCH] Splitter: reduce var assignments --- components/custom/SplitterRow.qml | 19 ++++++++++--------- examples/SplitterGallery.qml | 4 ++-- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/components/custom/SplitterRow.qml b/components/custom/SplitterRow.qml index 0f6379572..34cc187ce 100644 --- a/components/custom/SplitterRow.qml +++ b/components/custom/SplitterRow.qml @@ -32,19 +32,16 @@ Item { // 'updateLayout' will override in case new width violates max/min. // And 'updateLayout will be triggered when an item changes width. - // [leftHandle - leftItem - handle - rightItem - rightHandle] - var leftHandle = handles[handleIndex-1] - var leftItem = items[handleIndex] - var handle = handles[handleIndex] - var rightItem = items[handleIndex+1] - var rightHandle = handles[handleIndex+1] - var leftEdge = leftHandle ? (leftHandle.x + leftHandle.width) : 0 - var rightEdge = (rightHandle ? rightHandle.x : root.width) - var expandingItem = items[d.expandingIndex] + var leftHandle, leftItem, handle, rightItem, rightHandle + var leftEdge, rightEdge if (d.expandingIndex > handleIndex) { // Resize item to the left. // Ensure that the handle is not crossing other handles: + leftHandle = handles[handleIndex-1] + leftItem = items[handleIndex] + handle = handles[handleIndex] + leftEdge = leftHandle ? (leftHandle.x + leftHandle.width) : 0 handle.x = Math.max(leftEdge, handle.x) leftItem.width = handle.x - leftEdge if (root.width != 0 && leftItem.percentageWidth != undefined && leftItem.percentageWidth !== -1) @@ -56,6 +53,10 @@ Item { // we got space for: var min = accumulatedWidth(0, handleIndex+1, true) // Ensure that the handle is not crossing other handles: + handle = handles[handleIndex] + rightItem = items[handleIndex+1] + rightHandle = handles[handleIndex+1] + rightEdge = (rightHandle ? rightHandle.x : root.width) handle.x = Math.max(min, Math.max(Math.min((rightEdge - handle.width), handle.x))) rightItem.width = rightEdge - (handle.x + handle.width) if (root.width != 0 && rightItem.percentageWidth != undefined && rightItem.percentageWidth !== -1) diff --git a/examples/SplitterGallery.qml b/examples/SplitterGallery.qml index 4521e36af..13f01a2be 100644 --- a/examples/SplitterGallery.qml +++ b/examples/SplitterGallery.qml @@ -14,7 +14,7 @@ Rectangle { id: r1 // property bool expanding: true // property int maximumWidth: 100 -// property real percentageWidth: 50 + property real percentageWidth: 50 color: "gray" width: slider.value // Behavior on width { PropertyAnimation{} } @@ -23,7 +23,7 @@ Rectangle { id: r2 property int minimumWidth: 50 color: "darkGray" -// property bool expanding: true + property bool expanding: true width: 50 } Slider { -- GitLab