[ui] Node: add selected property + selection border

* use more efficient selection border instead of slightly changing header's color
* require activeFocus when selected
This commit is contained in:
Yann Lanthony 2018-07-26 22:50:42 +02:00
parent 06f3d140df
commit e6e2c18aa8
2 changed files with 14 additions and 1 deletions

View file

@ -267,7 +267,8 @@ Item {
node: object
width: uigraph.layout.nodeWidth
readOnly: root.readOnly
baseColor: root.selectedNode == node ? Qt.lighter(defaultColor, 1.2) : defaultColor
selected: root.selectedNode == node
onSelectedChanged: if(selected) forceActiveFocus()
onAttributePinCreated: registerAttributePin(attribute, pin)
onAttributePinDeleted: unregisterAttributePin(attribute, pin)

View file

@ -12,6 +12,7 @@ Item {
property color shadowColor: "black"
readonly property bool isCompatibilityNode: node.hasOwnProperty("compatibilityIssue")
readonly property color defaultColor: isCompatibilityNode ? "#444" : "#607D8B"
property bool selected: false
signal pressed(var mouse)
signal doubleClicked(var mouse)
@ -52,6 +53,17 @@ Item {
}
}
// Selection border
Rectangle {
anchors.fill: parent
anchors.margins: -border.width
visible: root.selected
border.width: 2.5
border.color: activePalette.highlight
opacity: 0.9
color: "transparent"
}
Rectangle {
id: background
anchors.fill: parent