@@ -3,6 +3,7 @@ import QtQuick.Controls
3
3
import QtQuick.Layouts
4
4
5
5
import Utils 1.0
6
+ import MaterialIcons 2.2
6
7
7
8
/**
8
9
* The representation of an Attribute on a Node.
@@ -71,10 +72,6 @@ RowLayout {
71
72
return label
72
73
}
73
74
74
- onExpandedChanged: {
75
- nameLabel .text = updateLabel ()
76
- }
77
-
78
75
// Instantiate empty Items for each child attribute
79
76
Repeater {
80
77
id: childrenRepeater
@@ -215,29 +212,66 @@ RowLayout {
215
212
id: nameContainer
216
213
implicitHeight: childrenRect .height
217
214
Layout .fillWidth : true
218
- Layout .alignment : Qt .AlignVCenter
215
+ Layout .alignment : {
216
+ if (attribute .isOutput ) {
217
+ return Qt .AlignRight | Qt .AlignVCenter
218
+ }
219
+ return Qt .AlignLeft | Qt .AlignVCenter
220
+ }
219
221
220
- Label {
222
+ MaterialToolLabel {
221
223
id: nameLabel
222
224
225
+ anchors .rightMargin : 0
226
+ anchors .right : attribute && attribute .isOutput ? parent .right : undefined
227
+ labelIconRow .layoutDirection : attribute .isOutput ? Qt .RightToLeft : Qt .LeftToRight
228
+ labelIconRow .spacing : 0
229
+
223
230
enabled: ! root .readOnly
224
231
visible: true
225
- property bool hovered: (inputConnectMA .containsMouse || inputConnectMA .drag .active || inputDropArea .containsDrag || outputConnectMA .containsMouse || outputConnectMA .drag .active || outputDropArea .containsDrag )
226
- text: root .updateLabel ()
227
- elide: hovered ? Text .ElideNone : Text .ElideMiddle
228
- width: hovered ? contentWidth : parent .width
229
- font .pointSize : 7
230
- font .italic : isChild ? true : false
231
- horizontalAlignment: attribute && attribute .isOutput ? Text .AlignRight : Text .AlignLeft
232
- anchors .right : attribute && attribute .isOutput ? parent .right : undefined
233
- rightPadding: 0
234
- color: {
235
- if ((object .hasOutputConnections || object .isLink ) && ! object .enabled )
232
+ property bool hovered: (inputConnectMA .containsMouse || inputConnectMA .drag .active ||
233
+ inputDropArea .containsDrag || outputConnectMA .containsMouse ||
234
+ outputConnectMA .drag .active || outputDropArea .containsDrag )
235
+
236
+ labelIconColor: {
237
+ if ((object .hasOutputConnections || object .isLink ) && ! object .enabled ) {
236
238
return Colors .lightgrey
237
- else if (hovered)
239
+ } else if (hovered) {
238
240
return palette .highlight
241
+ }
239
242
return palette .text
240
243
}
244
+ labelIconMouseArea .enabled : false // Prevent mixing mouse interactions between the label and the pin context
245
+
246
+ // Text
247
+ label .text : attribute .label
248
+ label .font .pointSize : 7
249
+ label .elide : hovered ? Text .ElideNone : Text .ElideMiddle
250
+ label .horizontalAlignment : attribute && attribute .isOutput ? Text .AlignRight : Text .AlignLeft
251
+
252
+ // Icon
253
+ iconText: {
254
+ if (isGroup) {
255
+ return expanded ? MaterialIcons .expand_less : MaterialIcons .chevron_right
256
+ }
257
+ return " "
258
+ }
259
+ iconSize: 7
260
+ icon .horizontalAlignment : attribute && attribute .isOutput ? Text .AlignRight : Text .AlignLeft
261
+
262
+ // Handle tree view for nested attributes
263
+ icon .leftPadding : {
264
+ if (attribute .depth != 0 && ! attribute .isOutput ) {
265
+ return attribute .depth * 10
266
+ }
267
+ return 0
268
+ }
269
+ icon .rightPadding : {
270
+ if (attribute .depth != 0 && attribute .isOutput ) {
271
+ return attribute .depth * 10
272
+ }
273
+ return 0
274
+ }
241
275
}
242
276
}
243
277
0 commit comments