Skip to content

Commit

Permalink
Improve the height of plugins in the right split (#194)
Browse files Browse the repository at this point in the history
Signed-off-by: Louise Poubel <louise@openrobotics.org>
  • Loading branch information
chapulina authored Mar 18, 2021
1 parent 071a8e4 commit 3794b8a
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 21 deletions.
43 changes: 28 additions & 15 deletions include/ignition/gui/qml/IgnCard.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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})

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -440,6 +445,14 @@ Pane {
// Do nothing
}

/**
* Recalculate split sizes
*/
function recalculateSplitSizes()
{
backgroundItem.recalculateMinimumSizes();
}

// TODO(louise): re-enable window state support
// /**
// * Window for undocking
Expand Down
42 changes: 36 additions & 6 deletions include/ignition/gui/qml/IgnSplit.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -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];
Expand All @@ -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;
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/plugins/publisher/Publisher.qml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Rectangle {
color: "transparent"
Layout.minimumWidth: 250
Layout.minimumHeight: 375
anchors.fill: parent

property int tooltipDelay: 500
property int tooltipTimeout: 1000
Expand Down

0 comments on commit 3794b8a

Please sign in to comment.