Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve the height of plugins in the right split #194

Merged
merged 3 commits into from
Mar 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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