From 700533b4aa60105dde4a029c1a2f151b33b6313d Mon Sep 17 00:00:00 2001 From: Mark Burton Date: Wed, 3 Jun 2020 08:13:28 +0100 Subject: [PATCH 1/3] Change the panelBorder rectangle anchor to the bottom for lower toolbar buttons. This makes the panel grow upwards into clear space rather than downwards which is a problem when the Cura window height is restricted. --- resources/qml/Toolbar.qml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/resources/qml/Toolbar.qml b/resources/qml/Toolbar.qml index 63f608d635..db6c75f280 100644 --- a/resources/qml/Toolbar.qml +++ b/resources/qml/Toolbar.qml @@ -96,6 +96,8 @@ Item { UM.Controller.setActiveTool(model.id); } + + base.state = (index < toolsModel.count/2) ? "anchorAtTop" : "anchorAtBottom"; } } } @@ -219,4 +221,33 @@ Item visible: toolHint.text != "" } + + states: [ + State { + name: "anchorAtTop" + + AnchorChanges { + target: panelBorder + anchors.top: base.top + anchors.bottom: undefined + } + PropertyChanges { + target: panelBorder + anchors.topMargin: base.activeY + } + }, + State { + name: "anchorAtBottom" + + AnchorChanges { + target: panelBorder + anchors.top: undefined + anchors.bottom: base.top + } + PropertyChanges { + target: panelBorder + anchors.bottomMargin: -(base.activeY + UM.Theme.getSize("button").height) + } + } + ] } From 74984ca12a56f4e39a6077a839528c1bb4f961cd Mon Sep 17 00:00:00 2001 From: Mark Burton Date: Thu, 4 Jun 2020 11:29:23 +0100 Subject: [PATCH 2/3] Stop panel growing above first tool button. --- resources/qml/Toolbar.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/qml/Toolbar.qml b/resources/qml/Toolbar.qml index db6c75f280..da986cf0bf 100644 --- a/resources/qml/Toolbar.qml +++ b/resources/qml/Toolbar.qml @@ -246,7 +246,7 @@ Item } PropertyChanges { target: panelBorder - anchors.bottomMargin: -(base.activeY + UM.Theme.getSize("button").height) + anchors.bottomMargin: ((base.activeY + UM.Theme.getSize("button").height) > panelBorder.height) ? -(base.activeY + UM.Theme.getSize("button").height) : -panelBorder.height } } ] From f8c86cce4d02e9c0188219f6e43738bedacf639a Mon Sep 17 00:00:00 2001 From: Mark Burton Date: Thu, 4 Jun 2020 12:04:14 +0100 Subject: [PATCH 3/3] Improve readability and add comments. --- resources/qml/Toolbar.qml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/resources/qml/Toolbar.qml b/resources/qml/Toolbar.qml index da986cf0bf..0bf09b4d18 100644 --- a/resources/qml/Toolbar.qml +++ b/resources/qml/Toolbar.qml @@ -246,7 +246,14 @@ Item } PropertyChanges { target: panelBorder - anchors.bottomMargin: ((base.activeY + UM.Theme.getSize("button").height) > panelBorder.height) ? -(base.activeY + UM.Theme.getSize("button").height) : -panelBorder.height + anchors.bottomMargin: { + if (panelBorder.height > (base.activeY + UM.Theme.getSize("button").height)) { + // panel is tall, align the top of the panel with the top of the first tool button + return -panelBorder.height + } + // align the bottom of the panel with the bottom of the selected tool button + return -(base.activeY + UM.Theme.getSize("button").height) + } } } ]