Skip to content

Commit 236ba1d

Browse files
committed
[ui] Backdrop: Added getters for children indices from a backdrop
updateChildren gets invoked when the node is pressed resulting in an update call before the selection of the children nodes could happen
1 parent faa7287 commit 236ba1d

File tree

1 file changed

+31
-7
lines changed

1 file changed

+31
-7
lines changed

meshroom/ui/qml/GraphEditor/Backdrop.qml

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ Item {
2525
// The Item instantiating the delegates.
2626
property Item modelInstantiator: undefined
2727

28-
// Node Children for the Backdrop
28+
readonly property bool isBackdrop: true
29+
// Node Children for the Backdrop
2930
property var children: []
30-
31+
property var childrenIndices: []
32+
3133
property bool dragging: mouseArea.drag.active
3234
property bool resizing: leftDragger.drag.active || topDragger.drag.active
3335
/// Combined x and y
@@ -50,7 +52,7 @@ Item {
5052
signal moved(var position)
5153
signal entered()
5254
signal exited()
53-
55+
5456
// Size signal
5557
signal resized(var width, var height)
5658
signal resizedAndMoved(var width, var height, var position)
@@ -102,7 +104,12 @@ Item {
102104
}
103105
}
104106

107+
onPressed: {
108+
updateChildren();
109+
}
110+
105111
function updateChildren() {
112+
let indices = [];
106113
let nodes = [];
107114
const backdropRect = Qt.rect(root.node.x, root.node.y, root.node.nodeWidth, root.node.nodeHeight);
108115

@@ -113,17 +120,34 @@ Item {
113120

114121
const delegateRect = Qt.rect(delegate.x, delegate.y, delegate.width, delegate.height);
115122
if (Geom2D.rectRectFullIntersect(backdropRect, delegateRect)) {
116-
nodes.push(delegate);
123+
indices.push(i);
124+
nodes.push(delegate);
117125
}
118126
}
119-
children = nodes
127+
childrenIndices = indices;
128+
children = nodes;
120129
}
121130

122-
function getChildrenNodes() {
131+
function getChildrenNodes(refresh = false) {
123132
/**
124133
* Returns the current nodes which are a part of the Backdrop.
125134
*/
126-
return children
135+
// Update the children if required
136+
if (refresh) {
137+
updateChildren();
138+
}
139+
return children;
140+
}
141+
142+
function getChildrenIndices(refresh = false) {
143+
/**
144+
* Returns the current nodes' indices which are a part of the Backdrop.
145+
*/
146+
// Update the children if required
147+
if (refresh) {
148+
updateChildren();
149+
}
150+
return childrenIndices;
127151
}
128152

129153
// Main Layout

0 commit comments

Comments
 (0)