Changeset View
Changeset View
Standalone View
Standalone View
src/QuickEditor/SelectionRectangle.qml
Context not available. | |||||
25 | 25 | | |||
---|---|---|---|---|---|
26 | property var drawCanvas: null; | 26 | property var drawCanvas: null; | ||
27 | property var imageElement: null; | 27 | property var imageElement: null; | ||
28 | property var zx: -1; | ||||
29 | property var zy: -1; | ||||
28 | 30 | | |||
29 | signal doubleClicked(); | 31 | signal doubleClicked(); | ||
ngraham: `int`s please. | |||||
guotao: In HiDPI mode, It's not int | |||||
alexeymin: maybe `double` then? | |||||
Yup, see https://doc.qt.io/qt-5/qml-real.html for what is allowed. Using double seems to work for me in HiDPI mode (as opposed to int). rkflx: Yup, see https://doc.qt.io/qt-5/qml-real.html for what is allowed.
Using `double` seems to… | |||||
I don't really understand why those properties are called zx and zy. Could you come up with a more descriptive name? If not, at least add a comment here describing their purpose. rkflx: I don't really understand why those properties are called `zx` and `zy`. Could you come up with… | |||||
rkflx: Thank you, much better ;) | |||||
30 | 32 | | |||
Context not available. | |||||
75 | onPressed: { | 77 | onPressed: { | ||
76 | brxLimit = (parent.x + parent.width) - 20; | 78 | brxLimit = (parent.x + parent.width) - 20; | ||
77 | bryLimit = (parent.y + parent.height) - 20; | 79 | bryLimit = (parent.y + parent.height) - 20; | ||
80 | parent.zx = parent.x; | ||||
81 | parent.zy = parent.y; | ||||
78 | } | 82 | } | ||
79 | 83 | | |||
80 | onPositionChanged: { | 84 | onPositionChanged: { | ||
81 | if ((parent.x + mouse.x) < brxLimit) { | 85 | if ((parent.x + mouse.x) < brxLimit) { | ||
82 | parent.width = parent.width - mouse.x; | 86 | parent.width = parent.width - mouse.x; | ||
83 | parent.x = parent.x + mouse.x; | 87 | parent.x = parent.x + mouse.x; | ||
88 | parent.zx = parent.zx + mouse.x; | ||||
84 | } | 89 | } | ||
85 | 90 | | |||
86 | if ((parent.y + mouse.y) < bryLimit) { | 91 | if ((parent.y + mouse.y) < bryLimit) { | ||
87 | parent.height = parent.height - mouse.y; | 92 | parent.height = parent.height - mouse.y; | ||
88 | parent.y = parent.y + mouse.y; | 93 | parent.y = parent.y + mouse.y; | ||
94 | parent.zy = parent.zy + mouse.y; | ||||
89 | } | 95 | } | ||
96 | drawCanvas.requestPaint(); | ||||
97 | } | ||||
90 | 98 | | |||
99 | onReleased: { | ||||
100 | parent.zx = -1; | ||||
101 | parent.zy = -1; | ||||
91 | drawCanvas.requestPaint(); | 102 | drawCanvas.requestPaint(); | ||
92 | } | 103 | } | ||
93 | } | 104 | } | ||
Context not available. | |||||
108 | onPressed: { | 119 | onPressed: { | ||
109 | brxLimit = parent.x + 40; | 120 | brxLimit = parent.x + 40; | ||
110 | bryLimit = (parent.y + parent.height) - 20; | 121 | bryLimit = (parent.y + parent.height) - 20; | ||
122 | parent.zx = parent.x + parent.width; | ||||
123 | parent.zy = parent.y; | ||||
111 | } | 124 | } | ||
112 | 125 | | |||
113 | onPositionChanged: { | 126 | onPositionChanged: { | ||
114 | if ((parent.x + parent.width + mouse.x) > brxLimit) { | 127 | if ((parent.x + parent.width + mouse.x) > brxLimit) { | ||
115 | parent.width = parent.width + mouse.x - 20; | 128 | parent.width = parent.width + mouse.x - 20; | ||
129 | parent.zx = parent.zx + mouse.x - 20; | ||||
116 | } | 130 | } | ||
117 | 131 | | |||
118 | if ((parent.y + mouse.y) < bryLimit) { | 132 | if ((parent.y + mouse.y) < bryLimit) { | ||
119 | parent.height = parent.height - mouse.y; | 133 | parent.height = parent.height - mouse.y; | ||
120 | parent.y = parent.y + mouse.y; | 134 | parent.y = parent.y + mouse.y; | ||
135 | parent.zy = parent.zy + mouse.y; | ||||
121 | } | 136 | } | ||
137 | drawCanvas.requestPaint(); | ||||
138 | } | ||||
122 | 139 | | |||
140 | onReleased: { | ||||
141 | parent.zx = -1; | ||||
142 | parent.zy = -1; | ||||
123 | drawCanvas.requestPaint(); | 143 | drawCanvas.requestPaint(); | ||
124 | } | 144 | } | ||
125 | } | 145 | } | ||
Context not available. | |||||
140 | onPressed: { | 160 | onPressed: { | ||
141 | brxLimit = (parent.x + parent.width) - 20; | 161 | brxLimit = (parent.x + parent.width) - 20; | ||
142 | bryLimit = parent.y + 40; | 162 | bryLimit = parent.y + 40; | ||
163 | parent.zx = parent.x; | ||||
164 | parent.zy = parent.y + parent.height; | ||||
143 | } | 165 | } | ||
144 | 166 | | |||
145 | onPositionChanged: { | 167 | onPositionChanged: { | ||
146 | if ((parent.x + mouse.x) < brxLimit) { | 168 | if ((parent.x + mouse.x) < brxLimit) { | ||
147 | parent.width = parent.width - mouse.x; | 169 | parent.width = parent.width - mouse.x; | ||
148 | parent.x = parent.x + mouse.x; | 170 | parent.x = parent.x + mouse.x; | ||
171 | parent.zx = parent.zx + mouse.x; | ||||
149 | } | 172 | } | ||
150 | 173 | | |||
151 | if ((parent.y + parent.height + mouse.y) > bryLimit) { | 174 | if ((parent.y + parent.height + mouse.y) > bryLimit) { | ||
152 | parent.height = parent.height + mouse.y - 20; | 175 | parent.height = parent.height + mouse.y - 20; | ||
176 | parent.zy = parent.zy + mouse.y - 20; | ||||
153 | } | 177 | } | ||
178 | drawCanvas.requestPaint(); | ||||
179 | } | ||||
154 | 180 | | |||
181 | onReleased: { | ||||
182 | parent.zx = -1; | ||||
183 | parent.zy = -1; | ||||
155 | drawCanvas.requestPaint(); | 184 | drawCanvas.requestPaint(); | ||
156 | } | 185 | } | ||
157 | } | 186 | } | ||
Context not available. | |||||
172 | onPressed: { | 201 | onPressed: { | ||
173 | brxLimit = parent.x + 40; | 202 | brxLimit = parent.x + 40; | ||
174 | bryLimit = parent.y + 40; | 203 | bryLimit = parent.y + 40; | ||
204 | parent.zx = parent.x + parent.width; | ||||
205 | parent.zy = parent.y + parent.height; | ||||
175 | } | 206 | } | ||
176 | 207 | | |||
177 | onPositionChanged: { | 208 | onPositionChanged: { | ||
178 | if ((parent.x + parent.width + mouse.x) > brxLimit) { | 209 | if ((parent.x + parent.width + mouse.x) > brxLimit) { | ||
179 | parent.width = parent.width + mouse.x - 20; | 210 | parent.width = parent.width + mouse.x - 20; | ||
211 | parent.zx = parent.zx + mouse.x - 20; | ||||
180 | } | 212 | } | ||
181 | 213 | | |||
182 | if ((parent.y + parent.height + mouse.y) > bryLimit) { | 214 | if ((parent.y + parent.height + mouse.y) > bryLimit) { | ||
183 | parent.height = parent.height + mouse.y - 20; | 215 | parent.height = parent.height + mouse.y - 20; | ||
216 | parent.zy = parent.zy + mouse.y - 20; | ||||
184 | } | 217 | } | ||
218 | drawCanvas.requestPaint(); | ||||
219 | } | ||||
185 | 220 | | |||
221 | onReleased: { | ||||
222 | parent.zx = -1; | ||||
223 | parent.zy = -1; | ||||
186 | drawCanvas.requestPaint(); | 224 | drawCanvas.requestPaint(); | ||
187 | } | 225 | } | ||
188 | } | 226 | } | ||
Context not available. | |||||
201 | 239 | | |||
202 | onPressed: { | 240 | onPressed: { | ||
203 | limit = (parent.y + parent.height) - 20; | 241 | limit = (parent.y + parent.height) - 20; | ||
242 | parent.zx = parent.x + parent.width / 2 - 10; | ||||
243 | parent.zy = parent.y; | ||||
204 | } | 244 | } | ||
205 | 245 | | |||
206 | onPositionChanged: { | 246 | onPositionChanged: { | ||
207 | if ((parent.y + mouse.y) < limit) { | 247 | if ((parent.y + mouse.y) < limit) { | ||
208 | parent.height = parent.height - mouse.y; | 248 | parent.height = parent.height - mouse.y; | ||
209 | parent.y = parent.y + mouse.y; | 249 | parent.y = parent.y + mouse.y; | ||
250 | parent.zy = parent.zy + mouse.y; | ||||
210 | } | 251 | } | ||
252 | parent.zx = parent.x + parent.width / 2 - 10 + mouse.x; | ||||
253 | drawCanvas.requestPaint(); | ||||
254 | } | ||||
211 | 255 | | |||
256 | onReleased: { | ||||
257 | parent.zx = -1; | ||||
258 | parent.zy = -1; | ||||
212 | drawCanvas.requestPaint(); | 259 | drawCanvas.requestPaint(); | ||
213 | } | 260 | } | ||
214 | } | 261 | } | ||
Context not available. | |||||
227 | 274 | | |||
228 | onPressed: { | 275 | onPressed: { | ||
229 | limit = parent.y + 40; | 276 | limit = parent.y + 40; | ||
277 | parent.zx = parent.x + parent.width / 2 - 10; | ||||
278 | parent.zy = parent.y + parent.height; | ||||
230 | } | 279 | } | ||
231 | 280 | | |||
232 | onPositionChanged: { | 281 | onPositionChanged: { | ||
233 | if ((parent.y + parent.height + mouse.y) > limit) { | 282 | if ((parent.y + parent.height + mouse.y) > limit) { | ||
234 | parent.height = parent.height + mouse.y - 20; | 283 | parent.height = parent.height + mouse.y - 20; | ||
284 | parent.zy = parent.zy + mouse.y - 20; | ||||
235 | } | 285 | } | ||
286 | parent.zx = parent.x + parent.width / 2 - 10 + mouse.x; | ||||
287 | drawCanvas.requestPaint(); | ||||
288 | } | ||||
236 | 289 | | |||
290 | onReleased: { | ||||
291 | parent.zx = -1; | ||||
292 | parent.zy = -1; | ||||
237 | drawCanvas.requestPaint(); | 293 | drawCanvas.requestPaint(); | ||
238 | } | 294 | } | ||
239 | } | 295 | } | ||
Context not available. | |||||
252 | 308 | | |||
253 | onPressed: { | 309 | onPressed: { | ||
254 | limit = (parent.x + parent.width) - 20; | 310 | limit = (parent.x + parent.width) - 20; | ||
311 | parent.zx = parent.x; | ||||
312 | parent.zy = parent.y + parent.height / 2 - 10; | ||||
255 | } | 313 | } | ||
256 | 314 | | |||
257 | onPositionChanged: { | 315 | onPositionChanged: { | ||
258 | if ((parent.x + mouse.x) < limit) { | 316 | if ((parent.x + mouse.x) < limit) { | ||
259 | parent.width = parent.width - mouse.x; | 317 | parent.width = parent.width - mouse.x; | ||
260 | parent.x = parent.x + mouse.x; | 318 | parent.x = parent.x + mouse.x; | ||
319 | parent.zx = parent.zx + mouse.x; | ||||
261 | } | 320 | } | ||
321 | parent.zy = parent.y + parent.height / 2 - 10 + mouse.y; | ||||
322 | drawCanvas.requestPaint(); | ||||
323 | } | ||||
262 | 324 | | |||
325 | onReleased: { | ||||
326 | parent.zx = -1; | ||||
327 | parent.zy = -1; | ||||
263 | drawCanvas.requestPaint(); | 328 | drawCanvas.requestPaint(); | ||
264 | } | 329 | } | ||
265 | } | 330 | } | ||
Context not available. | |||||
278 | 343 | | |||
279 | onPressed: { | 344 | onPressed: { | ||
280 | limit = parent.x + 40; | 345 | limit = parent.x + 40; | ||
346 | parent.zx = parent.x + parent.width; | ||||
347 | parent.zy = parent.y + parent.height / 2 - 10; | ||||
281 | } | 348 | } | ||
282 | 349 | | |||
283 | onPositionChanged: { | 350 | onPositionChanged: { | ||
284 | if ((parent.x + parent.width + mouse.x) > limit) { | 351 | if ((parent.x + parent.width + mouse.x) > limit) { | ||
285 | parent.width = parent.width + mouse.x - 20; | 352 | parent.width = parent.width + mouse.x - 20; | ||
353 | parent.zx = parent.zx + mouse.x - 20; | ||||
286 | } | 354 | } | ||
355 | parent.zy = parent.y + parent.height / 2 - 10 + mouse.y; | ||||
356 | drawCanvas.requestPaint(); | ||||
357 | } | ||||
287 | 358 | | |||
359 | onReleased: { | ||||
360 | parent.zx = -1; | ||||
361 | parent.zy = -1; | ||||
288 | drawCanvas.requestPaint(); | 362 | drawCanvas.requestPaint(); | ||
289 | } | 363 | } | ||
290 | } | 364 | } | ||
Context not available. |
ints please.