Skip to content

Commit 5bbd7ef

Browse files
committed
[GraphEditor] AttributePin: Add a tree view for children attributes
1 parent c1d013b commit 5bbd7ef

File tree

1 file changed

+52
-18
lines changed

1 file changed

+52
-18
lines changed

meshroom/ui/qml/GraphEditor/AttributePin.qml

+52-18
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import QtQuick.Controls
33
import QtQuick.Layouts
44

55
import Utils 1.0
6+
import MaterialIcons 2.2
67

78
/**
89
* The representation of an Attribute on a Node.
@@ -71,10 +72,6 @@ RowLayout {
7172
return label
7273
}
7374

74-
onExpandedChanged: {
75-
nameLabel.text = updateLabel()
76-
}
77-
7875
// Instantiate empty Items for each child attribute
7976
Repeater {
8077
id: childrenRepeater
@@ -215,29 +212,66 @@ RowLayout {
215212
id: nameContainer
216213
implicitHeight: childrenRect.height
217214
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+
}
219221

220-
Label {
222+
MaterialToolLabel {
221223
id: nameLabel
222224

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+
223230
enabled: !root.readOnly
224231
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) {
236238
return Colors.lightgrey
237-
else if (hovered)
239+
} else if (hovered) {
238240
return palette.highlight
241+
}
239242
return palette.text
240243
}
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+
}
241275
}
242276
}
243277

0 commit comments

Comments
 (0)