blob: 1e335472d46d1de8615e157f7a08750e18bec7db (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
|
// Copyright (c) 2018 Ultimaker B.V.
// Cura is released under the terms of the LGPLv3 or higher.
import QtQuick 2.2
import QtQuick.Controls 2.3
import UM 1.2 as UM
import Cura 1.0 as Cura
Item
{
id: base
width: buttons.width
height: buttons.height
property int activeY
Item
{
id: buttons
width: parent.visible ? toolButtons.width : 0
height: childrenRect.height
Behavior on width { NumberAnimation { duration: 100 } }
// Used to create a rounded rectangle behind the toolButtons
Rectangle
{
anchors
{
fill: toolButtons
leftMargin: -radius - border.width
rightMargin: -border.width
topMargin: -border.width
bottomMargin: -border.width
}
radius: UM.Theme.getSize("default_radius").width
color: UM.Theme.getColor("lining")
}
Column
{
id: toolButtons
anchors.top: parent.top
anchors.right: parent.right
spacing: UM.Theme.getSize("default_lining").height
Repeater
{
id: repeat
model: UM.ToolModel { id: toolsModel }
width: childrenRect.width
height: childrenRect.height
delegate: ToolbarButton
{
text: model.name + (model.shortcut ? (" (" + model.shortcut + ")") : "")
checkable: true
checked: model.active
enabled: model.enabled && UM.Selection.hasSelection && UM.Controller.toolsEnabled
isTopElement: toolsModel.getItem(0).id == model.id
isBottomElement: toolsModel.getItem(toolsModel.count - 1).id == model.id
toolItem: UM.RecolorImage
{
source: UM.Theme.getIcon(model.icon) != "" ? UM.Theme.getIcon(model.icon) : "file:///" + model.location + "/" + model.icon
color: UM.Theme.getColor("toolbar_button_text")
sourceSize: UM.Theme.getSize("button_icon")
}
onCheckedChanged:
{
if (checked)
{
base.activeY = y;
}
}
//Workaround since using ToolButton's onClicked would break the binding of the checked property, instead
//just catch the click so we do not trigger that behaviour.
MouseArea
{
anchors.fill: parent;
onClicked:
{
forceActiveFocus() //First grab focus, so all the text fields are updated
if(parent.checked)
{
UM.Controller.setActiveTool(null);
}
else
{
UM.Controller.setActiveTool(model.id);
}
}
}
}
}
}
// Used to create a rounded rectangle behind the extruderButtons
Rectangle
{
anchors
{
fill: extruderButtons
leftMargin: -radius - border.width
rightMargin: -border.width
topMargin: -border.width
bottomMargin: -border.width
}
radius: UM.Theme.getSize("default_radius").width
color: UM.Theme.getColor("lining")
visible: extrudersModel.items.length > 1
}
Column
{
id: extruderButtons
anchors.topMargin: UM.Theme.getSize("default_margin").height
anchors.top: toolButtons.bottom
anchors.right: parent.right
spacing: UM.Theme.getSize("default_lining").height
Repeater
{
id: extruders
width: childrenRect.width
height: childrenRect.height
model: extrudersModel.items.length > 1 ? extrudersModel : 0
delegate: ExtruderButton
{
extruder: model
isTopElement: extrudersModel.getItem(0).id == model.id
isBottomElement: extrudersModel.getItem(extrudersModel.rowCount() - 1).id == model.id
}
}
}
}
Cura.ExtrudersModel
{
id: extrudersModel
}
UM.PointingRectangle
{
id: panelBorder
anchors.left: parent.right
anchors.leftMargin: UM.Theme.getSize("default_margin").width
anchors.top: base.top
anchors.topMargin: base.activeY
z: buttons.z - 1
target: Qt.point(parent.right, base.activeY + Math.round(UM.Theme.getSize("button").height/2))
arrowSize: UM.Theme.getSize("default_arrow").width
width:
{
if (panel.item && panel.width > 0)
{
return Math.max(panel.width + 2 * UM.Theme.getSize("default_margin").width)
}
else
{
return 0;
}
}
height: panel.item ? panel.height + 2 * UM.Theme.getSize("default_margin").height : 0
opacity: panel.item && panel.width > 0 ? 1 : 0
Behavior on opacity { NumberAnimation { duration: 100 } }
color: UM.Theme.getColor("tool_panel_background")
borderColor: UM.Theme.getColor("lining")
borderWidth: UM.Theme.getSize("default_lining").width
MouseArea //Catch all mouse events (so scene doesnt handle them)
{
anchors.fill: parent
}
Loader
{
id: panel
x: UM.Theme.getSize("default_margin").width
y: UM.Theme.getSize("default_margin").height
source: UM.ActiveTool.valid ? UM.ActiveTool.activeToolPanel : ""
enabled: UM.Controller.toolsEnabled
}
}
// This rectangle displays the information about the current angle etc. when
// dragging a tool handle.
Rectangle
{
x: -base.x + base.mouseX + UM.Theme.getSize("default_margin").width
y: -base.y + base.mouseY + UM.Theme.getSize("default_margin").height
width: toolHint.width + UM.Theme.getSize("default_margin").width
height: toolHint.height;
color: UM.Theme.getColor("tooltip")
Label
{
id: toolHint
text: UM.ActiveTool.properties.getValue("ToolHint") != undefined ? UM.ActiveTool.properties.getValue("ToolHint") : ""
color: UM.Theme.getColor("tooltip_text")
font: UM.Theme.getFont("default")
anchors.horizontalCenter: parent.horizontalCenter
}
visible: toolHint.text != ""
}
}
|