Skip to content

Commit 4b91d21

Browse files
committed
[ui] Node: Implementation of the Backdrop Node interface.
A Backdrop node is default of pale yellow colour and is of the same colour in the header and the bottom area representing the node. Backdrop node allows user resize by dragging on the mouse area at the edges and also allows text appearing below the header from the notes section in the attribute panel.
1 parent 556fade commit 4b91d21

File tree

1 file changed

+179
-9
lines changed

1 file changed

+179
-9
lines changed

meshroom/ui/qml/GraphEditor/Node.qml

Lines changed: 179 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,25 @@ Item {
1919
property bool readOnly: node.locked
2020
/// Whether the node is in compatibility mode
2121
readonly property bool isCompatibilityNode: node ? node.hasOwnProperty("compatibilityIssue") : false
22+
/// Whether the node is a backdrop node
23+
readonly property bool isBackdrop: node ? node.isBackdrop : false
2224
/// Mouse related states
2325
property bool mainSelected: false
2426
property bool selected: false
2527
property bool hovered: false
26-
property bool dragging: mouseArea.drag.active
28+
property bool dragging: mouseArea.drag.active || leftDragger.drag.active
2729
/// Combined x and y
2830
property point position: Qt.point(x, y)
2931
/// Styling
3032
property color shadowColor: "#cc000000"
31-
readonly property color defaultColor: isCompatibilityNode ? "#444" : !node.isComputable ? "#BA3D69" : activePalette.base
33+
readonly property color defaultColor: _defaultColor()
3234
property color baseColor: defaultColor
3335

3436
property point mousePosition: Qt.point(mouseArea.mouseX, mouseArea.mouseY)
3537

3638
Item {
3739
id: m
38-
property bool displayParams: false
40+
property bool displayParams: isBackdrop ? true : false
3941
}
4042

4143
// Mouse interaction related signals
@@ -47,6 +49,9 @@ Item {
4749
signal entered()
4850
signal exited()
4951

52+
// Size signal
53+
signal resized(var width, var height)
54+
5055
// Already connected attribute with another edge in DropArea
5156
signal edgeAboutToBeRemoved(var input)
5257

@@ -62,6 +67,9 @@ Item {
6267
x: root.node ? root.node.x : undefined
6368
y: root.node ? root.node.y : undefined
6469

70+
// The backdrop node always needs to be at the back
71+
z: isBackdrop ? -1 : 1
72+
6573
implicitHeight: childrenRect.height
6674

6775
SystemPalette { id: activePalette }
@@ -75,6 +83,21 @@ Item {
7583
}
7684
}
7785

86+
function _defaultColor() {
87+
/*
88+
* Returns the default color for the Node.
89+
* If the node is in Compatibility Mode - Grey
90+
* If the node is an InputNode - Pinkish
91+
* If the node is a Backdrop - Yellow or the Node Color
92+
*/
93+
if (isCompatibilityNode) return "#444"
94+
else if (isBackdrop) return node.color === "" ? "#fffb85" : node.color
95+
else if (!node.isComputable) return "#BA3D69"
96+
97+
// The default color for the node
98+
return activePalette.base
99+
}
100+
78101
function formatInternalAttributesTooltip(invalidation, comment) {
79102
/*
80103
* Creates a string that contains the invalidation message (if it is not empty) in bold,
@@ -120,7 +143,7 @@ Item {
120143
// Main Layout
121144
MouseArea {
122145
id: mouseArea
123-
width: parent.width
146+
width: isBackdrop ? node.nodeWidth : parent.width
124147
height: body.height
125148
drag.target: root
126149
// Small drag threshold to avoid moving the node by mistake
@@ -141,6 +164,138 @@ Item {
141164

142165
cursorShape: drag.active ? Qt.ClosedHandCursor : Qt.ArrowCursor
143166

167+
/// Backdrop Resize Controls ???
168+
///
169+
/// Resize Right Side
170+
///
171+
Rectangle {
172+
width: 4
173+
height: nodeContent.height
174+
175+
color: baseColor
176+
opacity: 0
177+
178+
// Only Visible for a backdrop node
179+
visible: isBackdrop
180+
181+
anchors.horizontalCenter: parent.right
182+
183+
// This mouse area serves as the dragging rectangle
184+
MouseArea {
185+
id: rightDragger
186+
187+
cursorShape: Qt.SizeHorCursor
188+
anchors.fill: parent
189+
190+
drag{ target: parent; axis: Drag.XAxis }
191+
192+
onMouseXChanged: {
193+
if (drag.active) {
194+
// Width of the Area
195+
let w = 0
196+
197+
// Update the area width
198+
w = mouseArea.width + mouseX
199+
200+
// Ensure we have a minimum width always
201+
if (w < 300) {
202+
w = 300
203+
}
204+
205+
// emit the width and height
206+
root.resized(w, nodeContent.height)
207+
}
208+
}
209+
}
210+
}
211+
212+
///
213+
/// Resize Left Side
214+
///
215+
Rectangle {
216+
width: 4
217+
height: nodeContent.height
218+
219+
color: baseColor
220+
opacity: 0
221+
222+
// Only Visible for a backdrop node
223+
visible: isBackdrop
224+
225+
anchors.horizontalCenter: parent.left
226+
227+
// This mouse area serves as the dragging rectangle
228+
MouseArea {
229+
id: leftDragger
230+
231+
cursorShape: Qt.SizeHorCursor
232+
anchors.fill: parent
233+
234+
drag{ target: parent; axis: Drag.XAxis }
235+
236+
onMouseXChanged: {
237+
if (drag.active) {
238+
// Width of the Area
239+
let w = 0
240+
241+
// Update the area width
242+
w = mouseArea.width - mouseX
243+
244+
// Ensure we have a minimum width always
245+
if (w > 300) {
246+
// Update the node's x position
247+
root.x = root.x + mouseX
248+
// Emit the updated width and height
249+
root.resized(w, nodeContent.height)
250+
}
251+
}
252+
}
253+
}
254+
}
255+
256+
///
257+
/// Resize Bottom
258+
///
259+
Rectangle {
260+
width: mouseArea.width
261+
height: 4
262+
263+
color: baseColor
264+
opacity: 0
265+
266+
// Only Visible for a backdrop node
267+
visible: isBackdrop
268+
269+
anchors.verticalCenter: nodeContent.bottom
270+
271+
MouseArea {
272+
id: bottomDragger
273+
274+
cursorShape: Qt.SizeVerCursor
275+
anchors.fill: parent
276+
277+
drag{ target: parent; axis: Drag.YAxis }
278+
279+
onMouseYChanged: {
280+
if (drag.active) {
281+
// Height of the node
282+
let h = 0
283+
284+
// Update the height
285+
h = nodeContent.height + mouseY
286+
287+
// Ensure a minimum height
288+
if (h < 300) {
289+
h = 300
290+
}
291+
292+
// emit the width and height for it to be updated
293+
root.resized(mouseArea.width, h)
294+
}
295+
}
296+
}
297+
}
298+
144299
// Selection border
145300
Rectangle {
146301
anchors.fill: nodeContent
@@ -168,7 +323,7 @@ Item {
168323
Rectangle {
169324
id: background
170325
anchors.fill: nodeContent
171-
color: node.color === "" ? Qt.lighter(activePalette.base, 1.4) : node.color
326+
color: isBackdrop ? baseColor : node.color === "" ? Qt.lighter(activePalette.base, 1.4) : node.color
172327
layer.enabled: true
173328
layer.effect: DropShadow { radius: 3; color: shadowColor }
174329
radius: 3
@@ -178,7 +333,7 @@ Item {
178333
Rectangle {
179334
id: nodeContent
180335
width: parent.width
181-
height: childrenRect.height
336+
height: isBackdrop ? node.nodeHeight : childrenRect.height
182337
color: "transparent"
183338

184339
// Data Layout
@@ -215,7 +370,7 @@ Item {
215370
Layout.fillWidth: true
216371
text: node ? node.label : ""
217372
padding: 4
218-
color: root.mainSelected ? "white" : activePalette.text
373+
color: isBackdrop ? "#2b2b2b" : root.mainSelected ? "white" : activePalette.text
219374
elide: Text.ElideMiddle
220375
font.pointSize: 8
221376
}
@@ -244,7 +399,7 @@ Item {
244399
MaterialToolButton {
245400
property string baseText: "<b>Shares internal folder (data) with other node(s). Hold click for details.</b>"
246401
property string toolTipText: visible ? baseText : ""
247-
visible: node.hasDuplicates
402+
visible: !isBackdrop && node.hasDuplicates
248403
text: MaterialIcons.layers
249404
font.pointSize: 7
250405
padding: 2
@@ -294,7 +449,7 @@ Item {
294449

295450
MaterialLabel {
296451
id: nodeComment
297-
visible: node.comment !== "" || node.invalidation !== ""
452+
visible: !isBackdrop && (node.comment !== "" || node.invalidation !== "")
298453
text: MaterialIcons.comment
299454
padding: 2
300455
font.pointSize: 7
@@ -380,6 +535,20 @@ Item {
380535
// Vertical Spacer
381536
Item { width: parent.width; height: 2 }
382537

538+
// Node Text
539+
Rectangle {
540+
y: header.height
541+
542+
// Show only when the node is backdrop node and if we have a comment
543+
visible: isBackdrop && node.comment
544+
545+
Text {
546+
text: node.comment
547+
padding: 4
548+
font.pointSize: node.fontSize
549+
}
550+
}
551+
383552
// Input/Output Attributes
384553
Item {
385554
id: nodeAttributes
@@ -535,6 +704,7 @@ Item {
535704
spacing: 0
536705
anchors.margins: 0
537706
font.pointSize: 10
707+
visible: !isBackdrop
538708
onClicked: {
539709
m.displayParams = ! m.displayParams
540710
}

0 commit comments

Comments
 (0)