mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-08-09 06:45:09 -06:00
CURA-4234 fix topbar resize issues and removed hard coding numbers
This commit is contained in:
parent
3605edc565
commit
f3a6f50e2c
1 changed files with 36 additions and 23 deletions
|
@ -21,6 +21,22 @@ Rectangle
|
|||
property bool printerConnected: Cura.MachineManager.printerOutputDevices.length != 0
|
||||
property bool printerAcceptsCommands: printerConnected && Cura.MachineManager.printerOutputDevices[0].acceptsCommands
|
||||
|
||||
property int rightMargin: UM.Theme.getSize("sidebar").width + UM.Theme.getSize("default_margin").width;
|
||||
property int allItemsWidth: 0;
|
||||
|
||||
function updateMarginsAndSizes() {
|
||||
if (UM.Preferences.getValue("cura/sidebar_collapse")) {
|
||||
rightMargin = UM.Theme.getSize("default_margin").width;
|
||||
} else {
|
||||
rightMargin = UM.Theme.getSize("sidebar").width + UM.Theme.getSize("default_margin").width;
|
||||
}
|
||||
allItemsWidth = (
|
||||
logo.width + UM.Theme.getSize("topbar_logo_right_margin").width +
|
||||
UM.Theme.getSize("topbar_logo_right_margin").width + stagesMenuContainer.width +
|
||||
UM.Theme.getSize("default_margin").width + viewModeButton.width +
|
||||
rightMargin);
|
||||
}
|
||||
|
||||
UM.I18nCatalog
|
||||
{
|
||||
id: catalog
|
||||
|
@ -44,6 +60,7 @@ Rectangle
|
|||
|
||||
Row
|
||||
{
|
||||
id: stagesMenuContainer
|
||||
anchors.left: logo.right
|
||||
anchors.leftMargin: UM.Theme.getSize("topbar_logo_right_margin").width
|
||||
spacing: UM.Theme.getSize("default_margin").width
|
||||
|
@ -85,8 +102,8 @@ Rectangle
|
|||
anchors
|
||||
{
|
||||
verticalCenter: base.verticalCenter
|
||||
right: viewModeButton.right
|
||||
rightMargin: UM.Theme.getSize("default_margin").width + viewModeButton.width
|
||||
right: viewModeButton.left
|
||||
rightMargin: UM.Theme.getSize("default_margin").width
|
||||
}
|
||||
|
||||
// #1 3d view
|
||||
|
@ -98,7 +115,7 @@ Rectangle
|
|||
onClicked:{
|
||||
UM.Controller.rotateView("3d", 0);
|
||||
}
|
||||
visible: base.width > 1100
|
||||
visible: base.width - allItemsWidth - 4 * this.width > 0;
|
||||
}
|
||||
|
||||
// #2 Front view
|
||||
|
@ -110,7 +127,7 @@ Rectangle
|
|||
onClicked:{
|
||||
UM.Controller.rotateView("home", 0);
|
||||
}
|
||||
visible: base.width > 1130
|
||||
visible: base.width - allItemsWidth - 3 * this.width > 0;
|
||||
}
|
||||
|
||||
// #3 Top view
|
||||
|
@ -122,7 +139,7 @@ Rectangle
|
|||
onClicked:{
|
||||
UM.Controller.rotateView("y", 90);
|
||||
}
|
||||
visible: base.width > 1160
|
||||
visible: base.width - allItemsWidth - 2 * this.width > 0;
|
||||
}
|
||||
|
||||
// #4 Left view
|
||||
|
@ -134,7 +151,7 @@ Rectangle
|
|||
onClicked:{
|
||||
UM.Controller.rotateView("x", 90);
|
||||
}
|
||||
visible: base.width > 1190
|
||||
visible: base.width - allItemsWidth - 1 * this.width > 0;
|
||||
}
|
||||
|
||||
// #5 Left view
|
||||
|
@ -146,14 +163,13 @@ Rectangle
|
|||
onClicked:{
|
||||
UM.Controller.rotateView("x", -90);
|
||||
}
|
||||
visible: base.width > 1210
|
||||
visible: base.width - allItemsWidth > 0;
|
||||
}
|
||||
}
|
||||
|
||||
ComboBox
|
||||
{
|
||||
id: viewModeButton
|
||||
property int rightMargin: UM.Theme.getSize("sidebar").width + UM.Theme.getSize("default_margin").width;
|
||||
|
||||
anchors {
|
||||
verticalCenter: parent.verticalCenter
|
||||
|
@ -161,14 +177,6 @@ Rectangle
|
|||
rightMargin: rightMargin
|
||||
}
|
||||
|
||||
function updateMargins() {
|
||||
if (UM.Preferences.getValue("cura/sidebar_collapse")) {
|
||||
rightMargin = UM.Theme.getSize("default_margin").width;
|
||||
} else {
|
||||
rightMargin = UM.Theme.getSize("sidebar").width + UM.Theme.getSize("default_margin").width;
|
||||
}
|
||||
}
|
||||
|
||||
style: UM.Theme.styles.combobox
|
||||
visible: UM.Controller.activeStage.stageId != "MonitorStage"
|
||||
|
||||
|
@ -210,13 +218,6 @@ Rectangle
|
|||
}
|
||||
}
|
||||
|
||||
// Expand or collapse sidebar
|
||||
Connections
|
||||
{
|
||||
target: Cura.Actions.expandSidebar
|
||||
onTriggered: viewModeButton.updateMargins()
|
||||
}
|
||||
|
||||
Loader
|
||||
{
|
||||
id: view_panel
|
||||
|
@ -233,4 +234,16 @@ Rectangle
|
|||
source: UM.ActiveView.valid ? UM.ActiveView.activeViewPanel : "";
|
||||
}
|
||||
|
||||
// Expand or collapse sidebar
|
||||
Connections
|
||||
{
|
||||
target: Cura.Actions.expandSidebar
|
||||
onTriggered: updateMarginsAndSizes()
|
||||
}
|
||||
|
||||
Component.onCompleted:
|
||||
{
|
||||
updateMarginsAndSizes();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue