[ui] Node: elide attribute names + extend at mouse hover

This commit is contained in:
Yann Lanthony 2017-12-19 16:17:33 +01:00
parent 8c7a4bcc0f
commit a9bffb6c74
2 changed files with 34 additions and 6 deletions

View file

@ -1,10 +1,11 @@
import QtQuick 2.9 import QtQuick 2.9
import QtQuick.Controls 2.3 import QtQuick.Controls 2.3
import QtQuick.Layouts 1.3
/** /**
The representation of an Attribute on a Node. The representation of an Attribute on a Node.
*/ */
Row { RowLayout {
id: root id: root
property var nodeItem property var nodeItem
@ -109,7 +110,33 @@ Row {
Label { Label {
id: nameLabel id: nameLabel
text: attribute.name text: attribute.name
elide: Text.ElideMiddle
Layout.fillWidth: true
font.pointSize: 5 font.pointSize: 5
horizontalAlignment: attribute.isOutput ? Text.AlignRight : Text.AlignLeft
// Extend truncated names at mouse hover
MouseArea {
id: ma
anchors.fill: parent
enabled: parent.truncated
visible: enabled
hoverEnabled: true
acceptedButtons: Qt.NoButton
}
Loader {
active: ma.containsMouse
anchors.right: root.layoutDirection == Qt.LeftToRight ? undefined : nameLabel.right
// Non-elided label
sourceComponent: Label {
leftPadding: root.layoutDirection == Qt.LeftToRight ? 0 : 1
rightPadding: root.layoutDirection == Qt.LeftToRight ? 1 : 0
text: attribute.name
background: Rectangle {
color: palette.window
}
}
}
} }
state: connectMA.pressed ? "Dragging" : "" state: connectMA.pressed ? "Dragging" : ""

View file

@ -98,19 +98,20 @@ Item {
Item { width: 1; height: 2} Item { width: 1; height: 2}
RowLayout { Item {
width: parent.width + 6 width: parent.width + 6
height: childrenRect.height
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
Column { Column {
id: inputs id: inputs
Layout.fillWidth: true width: parent.width / 2
Layout.fillHeight: true
Repeater { Repeater {
model: node.attributes model: node.attributes
delegate: Loader { delegate: Loader {
active: !object.isOutput && object.type == "File" active: !object.isOutput && object.type == "File"
|| (object.type == "ListAttribute" && object.desc.elementDesc.type == "File") // TODO: review this || (object.type == "ListAttribute" && object.desc.elementDesc.type == "File") // TODO: review this
width: inputs.width
sourceComponent: AttributePin { sourceComponent: AttributePin {
id: inPin id: inPin
@ -125,8 +126,7 @@ Item {
} }
Column { Column {
id: outputs id: outputs
Layout.fillWidth: true width: parent.width / 2
Layout.fillHeight: true
anchors.right: parent.right anchors.right: parent.right
Repeater { Repeater {
model: node.attributes model: node.attributes
@ -134,6 +134,7 @@ Item {
delegate: Loader { delegate: Loader {
active: object.isOutput active: object.isOutput
anchors.right: parent.right anchors.right: parent.right
width: outputs.width
sourceComponent: AttributePin { sourceComponent: AttributePin {
id: outPin id: outPin