author | Claus Gittinger <cg@exept.de> |
Wed, 27 Sep 2000 16:23:30 +0200 | |
changeset 2284 | a0fe280353ba |
parent 2260 | ce3be65862db |
child 2396 | 8340b529e8ce |
permissions | -rw-r--r-- |
104 | 1 |
" |
2 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
2179 | 3 |
All Rights Reserved |
104 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
2179 | 13 |
|
2223 | 14 |
"{ Package: 'stx:libwidg' }" |
2179 | 15 |
|
104 | 16 |
Controller subclass:#VariablePanelController |
2179 | 17 |
instanceVariableNames:'movedHandle prevPos clickPos saveCursor startResizing resizeMode' |
2005
9b1ff373a8ad
moved opaqueResize setting to userPreferences
Claus Gittinger <cg@exept.de>
parents:
1871
diff
changeset
|
18 |
classVariableNames:'' |
582 | 19 |
poolDictionaries:'' |
20 |
category:'Interface-Support-Controllers' |
|
104 | 21 |
! |
22 |
||
23 |
!VariablePanelController class methodsFor:'documentation'! |
|
24 |
||
25 |
copyright |
|
26 |
" |
|
27 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
2179 | 28 |
All Rights Reserved |
104 | 29 |
|
30 |
This software is furnished under a license and may be used |
|
31 |
only in accordance with the terms of that license and with the |
|
32 |
inclusion of the above copyright notice. This software may not |
|
33 |
be provided or otherwise made available to, or used by, any |
|
34 |
other person. No title to or ownership of the software is |
|
35 |
hereby transferred. |
|
36 |
" |
|
2179 | 37 |
|
104 | 38 |
! |
39 |
||
150 | 40 |
documentation |
41 |
" |
|
42 |
An abstract class for variablePanel controllers; |
|
43 |
normally, not used directly by applications, these are created automatically |
|
44 |
whenever a variablePanel is created. |
|
45 |
Instances are responsible for tracking the mouse pointer and resize the |
|
46 |
views (a panel) subviews as appropriate. |
|
582 | 47 |
|
48 |
[author:] |
|
49 |
Claus Gittinger |
|
150 | 50 |
" |
1722 | 51 |
|
1720 | 52 |
|
53 |
! ! |
|
54 |
||
104 | 55 |
!VariablePanelController methodsFor:'event handling'! |
56 |
||
161 | 57 |
buttonMotion:state x:bx y:by |
104 | 58 |
"mouse-button was moved while pressed; |
2179 | 59 |
clear prev handleBar and draw handle bar at new position |
60 |
" |
|
61 |
|nextPos layout entered hindex opaqueResizing| |
|
62 |
||
63 |
state == 0 ifTrue:[ |
|
64 |
view snapMode isNil ifTrue:[^ self]. |
|
104 | 65 |
|
2179 | 66 |
hindex := self detectHandleIndexAt:bx y:by. |
104 | 67 |
|
2179 | 68 |
hindex ~~ movedHandle ifTrue:[ |
69 |
self pointerLeave:0. |
|
70 |
movedHandle := hindex. |
|
71 |
]. |
|
72 |
movedHandle isNil ifTrue:[^ self]. |
|
104 | 73 |
|
2179 | 74 |
"check entering click button ...." |
75 |
layout := view snapLayoutAt:movedHandle. |
|
76 |
entered := layout notNil and:[layout containsPointX:bx y:by]. |
|
104 | 77 |
|
2179 | 78 |
entered ~~ (saveCursor notNil) ifTrue:[ |
79 |
entered ifTrue:[ |
|
80 |
saveCursor := view cursor. |
|
2239 | 81 |
view cursor:(Cursor hand). |
2179 | 82 |
] ifFalse:[ |
83 |
view cursor:saveCursor. |
|
84 |
saveCursor := nil. |
|
85 |
]. |
|
86 |
view drawSnapAt:movedHandle |
|
87 |
]. |
|
88 |
^ self |
|
89 |
]. |
|
90 |
(movedHandle isNil or:[resizeMode isNil]) ifTrue:[^ self]. |
|
1215
0d9e67bdfbe4
check for any change before moving handle (tiny optimization)
Claus Gittinger <cg@exept.de>
parents:
872
diff
changeset
|
91 |
|
2179 | 92 |
"RESIZING" |
93 |
||
94 |
"compute new position ...." |
|
95 |
||
96 |
nextPos := self checkedHandleMovementX:bx y:by. |
|
2252 | 97 |
"/ nextPos = prevPos ifTrue:[ |
98 |
"/ ^ self |
|
99 |
"/ ]. |
|
100 |
||
2179 | 101 |
opaqueResizing := UserPreferences current opaqueVariablePanelResizing == true. |
102 |
||
103 |
resizeMode == #active ifTrue:[ |
|
104 |
"check position changed ..." |
|
2252 | 105 |
"/ nextPos > 10 ifTrue:[ |
106 |
"/ (prevPos - nextPos) abs < 2 ifTrue:[^ self]. |
|
107 |
"/ ]. |
|
2179 | 108 |
opaqueResizing ifFalse:[ |
109 |
self doInvertHandle "undo the last invert" |
|
110 |
] |
|
111 |
] ifFalse:[ |
|
2252 | 112 |
"/ nextPos > 10 ifTrue:[ |
113 |
"/ (clickPos - nextPos) abs < 5 ifTrue:[^ self]. |
|
114 |
"/ ]. |
|
2179 | 115 |
resizeMode := #active. |
131 | 116 |
|
2179 | 117 |
"/ restore the snap cursor |
118 |
saveCursor notNil ifTrue:[ |
|
119 |
view grabPointerWithCursor:saveCursor. |
|
120 |
saveCursor := nil. |
|
121 |
view drawSnapAt:movedHandle. |
|
122 |
] |
|
123 |
]. |
|
124 |
prevPos := nextPos. |
|
1720 | 125 |
|
2179 | 126 |
opaqueResizing ifFalse:[ |
127 |
self doInvertHandle. |
|
128 |
] ifTrue:[ |
|
129 |
self doResize. |
|
130 |
]. |
|
104 | 131 |
! |
132 |
||
200 | 133 |
buttonPress:button x:bx y:by |
2179 | 134 |
"button was pressed - setup resizing if a handle is hit |
135 |
" |
|
2236 | 136 |
|handleView hindex isMin isMax layout| |
200 | 137 |
|
2179 | 138 |
((button == 1) or:[button == #select]) ifFalse:[ |
2284
a0fe280353ba
ignore other button-presses/releases while moving the bar
Claus Gittinger <cg@exept.de>
parents:
2260
diff
changeset
|
139 |
movedHandle isNil ifTrue:[ |
a0fe280353ba
ignore other button-presses/releases while moving the bar
Claus Gittinger <cg@exept.de>
parents:
2260
diff
changeset
|
140 |
self pointerLeave:0. |
a0fe280353ba
ignore other button-presses/releases while moving the bar
Claus Gittinger <cg@exept.de>
parents:
2260
diff
changeset
|
141 |
super buttonPress:button x:bx y:by. |
a0fe280353ba
ignore other button-presses/releases while moving the bar
Claus Gittinger <cg@exept.de>
parents:
2260
diff
changeset
|
142 |
]. |
a0fe280353ba
ignore other button-presses/releases while moving the bar
Claus Gittinger <cg@exept.de>
parents:
2260
diff
changeset
|
143 |
^ self. |
2179 | 144 |
]. |
145 |
hindex := self detectHandleIndexAt:bx y:by. |
|
1626
3013631d4384
do nothing if pointer was never moved;
Claus Gittinger <cg@exept.de>
parents:
1483
diff
changeset
|
146 |
|
2179 | 147 |
movedHandle notNil ifTrue:[ |
148 |
hindex ~~ movedHandle ifTrue:[self pointerLeave:0]. "restore the cursor" |
|
149 |
]. |
|
200 | 150 |
|
2179 | 151 |
( (movedHandle := hindex) notNil |
152 |
and:[(view canChangeExtentOfViewAt:movedHandle)] |
|
153 |
) ifFalse:[ |
|
154 |
^ self |
|
155 |
]. |
|
2236 | 156 |
|
2179 | 157 |
view grabPointerWithCursor:(view cursor). |
158 |
handleView := view subViews at:movedHandle. |
|
159 |
||
160 |
"setup resizeing" |
|
161 |
resizeMode := #init. |
|
2159
2864c0de7f33
make certain, that handles can always be clicked on;
Claus Gittinger <cg@exept.de>
parents:
2005
diff
changeset
|
162 |
|
2179 | 163 |
view orientation ~~ #vertical ifTrue:[ |
164 |
clickPos := bx. |
|
165 |
prevPos := handleView right. |
|
166 |
] ifFalse:[ |
|
167 |
clickPos := by. |
|
168 |
prevPos := handleView bottom. |
|
169 |
]. |
|
170 |
prevPos := prevPos + (view barHeight + 1 // 2). |
|
2159
2864c0de7f33
make certain, that handles can always be clicked on;
Claus Gittinger <cg@exept.de>
parents:
2005
diff
changeset
|
171 |
|
2179 | 172 |
saveCursor notNil ifTrue:[ |
173 |
"there is a snap under the cursor; redraw selected" |
|
2236 | 174 |
view snapMode == #both ifTrue:[ |
175 |
layout := view snapLayoutAt:movedHandle. |
|
176 |
view orientation == #vertical ifTrue:[ |
|
177 |
isMax := bx > (layout right - (layout width//3)). |
|
178 |
isMin := bx < (layout left + (layout width//3)). |
|
179 |
] ifFalse:[ |
|
180 |
isMax := by > (layout bottom - (layout height//3)). |
|
181 |
isMin := by < (layout top + (layout height//3)). |
|
182 |
]. |
|
183 |
handleView objectAttributeAt:#snapPart put:(isMin ifTrue:[#left] ifFalse:[ isMax ifTrue:[#right] ifFalse:[#middle]]). |
|
184 |
]. |
|
2179 | 185 |
view drawSnapAt:movedHandle |
200 | 186 |
] |
187 |
! |
|
188 |
||
1626
3013631d4384
do nothing if pointer was never moved;
Claus Gittinger <cg@exept.de>
parents:
1483
diff
changeset
|
189 |
buttonRelease:button x:bx y:by |
104 | 190 |
"end bar-move" |
191 |
||
2179 | 192 |
|subViews layout aboveView| |
1871 | 193 |
|
2179 | 194 |
((button == 1) or:[button == #select]) ifFalse:[ |
2284
a0fe280353ba
ignore other button-presses/releases while moving the bar
Claus Gittinger <cg@exept.de>
parents:
2260
diff
changeset
|
195 |
movedHandle isNil ifTrue:[ |
a0fe280353ba
ignore other button-presses/releases while moving the bar
Claus Gittinger <cg@exept.de>
parents:
2260
diff
changeset
|
196 |
resizeMode := nil. |
a0fe280353ba
ignore other button-presses/releases while moving the bar
Claus Gittinger <cg@exept.de>
parents:
2260
diff
changeset
|
197 |
super buttonRelease:button x:bx y:by |
a0fe280353ba
ignore other button-presses/releases while moving the bar
Claus Gittinger <cg@exept.de>
parents:
2260
diff
changeset
|
198 |
]. |
a0fe280353ba
ignore other button-presses/releases while moving the bar
Claus Gittinger <cg@exept.de>
parents:
2260
diff
changeset
|
199 |
^ self. |
2179 | 200 |
]. |
201 |
||
202 |
view ungrabPointer. |
|
203 |
movedHandle isNil ifTrue:[^ self]. |
|
1871 | 204 |
|
2179 | 205 |
resizeMode notNil ifTrue:[ |
206 |
resizeMode == #active ifTrue:[ |
|
2236 | 207 |
(view snapMode == #both) ifFalse:[ |
208 |
aboveView := view subViews at:movedHandle. |
|
209 |
aboveView objectAttributeAt:#vpext put:(aboveView relativeCorner). |
|
210 |
]. |
|
2252 | 211 |
(UserPreferences current opaqueVariablePanelResizing == true) ifFalse:[ |
212 |
self doResize |
|
213 |
]. |
|
2179 | 214 |
] ifFalse:[ |
215 |
( (layout := view snapLayoutAt:movedHandle) notNil |
|
216 |
and:[layout containsPointX:bx y:by] |
|
217 |
) ifTrue:[ |
|
2236 | 218 |
self doSnapPressedX:bx y:by |
2179 | 219 |
]. |
1871 | 220 |
]. |
2179 | 221 |
]. |
222 |
self pointerLeave:0. |
|
223 |
self pointerEnter:0 x:bx y:by. "check whether mouse on a handle" |
|
1871 | 224 |
! |
225 |
||
2179 | 226 |
pointerEnter:state x:bx y:by |
227 |
||
228 |
state == 0 ifTrue:[ |
|
229 |
view snapMode notNil ifTrue:[ |
|
230 |
(movedHandle := self detectHandleIndexAt:bx y:by) notNil ifTrue:[ |
|
231 |
self buttonMotion:state x:bx y:by |
|
232 |
] |
|
233 |
] |
|
234 |
] |
|
235 |
! |
|
236 |
||
237 |
pointerLeave:state |
|
238 |
||
239 |
saveCursor notNil ifTrue:[ |
|
240 |
"restore the cursor" |
|
241 |
view cursor:saveCursor. |
|
242 |
saveCursor := nil |
|
243 |
]. |
|
244 |
||
245 |
state == 0 ifTrue:[ |
|
246 |
resizeMode := nil. |
|
247 |
||
248 |
movedHandle notNil ifTrue:[ |
|
249 |
view drawSnapAt:movedHandle. |
|
250 |
movedHandle := nil. |
|
251 |
] |
|
252 |
]. |
|
253 |
||
254 |
! ! |
|
255 |
||
256 |
!VariablePanelController methodsFor:'private'! |
|
257 |
||
2159
2864c0de7f33
make certain, that handles can always be clicked on;
Claus Gittinger <cg@exept.de>
parents:
2005
diff
changeset
|
258 |
checkedHandleMovementX:bx y:by |
2179 | 259 |
"check and return valid position a handle can be placed |
260 |
" |
|
2252 | 261 |
|max min pos subViews halfBarHeight barHeight thisView nextView nextView2| |
2159
2864c0de7f33
make certain, that handles can always be clicked on;
Claus Gittinger <cg@exept.de>
parents:
2005
diff
changeset
|
262 |
|
2864c0de7f33
make certain, that handles can always be clicked on;
Claus Gittinger <cg@exept.de>
parents:
2005
diff
changeset
|
263 |
subViews := view subViews. |
2252 | 264 |
barHeight := view barHeight. |
2245 | 265 |
"/ halfBarHeight := view barHeight + 1 // 2. |
2252 | 266 |
halfBarHeight := barHeight // 2. |
267 |
||
268 |
thisView := subViews at:movedHandle. |
|
269 |
nextView := subViews at:movedHandle + 1. |
|
270 |
nextView2 := subViews at:movedHandle + 2 ifAbsent:nil. |
|
2159
2864c0de7f33
make certain, that handles can always be clicked on;
Claus Gittinger <cg@exept.de>
parents:
2005
diff
changeset
|
271 |
|
2179 | 272 |
view orientation == #vertical ifTrue:[ |
2245 | 273 |
pos := by. |
2252 | 274 |
min := thisView top. |
275 |
nextView2 isNil ifTrue:[ |
|
276 |
max := view height. |
|
277 |
] ifFalse:[ |
|
278 |
max := nextView2 top. |
|
279 |
]. |
|
2159
2864c0de7f33
make certain, that handles can always be clicked on;
Claus Gittinger <cg@exept.de>
parents:
2005
diff
changeset
|
280 |
] ifFalse:[ |
2245 | 281 |
pos := bx. |
2252 | 282 |
min := thisView left. |
283 |
nextView2 isNil ifTrue:[ |
|
284 |
max := view width. |
|
285 |
] ifFalse:[ |
|
286 |
max := nextView2 left. |
|
287 |
]. |
|
2159
2864c0de7f33
make certain, that handles can always be clicked on;
Claus Gittinger <cg@exept.de>
parents:
2005
diff
changeset
|
288 |
]. |
2864c0de7f33
make certain, that handles can always be clicked on;
Claus Gittinger <cg@exept.de>
parents:
2005
diff
changeset
|
289 |
|
2260
ce3be65862db
min/max - make certain that handle can still be grabbed
Claus Gittinger <cg@exept.de>
parents:
2252
diff
changeset
|
290 |
min := min + halfBarHeight "- 1". |
2252 | 291 |
barHeight odd ifTrue:[ min := min + 1 ]. |
2260
ce3be65862db
min/max - make certain that handle can still be grabbed
Claus Gittinger <cg@exept.de>
parents:
2252
diff
changeset
|
292 |
movedHandle == 1 ifTrue:[ |
ce3be65862db
min/max - make certain that handle can still be grabbed
Claus Gittinger <cg@exept.de>
parents:
2252
diff
changeset
|
293 |
min := min + view margin |
ce3be65862db
min/max - make certain that handle can still be grabbed
Claus Gittinger <cg@exept.de>
parents:
2252
diff
changeset
|
294 |
]. |
2245 | 295 |
|
296 |
"/ max := max - halfBarHeight. |
|
2252 | 297 |
"/ movedHandle == (subViews size-1) ifTrue:[ |
298 |
"/ max := max - barHeight + 2. |
|
299 |
"/ ] ifFalse:[ |
|
300 |
max := max - halfBarHeight + 1. |
|
301 |
barHeight odd ifTrue:[ max := max - 1 ]. |
|
302 |
"/ ]. |
|
2159
2864c0de7f33
make certain, that handles can always be clicked on;
Claus Gittinger <cg@exept.de>
parents:
2005
diff
changeset
|
303 |
|
2260
ce3be65862db
min/max - make certain that handle can still be grabbed
Claus Gittinger <cg@exept.de>
parents:
2252
diff
changeset
|
304 |
movedHandle == (subViews size-1) ifTrue:[ |
ce3be65862db
min/max - make certain that handle can still be grabbed
Claus Gittinger <cg@exept.de>
parents:
2252
diff
changeset
|
305 |
max := max - view margin |
ce3be65862db
min/max - make certain that handle can still be grabbed
Claus Gittinger <cg@exept.de>
parents:
2252
diff
changeset
|
306 |
]. |
ce3be65862db
min/max - make certain that handle can still be grabbed
Claus Gittinger <cg@exept.de>
parents:
2252
diff
changeset
|
307 |
|
2179 | 308 |
pos < min ifTrue:[^ min]. |
2252 | 309 |
pos > max ifTrue:[^ max]. |
310 |
^ pos |
|
2159
2864c0de7f33
make certain, that handles can always be clicked on;
Claus Gittinger <cg@exept.de>
parents:
2005
diff
changeset
|
311 |
! |
2864c0de7f33
make certain, that handles can always be clicked on;
Claus Gittinger <cg@exept.de>
parents:
2005
diff
changeset
|
312 |
|
2179 | 313 |
detectHandleIndexAt:x y:y |
314 |
"returns the handle index at position x@y or nil if none detected |
|
315 |
" |
|
316 |
|subViews |
|
317 |
size "{ Class: SmallInteger }"| |
|
318 |
||
319 |
subViews := view subViews. |
|
320 |
||
321 |
(size := subViews size) > 1 ifTrue:[ |
|
322 |
view orientation == #vertical ifTrue:[ |
|
323 |
2 to:size do:[:i| |
|
324 |
(subViews at:i) top >= y ifTrue:[ |
|
325 |
^ (subViews at:(i-1)) bottom < y ifTrue:[i-1] ifFalse:[nil] |
|
326 |
] |
|
327 |
] |
|
328 |
] ifFalse:[ |
|
329 |
2 to:size do:[:i| |
|
330 |
(subViews at:i) left >= x ifTrue:[ |
|
331 |
^ (subViews at:(i-1)) right < x ifTrue:[i-1] ifFalse:[nil] |
|
332 |
] |
|
333 |
] |
|
334 |
] |
|
335 |
]. |
|
336 |
^ nil |
|
337 |
||
338 |
||
339 |
! ! |
|
1871 | 340 |
|
2179 | 341 |
!VariablePanelController methodsFor:'queries'! |
342 |
||
343 |
isSnapEntered:anIndex |
|
344 |
^ saveCursor notNil and:[anIndex == movedHandle] |
|
345 |
||
346 |
! |
|
347 |
||
348 |
isSnapPressed |
|
349 |
^ resizeMode notNil and:[resizeMode ~~ #active] |
|
350 |
! ! |
|
351 |
||
352 |
!VariablePanelController methodsFor:'user operations'! |
|
104 | 353 |
|
2179 | 354 |
doInvertHandle |
355 |
"invert a handle |
|
356 |
" |
|
357 |
|pos| |
|
358 |
||
359 |
pos := prevPos - (view barHeight + 1 // 2). |
|
360 |
view invertHandleBarAtX:pos y:pos. |
|
361 |
! |
|
362 |
||
363 |
doResize |
|
364 |
"perform the resize |
|
365 |
" |
|
366 |
|aboveView belowView aboveIndex belowIndex newRelPos subViews isVertical |
|
367 |
opaqueResizing newCorner newOrigin halfBarHg| |
|
368 |
||
369 |
opaqueResizing := UserPreferences current opaqueVariablePanelResizing == true. |
|
104 | 370 |
|
1871 | 371 |
"undo the last invert" |
2179 | 372 |
(resizeMode == #active and:[opaqueResizing not]) ifTrue:[ |
373 |
self doInvertHandle |
|
1871 | 374 |
]. |
2179 | 375 |
"check if position changed" |
376 |
prevPos == clickPos ifTrue:[^ self]. |
|
104 | 377 |
|
2179 | 378 |
"compute the new relative origins & corners" |
379 |
isVertical := view orientation == #vertical. |
|
1871 | 380 |
aboveIndex := movedHandle. |
381 |
belowIndex := movedHandle + 1. |
|
2179 | 382 |
subViews := view subViews. |
383 |
aboveView := subViews at:aboveIndex. |
|
384 |
belowView := subViews at:belowIndex. |
|
385 |
halfBarHg := view barHeight + 1 // 2. |
|
1626
3013631d4384
do nothing if pointer was never moved;
Claus Gittinger <cg@exept.de>
parents:
1483
diff
changeset
|
386 |
|
2179 | 387 |
isVertical ifFalse:[ |
388 |
"X complains badly if you try to create/resize a view with a dimension <= 0 |
|
389 |
" |
|
390 |
prevPos - halfBarHg == aboveView left ifTrue:[prevPos := prevPos + 1]. |
|
104 | 391 |
|
2179 | 392 |
newRelPos := (prevPos / view width) asFloat. |
393 |
newCorner := newRelPos @ aboveView relativeCorner y. |
|
2159
2864c0de7f33
make certain, that handles can always be clicked on;
Claus Gittinger <cg@exept.de>
parents:
2005
diff
changeset
|
394 |
newOrigin := newRelPos @ belowView relativeOrigin y. |
2179 | 395 |
] ifTrue:[ |
396 |
"X complains badly if you try to create/resize a view with a dimension <= 0 |
|
397 |
" |
|
398 |
prevPos - halfBarHg == aboveView top ifTrue:[prevPos := prevPos + 1]. |
|
399 |
||
400 |
newRelPos := (prevPos / view height) asFloat. |
|
401 |
newCorner := aboveView relativeCorner x @ newRelPos. |
|
2159
2864c0de7f33
make certain, that handles can always be clicked on;
Claus Gittinger <cg@exept.de>
parents:
2005
diff
changeset
|
402 |
newOrigin := belowView relativeOrigin x @ newRelPos. |
1871 | 403 |
]. |
2179 | 404 |
view lockRedraw. |
405 |
||
1871 | 406 |
aboveView relativeCorner:newCorner. |
407 |
belowView relativeOrigin:newOrigin. |
|
104 | 408 |
|
2179 | 409 |
prevPos > clickPos ifTrue:[ "above view grows" |
410 |
view resizeSubviewsFrom:aboveIndex to:belowIndex. |
|
104 | 411 |
] ifFalse:[ |
2179 | 412 |
view resizeSubviewsFrom:belowIndex to:aboveIndex |
1871 | 413 |
]. |
414 |
view unlockRedraw. |
|
1626
3013631d4384
do nothing if pointer was never moved;
Claus Gittinger <cg@exept.de>
parents:
1483
diff
changeset
|
415 |
|
2179 | 416 |
prevPos := isVertical ifTrue:[aboveView bottom] ifFalse:[aboveView right]. |
417 |
prevPos := prevPos + (view barHeight + 1 // 2). |
|
1483 | 418 |
! |
419 |
||
2236 | 420 |
doSnapPressedX:x y:y |
2179 | 421 |
"perform the snap press |
422 |
" |
|
2236 | 423 |
|layout handle curRCorner prvRCorner isVertical newPos mode isMax isMin doRememberPosition| |
2179 | 424 |
|
425 |
(mode := view snapMode) isNil ifTrue:[^ self]. |
|
426 |
||
427 |
layout := view snapLayoutAt:movedHandle. |
|
428 |
handle := view subViews at:movedHandle. |
|
429 |
isVertical := view orientation == #vertical. |
|
2236 | 430 |
|
2179 | 431 |
curRCorner := handle relativeCorner. |
432 |
prvRCorner := handle objectAttributeAt:#vpext. |
|
433 |
||
2236 | 434 |
isMax := isMin := false. |
435 |
mode == #both ifTrue:[ |
|
436 |
isVertical ifTrue:[ |
|
437 |
isMax := x > (layout right - (layout width//3)). |
|
438 |
isMin := x < (layout left + (layout width//3)). |
|
439 |
] ifFalse:[ |
|
2239 | 440 |
isMin := y > (layout bottom - (layout height//3)). |
441 |
isMax := y < (layout top + (layout height//3)). |
|
2236 | 442 |
]. |
443 |
handle objectAttributeAt:#snapPart put:(isMin ifTrue:[#left] ifFalse:[ isMax ifTrue:[#right] ifFalse:[#middle]]). |
|
444 |
doRememberPosition := (isMin or:[isMax]) and:[prvRCorner isNil]. |
|
445 |
] ifFalse:[ |
|
446 |
isMax := view snapAtIndexWillGrow:movedHandle. |
|
447 |
isMin := isMax not. |
|
448 |
isMax ifTrue:[ |
|
449 |
isMax := prvRCorner isNil or:[mode ~~ #min] |
|
450 |
] ifFalse:[ |
|
451 |
isMin := prvRCorner isNil or:[mode ~~ #max] |
|
452 |
]. |
|
453 |
doRememberPosition := true. |
|
454 |
]. |
|
455 |
||
456 |
isMax ifTrue:[ |
|
457 |
newPos := 99999 "set extent to max" |
|
458 |
] ifFalse:[ |
|
459 |
isMin ifTrue:[ |
|
460 |
newPos := 0 "set extent to min" |
|
461 |
] ifFalse:[ |
|
462 |
newPos := nil "restore previous extent" |
|
463 |
] |
|
2179 | 464 |
]. |
465 |
||
466 |
newPos isNil ifTrue:[ |
|
2236 | 467 |
prvRCorner isNil ifTrue:[ |
468 |
"/ nothing to do |
|
469 |
^ self |
|
470 |
]. |
|
471 |
||
2179 | 472 |
"restore previous extent" |
473 |
newPos := isVertical ifTrue:[view height * prvRCorner y] |
|
474 |
ifFalse:[view width * prvRCorner x]. |
|
475 |
||
476 |
newPos := self checkedHandleMovementX:newPos y:newPos. |
|
477 |
||
478 |
(prevPos - newPos) abs < 2 ifTrue:[ |
|
479 |
"cannot resize; set extent to min or max dependent on the current extent" |
|
480 |
isVertical ifTrue:[ |
|
481 |
newPos := handle height > 2 ifTrue:[0] ifFalse:[99999] |
|
482 |
] ifFalse:[ |
|
483 |
newPos := handle width > 2 ifTrue:[0] ifFalse:[99999] |
|
484 |
]. |
|
485 |
newPos := self checkedHandleMovementX:newPos y:newPos. |
|
486 |
]. |
|
2236 | 487 |
|
488 |
mode == #both ifTrue:[ |
|
489 |
handle objectAttributeAt:#vpext put:nil. "clear previous corner" |
|
490 |
doRememberPosition := false. |
|
491 |
]. |
|
492 |
||
2179 | 493 |
] ifFalse:[ |
494 |
newPos := self checkedHandleMovementX:newPos y:newPos |
|
495 |
]. |
|
496 |
||
497 |
(newPos - prevPos) abs < 2 ifFalse:[ |
|
2236 | 498 |
doRememberPosition ifTrue:[ |
499 |
handle objectAttributeAt:#vpext put:curRCorner. "save previous corner" |
|
500 |
]. |
|
2179 | 501 |
prevPos := newPos. |
502 |
self doResize. |
|
1483 | 503 |
] |
200 | 504 |
! ! |
104 | 505 |
|
203 | 506 |
!VariablePanelController class methodsFor:'documentation'! |
507 |
||
508 |
version |
|
2284
a0fe280353ba
ignore other button-presses/releases while moving the bar
Claus Gittinger <cg@exept.de>
parents:
2260
diff
changeset
|
509 |
^ '$Header: /cvs/stx/stx/libwidg/VariablePanelController.st,v 1.33 2000-09-27 14:23:30 cg Exp $' |
2179 | 510 |
|
511 |
||
203 | 512 |
! ! |