[ui] Hide disabled File attributes and their edges but keep the connections

This commit effectively hides a node's attributes when they are disabled.
If these attributes have connections, the edges representing these
connections are hidden but not destroyed. When the edges are hidden, if
one of the connected attributes is still enabled, its pin becomes empty as
if it was not connected to anything.

If the disabled attribute is re-enabled and the connection has not been
broken (if the enabled attribute on the other side of the edge has not
been reconnected to another attribute, for example), the edge re-appears.
If the connection has been broken, then the attribute will be unconnected.

Hidden connections are saved in project files and taken into account when
a project file containing some is loaded.
This commit is contained in:
Candice Bentéjac 2023-03-08 16:45:28 +01:00
parent de39143e83
commit 6f1ac9a06e
3 changed files with 46 additions and 4 deletions

View file

@ -35,6 +35,16 @@ RowLayout {
layoutDirection: Qt.LeftToRight
spacing: 3
function updatePin(isSrc, isVisible)
{
if (isSrc) {
innerOutputAnchor.linkEnabled = isVisible
} else {
innerInputAnchor.linkEnabled = isVisible
}
}
// Instantiate empty Items for each child attribute
Repeater {
id: childrenRepeater
@ -59,7 +69,9 @@ RowLayout {
color: Colors.sysPalette.base
Rectangle {
visible: inputConnectMA.containsMouse || childrenRepeater.count > 0 || (attribute && attribute.isLink) || inputConnectMA.drag.active || inputDropArea.containsDrag
id: innerInputAnchor
property bool linkEnabled: true
visible: inputConnectMA.containsMouse || childrenRepeater.count > 0 || (attribute && attribute.isLink && linkEnabled) || inputConnectMA.drag.active || inputDropArea.containsDrag
radius: isList ? 0 : 2
anchors.fill: parent
anchors.margins: 2
@ -207,7 +219,9 @@ RowLayout {
color: Colors.sysPalette.base
Rectangle {
visible: attribute.hasOutputConnections || outputConnectMA.containsMouse || outputConnectMA.drag.active || outputDropArea.containsDrag
id: innerOutputAnchor
property bool linkEnabled: true
visible: (attribute.hasOutputConnections && linkEnabled) || outputConnectMA.containsMouse || outputConnectMA.drag.active || outputDropArea.containsDrag
radius: isList ? 0 : 2
anchors.fill: parent
anchors.margins: 2