mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-08-06 10:18:42 +02:00
[ui] Node: use TextMetrics to expand elided attribute pins at hover
This commit is contained in:
parent
fc3e17e6d4
commit
4d6195cf81
1 changed files with 26 additions and 18 deletions
|
@ -134,30 +134,38 @@ RowLayout {
|
||||||
point1y: parent.width / 2
|
point1y: parent.width / 2
|
||||||
point2x: dragTarget.x + dragTarget.width/2
|
point2x: dragTarget.x + dragTarget.width/2
|
||||||
point2y: dragTarget.y + dragTarget.height/2
|
point2y: dragTarget.y + dragTarget.height/2
|
||||||
color: nameLabel.palette.text
|
color: nameLabel.color
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attribute name
|
// Attribute name
|
||||||
Label {
|
Item {
|
||||||
id: nameLabel
|
id: nameContainer
|
||||||
text: attribute.name
|
|
||||||
elide: Text.ElideMiddle
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
font.pointSize: 5
|
implicitHeight: childrenRect.height
|
||||||
horizontalAlignment: attribute.isOutput ? Text.AlignRight : Text.AlignLeft
|
|
||||||
|
|
||||||
Loader {
|
TextMetrics {
|
||||||
active: parent.truncated && (connectMA.containsMouse || connectMA.drag.active || dropArea.containsDrag)
|
id: metrics
|
||||||
anchors.right: root.layoutDirection == Qt.LeftToRight ? undefined : nameLabel.right
|
property bool truncated: width > nameContainer.width
|
||||||
// Non-elided label
|
text: nameLabel.text
|
||||||
sourceComponent: Label {
|
font: nameLabel.font
|
||||||
leftPadding: root.layoutDirection == Qt.LeftToRight ? 0 : 1
|
}
|
||||||
rightPadding: root.layoutDirection == Qt.LeftToRight ? 1 : 0
|
|
||||||
text: attribute.name
|
Label {
|
||||||
background: Rectangle {
|
id: nameLabel
|
||||||
color: parent.palette.window
|
|
||||||
}
|
property bool hovered: (connectMA.containsMouse || connectMA.drag.active || dropArea.containsDrag)
|
||||||
|
text: attribute.name
|
||||||
|
elide: hovered ? Text.ElideNone : Text.ElideMiddle
|
||||||
|
width: hovered ? contentWidth : parent.width
|
||||||
|
font.pointSize: 5
|
||||||
|
horizontalAlignment: attribute.isOutput ? Text.AlignRight : Text.AlignLeft
|
||||||
|
anchors.right: attribute.isOutput ? parent.right : undefined
|
||||||
|
|
||||||
|
background: Rectangle {
|
||||||
|
visible: parent.hovered && metrics.truncated
|
||||||
|
anchors { fill: parent; leftMargin: -1; rightMargin: -1 }
|
||||||
|
color: parent.palette.window
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue