Skip to content

Commit 0716f00

Browse files
committed
[GraphEditor] AttributePin: Handle width and elide for attributes' name
1 parent 3234bb9 commit 0716f00

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

meshroom/ui/qml/GraphEditor/AttributePin.qml

+16-2
Original file line numberDiff line numberDiff line change
@@ -236,13 +236,26 @@ RowLayout {
236236
id: nameLabel
237237

238238
anchors.rightMargin: 0
239-
anchors.right: root.attribute && root.attribute.isOutput ? parent.right : undefined
240239
labelIconRow.layoutDirection: root.attribute.isOutput ? Qt.RightToLeft : Qt.LeftToRight
240+
anchors.right: root.attribute && root.attribute.isOutput ? parent.right : undefined
241241
labelIconRow.spacing: 0
242+
width: {
243+
if (hovered) {
244+
return icon.width + label.contentWidth
245+
} else {
246+
if (nameContainer.width > 0 && icon.width + label.contentWidth < nameContainer.width)
247+
return icon.width + label.contentWidth
248+
return nameContainer.width
249+
}
250+
}
242251

243252
enabled: !root.readOnly
244253
visible: true
245-
property bool hovered: (inputConnectMA.containsMouse || inputConnectMA.drag.active ||
254+
property bool parentNotReady: nameContainer.width == 0 // Allows to trigger a change of state once the parent is ready,
255+
// ensuring the correct width of the elements upon their first
256+
// display without waiting for a mouse interaction
257+
property bool hovered: parentNotReady ||
258+
(inputConnectMA.containsMouse || inputConnectMA.drag.active ||
246259
inputDropArea.containsDrag || outputConnectMA.containsMouse ||
247260
outputConnectMA.drag.active || outputDropArea.containsDrag)
248261

@@ -259,6 +272,7 @@ RowLayout {
259272
// Text
260273
label.text: root.attribute.label
261274
label.font.pointSize: 7
275+
labelWidth: hovered ? label.contentWidth : nameLabel.width - icon.width
262276
label.elide: hovered ? Text.ElideNone : Text.ElideMiddle
263277
label.horizontalAlignment: root.attribute && root.attribute.isOutput ? Text.AlignRight : Text.AlignLeft
264278

0 commit comments

Comments
 (0)