Skip to content

Commit

Permalink
[ui] GraphEditor: Updated Resizing behaviour for Backdrop
Browse files Browse the repository at this point in the history
Updating Selection behaviour for Backdrop based Nodes
  • Loading branch information
waaake committed Dec 11, 2024
1 parent 03e6d98 commit 0a4bf9f
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 4 deletions.
2 changes: 2 additions & 0 deletions meshroom/core/desc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
)
from .node import (
AVCommandLineNode,
Backdrop,
CommandLineNode,
InitNode,
InputNode,
Expand Down Expand Up @@ -49,6 +50,7 @@
"StaticNodeSize",
# node
"AVCommandLineNode",
"Backdrop",
"CommandLineNode",
"InitNode",
"InputNode",
Expand Down
64 changes: 63 additions & 1 deletion meshroom/core/desc/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import shlex

from .computation import Level, StaticNodeSize
from .attribute import StringParam, ColorParam
from .attribute import StringParam, ColorParam, FloatParam, IntParam

from meshroom.core import cgroup

Expand Down Expand Up @@ -122,6 +122,68 @@ def __init__(self):
def processChunk(self, chunk):
pass

def stopProcess(self, chunk):
pass


class Backdrop(InputNode):
""" A Backdrop for other nodes.
"""

# The internal inputs' of Backdrop Node needs a Integer Field to determine the font size for the comment
internalInputs = [
StringParam(
name="invalidation",
label="Invalidation Message",
description="A message that will invalidate the node's output folder.\n"
"This is useful for development, we can invalidate the output of the node when we modify the code.\n"
"It is displayed in bold font in the invalidation/comment messages tooltip.",
value="",
semantic="multiline",
advanced=True,
uidIgnoreValue="", # If the invalidation string is empty, it does not participate to the node's UID
),
StringParam(
name="comment",
label="Comments",
description="User comments describing this specific node instance.\n"
"It is displayed in regular font in the invalidation/comment messages tooltip.",
value="",
semantic="multiline",
invalidate=False,
),
IntParam(
name="fontSize",
label="Font Size",
description="The Font size for the User Comment on the Backdrop.",
value=12,
range=(6, 100, 1),
),
FloatParam(
name="nodeWidth",
label="Node Width",
description="The Backdrop Node's Width.",
value=600,
range=None,
enabled=False # Hidden always
),
FloatParam(
name="nodeHeight",
label="Node Height",
description="The Backdrop Node's Height.",
value=400,
range=None,
enabled=False # Hidden always
),
ColorParam(
name="color",
label="Color",
description="Custom color for the node (SVG name or hexadecimal code).",
value="",
invalidate=False,
)
]


class CommandLineNode(Node):
"""
Expand Down
13 changes: 13 additions & 0 deletions meshroom/ui/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -1033,6 +1033,19 @@ def selectNodesByIndices(
self._graph.nodes.index(index), self._graph.nodes.index(index)
)

# {{{ Backdrop Selection Logic
# Get the node corresponding to the index
node = self._graph.nodes[index]

if node.isBackdrop:
for node in self.getBackdropNodes(node):
index = self._graph.nodes.indexOf(node)

itemSelection.select(
self._graph.nodes.index(index), self._graph.nodes.index(index)
)
# }}}

self._nodeSelection.select(itemSelection, command)

if self.selectedNode and not self.isSelected(self.selectedNode):
Expand Down
6 changes: 4 additions & 2 deletions meshroom/ui/qml/GraphEditor/GraphEditor.qml
Original file line number Diff line number Diff line change
Expand Up @@ -912,7 +912,9 @@ Item {
onDoubleClicked: function(mouse) { root.nodeDoubleClicked(mouse, node) }

// Update the Node size
onResized: uigraph.resizeNode(node, width, height)
onResized: function(width, height) {
uigraph.resizeNode(node, width, height);
}

onEntered: uigraph.hoveredNode = node
onExited: uigraph.hoveredNode = null
Expand Down Expand Up @@ -963,7 +965,7 @@ Item {
}

Behavior on x {
enabled: !nodeRepeater.ongoingDrag
enabled: !nodeRepeater.ongoingDrag && !resizing
NumberAnimation { duration: 100 }
}
Behavior on y {
Expand Down
3 changes: 2 additions & 1 deletion meshroom/ui/qml/GraphEditor/Node.qml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ Item {
property bool mainSelected: false
property bool selected: false
property bool hovered: false
property bool dragging: mouseArea.drag.active || leftDragger.drag.active
property bool dragging: mouseArea.drag.active
property bool resizing: leftDragger.drag.active
/// Combined x and y
property point position: Qt.point(x, y)
/// Styling
Expand Down

0 comments on commit 0a4bf9f

Please sign in to comment.