@@ -75,6 +75,7 @@ Qan.AbstractGraphView {
75
75
border .width : 2
76
76
border .color : ' violet'
77
77
transformOrigin: Qt .TopLeftCorner
78
+
78
79
z: 1 // Note: Do not remove, otherwise events are hidden !
79
80
Component .onCompleted : {
80
81
// Set initial content size
@@ -91,35 +92,43 @@ Qan.AbstractGraphView {
91
92
navigable.contentY = (2000 / 2) - (navigable.height / 2.)
92
93
*/
93
94
}
94
- }
95
-
96
- MouseArea {
97
- // hoverEnabled: true
98
- anchors .fill : parent
99
- onWheel : (wheel ) => {
100
- console .error (' HOPLA' )
101
- // FIXME #232 take wheel intensity into account...
102
- const P = mapToGlobal (wheel .x , wheel .y )
103
- const scaleIncrement = wheel .angleDelta .y > 0. ? 0.5
104
- : - 0.05 ;
105
- const preScale = graphContainerItem .scale
106
- graphContainerItem .scale += scaleIncrement
107
- const scale = graphContainerItem .scale
108
-
109
- console .error (` graphContainerItem.scale=${ graphContainerItem .scale } ` )
110
- const preContentX = navigable .contentX
111
- const preContentY = navigable .contentY
112
-
113
- console .error (` contentX=${ navigable .contentX } contentY=${ navigable .contentY } ` )
114
- navigable .contentWidth = graphContainerItem .width * graphContainerItem .scale ;
115
- navigable .contentHeight = graphContainerItem .height * graphContainerItem .scale ;
116
-
117
- const Pp = mapToGlobal (wheel .x , wheel .y )
118
- console .error (` P=${ P } Pp=${ Pp} PPp=${ Qt .point ((Pp .x - P .x ), (Pp .y - P .y ))} ` )
119
- navigable .contentX = preContentX + (Pp .x - P .x )
120
- navigable .contentY = preContentY + (Pp .y - P .y )
121
- }
122
- onClicked : (mouse ) => { console .error (' HOPLA' ); graphView .clicked (mouse) }
95
+ MouseArea {
96
+ // hoverEnabled: true
97
+ anchors .fill : parent
98
+ onWheel : (wheel ) => {
99
+ // FIXME #232 take wheel intensity into account...
100
+ console .error (` wheel.x=${ wheel .x } wheel.y=${ wheel .y } ` )
101
+ const P = mapToGlobal (wheel .x , wheel .y )
102
+ // const P = mapToItem(contentItem, wheel.x, wheel.y)
103
+ const scaleIncrement = wheel .angleDelta .y > 0. ? 0.25
104
+ : - 0.25 ;
105
+ const preScale = graphContainerItem .scale
106
+ graphContainerItem .scale += scaleIncrement
107
+ const scale = graphContainerItem .scale
108
+
109
+ // console.error(`graphContainerItem.scale=${graphContainerItem.scale}`)
110
+ const preContentX = navigable .contentX
111
+ const preContentY = navigable .contentY
112
+
113
+ // console.error(`contentX=${navigable.contentX} contentY=${navigable.contentY}`)
114
+ navigable .contentWidth = graphContainerItem .width * graphContainerItem .scale ;
115
+ navigable .contentHeight = graphContainerItem .height * graphContainerItem .scale ;
116
+
117
+ // const Pp = graphContainerItem.mapFromGlobal(wheel.x, wheel.y)
118
+ const Pp = mapToGlobal (wheel .x , wheel .y )
119
+ // const Pp = mapToItem(contentItem, wheel.x, wheel.y)
120
+
121
+ // const Pp = Qt.point(P.x * (1 + scaleIncrement), P.y * (1. + scaleIncrement));
122
+ console .error (` P=${ P } Pp=${ Pp} PPp=${ Qt .point ((Pp .x - P .x ), (Pp .y - P .y ))} ` )
123
+ navigable .contentX = preContentX + (Pp .x - P .x )
124
+ navigable .contentY = preContentY + (Pp .y - P .y )
125
+ // navigable.contentX *= graphContainerItem.scale
126
+ // navigable.contentY *= graphContainerItem.scale
127
+ navigable .returnToBounds ();
128
+ }
129
+
130
+ onClicked : (mouse ) => { graphView .clicked (mouse) }
131
+ }
123
132
}
124
133
}
125
134
onRequestDisableNavigable: navigable .interactive = false
0 commit comments