Skip to content

Commit 8d2fe99

Browse files
committed
GraphEditor: Add scroll direction border indicator
1 parent f0bedeb commit 8d2fe99

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

meshroom/ui/qml/GraphEditor/GraphEditor.qml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import QtQuick
22
import QtQuick.Controls
33
import QtQuick.Layouts
4+
import Qt5Compat.GraphicalEffects
45

56
import Controls 1.0
67
import MaterialIcons 2.2
@@ -25,6 +26,14 @@ Item {
2526
property bool isDraggingEdge: false // Tracks whether we are dragging an AttributePin
2627
property point dragMousePos: Qt.point(0, 0) // Position of the mouse during edge dragging
2728

29+
readonly property real borderHighlightOpacity: 0.05
30+
readonly property color borderHighlightColor: Colors.blue
31+
readonly property real borderHighlightWidth: 4
32+
property bool highlightedBorderLeft: false
33+
property bool highlightedBorderRight: false
34+
property bool highlightedBorderTop: false
35+
property bool highlightedBorderBottom: false
36+
2837
property var edgeAboutToBeRemoved: undefined
2938

3039
property var _attributeToDelegate: ({})
@@ -213,15 +222,47 @@ Item {
213222
deltaY = -root.autoscrollSpeed * Math.pow(factorY, 2)
214223
}
215224

225+
root.highlightedBorderRight=false
226+
root.highlightedBorderLeft=false
227+
root.highlightedBorderTop=false
228+
root.highlightedBorderBottom=false
229+
216230
// Apply scroll on workspaxe
217231
if (deltaX !== 0 || deltaY !== 0) {
218232
draggable.x += deltaX
219233
draggable.y += deltaY
220234
workspaceMoved()
235+
236+
if (deltaX>0) { root.highlightedBorderLeft=true }
237+
else if (deltaX<0) { root.highlightedBorderRight=true }
238+
if (deltaY>0) { root.highlightedBorderTop=true }
239+
else if (deltaY<0) { root.highlightedBorderBottom=true }
221240
}
222241
}
223242
}
224243

244+
// Display scroll direction
245+
Rectangle {
246+
enabled: root.isDraggingEdge
247+
color: "transparent"
248+
border.color: root.borderHighlightColor
249+
border.width: root.borderHighlightWidth
250+
251+
// Combine fill and margins into one anchor block
252+
anchors {
253+
fill: parent
254+
leftMargin: root.highlightedBorderLeft ? 0 : -root.borderHighlightWidth
255+
rightMargin: root.highlightedBorderRight ? 0 : -root.borderHighlightWidth
256+
topMargin: root.highlightedBorderTop ? 0 : -root.borderHighlightWidth
257+
bottomMargin: root.highlightedBorderBottom ? 0 : -root.borderHighlightWidth
258+
}
259+
260+
Behavior on anchors.leftMargin { NumberAnimation { duration: 200; easing.type: Easing.OutQuad } }
261+
Behavior on anchors.rightMargin { NumberAnimation { duration: 200; easing.type: Easing.OutQuad } }
262+
Behavior on anchors.topMargin { NumberAnimation { duration: 200; easing.type: Easing.OutQuad } }
263+
Behavior on anchors.bottomMargin { NumberAnimation { duration: 200; easing.type: Easing.OutQuad } }
264+
}
265+
225266
MouseArea {
226267
id: mouseArea
227268
anchors.fill: parent

0 commit comments

Comments
 (0)