mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-06-04 03:41:56 +02:00
[ui] GraphEditor: improve Edge UI
* increase EdgeMouseArea thickness for easier picking * EdgeMouseArea: propagate modifiers on pressed * increase edge visual thickness when hovered * add edge contextual menu on right click * Alt+RighClick shortcut to delete an edge
This commit is contained in:
parent
41ea5a5423
commit
53be806019
3 changed files with 26 additions and 4 deletions
|
@ -12,10 +12,12 @@ class MouseEvent(QObject):
|
||||||
self._x = evt.x()
|
self._x = evt.x()
|
||||||
self._y = evt.y()
|
self._y = evt.y()
|
||||||
self._button = evt.button()
|
self._button = evt.button()
|
||||||
|
self._modifiers = evt.modifiers()
|
||||||
|
|
||||||
x = Property(float, lambda self: self._x, constant=True)
|
x = Property(float, lambda self: self._x, constant=True)
|
||||||
y = Property(float, lambda self: self._y, constant=True)
|
y = Property(float, lambda self: self._y, constant=True)
|
||||||
button = Property(Qt.MouseButton, lambda self: self._button, constant=True)
|
button = Property(Qt.MouseButton, lambda self: self._button, constant=True)
|
||||||
|
modifiers = Property(int, lambda self: self._modifiers, constant=True)
|
||||||
|
|
||||||
|
|
||||||
class EdgeMouseArea(QQuickItem):
|
class EdgeMouseArea(QQuickItem):
|
||||||
|
|
|
@ -60,7 +60,7 @@ Shape {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
curveScale: cubic.curveScale
|
curveScale: cubic.curveScale
|
||||||
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||||
thickness: root.thickness + 2
|
thickness: root.thickness + 4
|
||||||
onPressed: root.pressed(arguments[0]) // can't get named args, use arguments array
|
onPressed: root.pressed(arguments[0]) // can't get named args, use arguments array
|
||||||
onReleased: root.released(arguments[0])
|
onReleased: root.released(arguments[0])
|
||||||
}
|
}
|
||||||
|
|
|
@ -182,6 +182,15 @@ Item {
|
||||||
width: 1000
|
width: 1000
|
||||||
height: 1000
|
height: 1000
|
||||||
|
|
||||||
|
Menu {
|
||||||
|
id: edgeMenu
|
||||||
|
property var currentEdge: null
|
||||||
|
MenuItem {
|
||||||
|
text: "Remove"
|
||||||
|
enabled: !root.readOnly
|
||||||
|
onTriggered: uigraph.removeEdge(edgeMenu.currentEdge)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Edges
|
// Edges
|
||||||
Repeater {
|
Repeater {
|
||||||
|
@ -196,16 +205,27 @@ Item {
|
||||||
property var srcAnchor: src.nodeItem.mapFromItem(src, src.edgeAnchorPos.x, src.edgeAnchorPos.y)
|
property var srcAnchor: src.nodeItem.mapFromItem(src, src.edgeAnchorPos.x, src.edgeAnchorPos.y)
|
||||||
property var dstAnchor: dst.nodeItem.mapFromItem(dst, dst.edgeAnchorPos.x, dst.edgeAnchorPos.y)
|
property var dstAnchor: dst.nodeItem.mapFromItem(dst, dst.edgeAnchorPos.x, dst.edgeAnchorPos.y)
|
||||||
|
|
||||||
|
property bool inFocus: containsMouse || (edgeMenu.opened && edgeMenu.currentEdge == edge)
|
||||||
|
|
||||||
edge: object
|
edge: object
|
||||||
color: containsMouse && !readOnly ? activePalette.highlight : activePalette.text
|
color: inFocus ? activePalette.highlight : activePalette.text
|
||||||
|
thickness: inFocus ? 2 : 1
|
||||||
opacity: 0.7
|
opacity: 0.7
|
||||||
point1x: src.nodeItem.x + srcAnchor.x
|
point1x: src.nodeItem.x + srcAnchor.x
|
||||||
point1y: src.nodeItem.y + srcAnchor.y
|
point1y: src.nodeItem.y + srcAnchor.y
|
||||||
point2x: dst.nodeItem.x + dstAnchor.x
|
point2x: dst.nodeItem.x + dstAnchor.x
|
||||||
point2y: dst.nodeItem.y + dstAnchor.y
|
point2y: dst.nodeItem.y + dstAnchor.y
|
||||||
onPressed: {
|
onPressed: {
|
||||||
if(!root.readOnly && event.button == Qt.RightButton)
|
if(event.button == Qt.RightButton)
|
||||||
uigraph.removeEdge(edge)
|
{
|
||||||
|
if(!root.readOnly && event.modifiers & Qt.AltModifier) {
|
||||||
|
uigraph.removeEdge(edge)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
edgeMenu.currentEdge = edge
|
||||||
|
edgeMenu.popup()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue