From 3794b8a7e320a09102ef521d82b58dd4d1755e5b Mon Sep 17 00:00:00 2001 From: Louise Poubel Date: Wed, 17 Mar 2021 23:15:35 -0700 Subject: [PATCH] Improve the height of plugins in the right split (#194) Signed-off-by: Louise Poubel --- include/ignition/gui/qml/IgnCard.qml | 43 +++++++++++++++++---------- include/ignition/gui/qml/IgnSplit.qml | 42 ++++++++++++++++++++++---- src/plugins/publisher/Publisher.qml | 1 + 3 files changed, 65 insertions(+), 21 deletions(-) diff --git a/include/ignition/gui/qml/IgnCard.qml b/include/ignition/gui/qml/IgnCard.qml index e83bae6ae..c9b5031fa 100644 --- a/include/ignition/gui/qml/IgnCard.qml +++ b/include/ignition/gui/qml/IgnCard.qml @@ -175,7 +175,6 @@ Pane { // Bind anchors anchors.fill = Qt.binding(function() {return parent}) - anchors.fill = Qt.binding(function() {return parent}) parent.height = Qt.binding(function() {return height}) parent.width = Qt.binding(function() {return width}) @@ -323,25 +322,31 @@ Pane { Transition { from: "docked" to: "docked_collapsed" - NumberAnimation { - target: cardPane - property: "parent.Layout.minimumHeight" - duration: 200 - easing.type: Easing.OutCubic - from: cardPane.height - to: 50 + SequentialAnimation { + NumberAnimation { + target: cardPane + property: "parent.Layout.maximumHeight" + duration: 200 + easing.type: Easing.OutCubic + from: cardPane.height + to: 50 + } + ScriptAction {script: recalculateSplitSizes()} } }, Transition { from: "docked_collapsed" to: "docked" - NumberAnimation { - target: cardPane - property: "parent.Layout.minimumHeight" - duration: 200 - easing.type: Easing.InCubic - from: 50 - to: content.children[0] === undefined ? 50 : content.children[0].Layout.minimumHeight + SequentialAnimation { + NumberAnimation { + target: cardPane + property: "parent.Layout.maximumHeight" + duration: 200 + easing.type: Easing.InCubic + from: 50 + to: backgroundItem.height + } + ScriptAction {script: recalculateSplitSizes()} } }, Transition { @@ -440,6 +445,14 @@ Pane { // Do nothing } + /** + * Recalculate split sizes + */ + function recalculateSplitSizes() + { + backgroundItem.recalculateMinimumSizes(); + } + // TODO(louise): re-enable window state support // /** // * Window for undocking diff --git a/include/ignition/gui/qml/IgnSplit.qml b/include/ignition/gui/qml/IgnSplit.qml index 529fa5df6..baa41e33e 100644 --- a/include/ignition/gui/qml/IgnSplit.qml +++ b/include/ignition/gui/qml/IgnSplit.qml @@ -43,6 +43,14 @@ SplitView { */ property variant childSplits: new Object() + /** + * Callback when the height changed. + */ + onHeightChanged: + { + background.recalculateMinimumSizes(); + } + Rectangle { id: startLabel; visible: MainWindow.pluginCount === 0 @@ -58,6 +66,17 @@ SplitView { } } + /** + * Recalculate minimum size for all splits + */ + function recalculateMinimumSizes() + { + for (var name in childSplits) + { + childSplits[name].split.recalculateMinimumSize() + } + } + /** * This function will appropriately create new items and splits according to * the current main window state. @@ -327,6 +346,7 @@ SplitView { // Sync minimum sizes var heightSum = 0; + var minHeightSum = 0; for (var i = 0; i < __items.length; i++) { var child = __items[i]; @@ -336,14 +356,24 @@ SplitView { { Layout.minimumWidth = child.Layout.minimumWidth; } - // Set child height to minimum height - child.height = child.Layout.minimumHeight; + heightSum += child.height; + minHeightSum += child.height < child.Layout.minimumHeight ? + child.height : child.Layout.minimumHeight; + } - // Minimum height is the sum of all children's minimum heights - heightSum += child.Layout.minimumHeight; + // Minimum height to show all children + Layout.minimumHeight = minHeightSum; + split.height = Math.max(minHeightSum, background.height); + + // Squish all children if there's no slack + if (heightSum > background.height) + { + for (var i = 0; i < __items.length; i++) + { + var child = __items[i]; + child.height = child.Layout.minimumHeight; + } } - Layout.minimumHeight = heightSum; - split.height = heightSum; } } } diff --git a/src/plugins/publisher/Publisher.qml b/src/plugins/publisher/Publisher.qml index 1b218e56c..c31149e1a 100644 --- a/src/plugins/publisher/Publisher.qml +++ b/src/plugins/publisher/Publisher.qml @@ -23,6 +23,7 @@ Rectangle { color: "transparent" Layout.minimumWidth: 250 Layout.minimumHeight: 375 + anchors.fill: parent property int tooltipDelay: 500 property int tooltipTimeout: 1000