@@ -62,68 +62,62 @@ Qan.AbstractGraphView {
62
62
Flickable {
63
63
id: navigable
64
64
anchors .fill : parent
65
- clip: true
65
+ clip: false
66
66
ScrollBar .vertical : ScrollBar { }
67
67
ScrollBar .horizontal : ScrollBar { }
68
68
// Note: keep pressDelay to 0 otherwise it broke event dispatching
69
69
boundsMovement: Flickable .DragAndOvershootBounds
70
70
71
71
Rectangle {
72
- id: graphContainerItem
73
- width: 3000
74
- height: 2000
72
+ id: graphContainer
73
+ width: graphView . graphBr . width
74
+ height: graphView . graphBr . height
75
75
border .width : 2
76
76
border .color : ' violet'
77
77
transformOrigin: Qt .TopLeftCorner
78
-
79
78
z: 1 // Note: Do not remove, otherwise events are hidden !
80
79
Component .onCompleted : {
81
- // Set initial content size
82
- // navigable.resizeContent(3000, 2000, null)
83
- // FIXME: Laisser comme cela, mais il faudra un code d'initialisation "dédié" pour
84
- // faire le centrage initial de la vue:
85
- // avec un flag sur onSizeChanged() pas le choix, ici la taille est à 0...
86
- navigable .contentWidth = 3000
87
- navigable .contentHeight = 2000
88
- /* console.error('navigable.width=' + navigable.width)
89
- console.error('navigable.contentItem.width=' + navigable.contentItem.width)
90
- // Resize view to center
91
- navigable.contentX = (3000 / 2) - (navigable.width / 2.) // FIXME simplify expression /2
92
- navigable.contentY = (2000 / 2) - (navigable.height / 2.)
93
- */
80
+ // updateGraphBr(Qt.rect(0., 0., 3000, 2000))
81
+ }
82
+ function updateGraphBr (graphBr ) {
83
+ console .error (' updateGraphBr(): graphBr=' + graphBr)
84
+ if (! graphBr)
85
+ return ;
86
+ // const contentBr = graphContainer.childrenRect
87
+ navigable .contentWidth = graphBr .width * graphContainer .scale ;
88
+ navigable .contentHeight = graphBr .height * graphContainer .scale ;
89
+ graphContainer .x = (- graphBr .x * graphContainer .scale );
90
+ graphContainer .y = (- graphBr .y * graphContainer .scale );
94
91
}
92
+
95
93
MouseArea {
96
94
// hoverEnabled: true
97
95
anchors .fill : parent
98
96
onWheel : (wheel ) => {
99
97
// FIXME #232 take wheel intensity into account...
100
98
console .error (` wheel.x=${ wheel .x } wheel.y=${ wheel .y } ` )
101
99
const P = mapToGlobal (wheel .x , wheel .y )
102
- // const P = mapToItem(contentItem, wheel.x, wheel.y)
103
100
const scaleIncrement = wheel .angleDelta .y > 0. ? 0.25
104
101
: - 0.25 ;
105
- const preScale = graphContainerItem .scale
106
- graphContainerItem .scale += scaleIncrement
107
- const scale = graphContainerItem .scale
102
+ const preScale = graphContainer .scale
103
+ graphContainer .scale += scaleIncrement
104
+ const scale = graphContainer .scale
108
105
109
- // console.error(`graphContainerItem .scale=${graphContainerItem .scale}`)
106
+ // console.error(`graphContainer .scale=${graphContainer .scale}`)
110
107
const preContentX = navigable .contentX
111
108
const preContentY = navigable .contentY
112
109
113
110
// console.error(`contentX=${navigable.contentX} contentY=${navigable.contentY}`)
114
- navigable .contentWidth = graphContainerItem .width * graphContainerItem .scale ;
115
- navigable .contentHeight = graphContainerItem .height * graphContainerItem .scale ;
111
+ // const graphContainerBr = graphContainer.childrenRect
112
+ navigable .contentWidth = graphView .graphBr .width * graphContainer .scale ;
113
+ navigable .contentHeight = graphView .graphBr .height * graphContainer .scale ;
114
+ // graphContainer.x = (-graphContainerBr.x * graphContainer.scale);
115
+ // graphContainer.y = (-graphContainerBr.y * graphContainer.scale);
116
116
117
- // const Pp = graphContainerItem.mapFromGlobal(wheel.x, wheel.y)
118
117
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
118
console .error (` P=${ P } Pp=${ Pp} PPp=${ Qt .point ((Pp .x - P .x ), (Pp .y - P .y ))} ` )
123
119
navigable .contentX = preContentX + (Pp .x - P .x )
124
120
navigable .contentY = preContentY + (Pp .y - P .y )
125
- // navigable.contentX *= graphContainerItem.scale
126
- // navigable.contentY *= graphContainerItem.scale
127
121
navigable .returnToBounds ();
128
122
}
129
123
@@ -133,8 +127,8 @@ Qan.AbstractGraphView {
133
127
}
134
128
onRequestDisableNavigable: navigable .interactive = false
135
129
onRequestEnableNavigable: navigable .interactive = true
136
-
137
- containerItem: graphContainerItem
130
+ onRequestUpdateGraphBr : ( graphBr ) => { graphContainer . updateGraphBr (graphBr) }
131
+ containerItem: graphContainer
138
132
Qan .LineGrid {
139
133
id: lineGrid
140
134
}
0 commit comments