44 [author:] |
44 [author:] |
45 Claus Gittinger |
45 Claus Gittinger |
46 " |
46 " |
47 ! ! |
47 ! ! |
48 |
48 |
|
49 !VariablePanelController class methodsFor:'defaults'! |
|
50 |
|
51 opaqueResize:aBoolean |
|
52 "set/clear opaque-resizing. |
|
53 If off (the default), the resizing takes place at the end of |
|
54 the handle move operation (when the mouse button is released). |
|
55 If on, the resizing is syncronous with the move. |
|
56 On slow machines, it may make sense to leave it off." |
|
57 |
|
58 OpaqueResize := aBoolean. |
|
59 |
|
60 " |
|
61 self opaqueResize:true |
|
62 self opaqueResize:false |
|
63 " |
|
64 |
|
65 "Modified: / 13.11.1998 / 15:16:37 / cg" |
|
66 ! ! |
|
67 |
49 !VariablePanelController methodsFor:'event handling'! |
68 !VariablePanelController methodsFor:'event handling'! |
50 |
69 |
51 buttonMotion:state x:bx y:by |
70 buttonMotion:state x:bx y:by |
52 "mouse-button was moved while pressed; |
71 "mouse-button was moved while pressed; |
53 clear prev handleBar and draw handle bar at new position" |
72 clear prev handleBar and draw handle bar at new position" |
64 |
83 |
65 subViews := view subViews. |
84 subViews := view subViews. |
66 barHeight := view barHeight. |
85 barHeight := view barHeight. |
67 |
86 |
68 view orientation ~~ #vertical ifTrue:[ |
87 view orientation ~~ #vertical ifTrue:[ |
69 pos := bx - startPos. |
88 pos := bx - startPos. |
70 " |
89 " |
71 the two lines below will not allow resizing down to zero |
90 the two lines below will not allow resizing down to zero |
72 (so that some is always visible) |
91 (so that some is always visible) |
73 " |
92 " |
74 "/ limitMin := barHeight // 2. |
93 "/ limitMin := barHeight // 2. |
75 "/ limitMax := view width - barHeight. |
94 "/ limitMax := view width - barHeight. |
76 " |
95 " |
77 these allow resizing to zero - which is better ? |
96 these allow resizing to zero - which is better ? |
78 " |
97 " |
79 limitMin := 0. |
98 limitMin := 0. |
80 limitMax := view innerWidth. |
99 limitMax := view innerWidth. |
81 |
100 |
82 movedHandle > 1 ifTrue:[ |
101 movedHandle > 1 ifTrue:[ |
83 limitMin := (subViews at:movedHandle) origin x + (barHeight // 2) |
102 limitMin := (subViews at:movedHandle) origin x + (barHeight // 2) |
84 ]. |
103 ]. |
85 movedHandle < (subViews size - 1) ifTrue:[ |
104 movedHandle < (subViews size - 1) ifTrue:[ |
86 limitMax := (subViews at:(movedHandle + 2)) origin x - barHeight |
105 limitMax := (subViews at:(movedHandle + 2)) origin x - barHeight |
87 ]. |
106 ]. |
88 ] ifFalse:[ |
107 ] ifFalse:[ |
89 pos := by - startPos. |
108 pos := by - startPos. |
90 " |
109 " |
91 the two lines below will not allow resizing down to zero |
110 the two lines below will not allow resizing down to zero |
92 (so that some is always visible) |
111 (so that some is always visible) |
93 " |
112 " |
94 "/ limitMin := barHeight // 2. |
113 "/ limitMin := barHeight // 2. |
95 "/ limitMax := view height - barHeight. |
114 "/ limitMax := view height - barHeight. |
96 " |
115 " |
97 these allow resizing to zero - which is better ? |
116 these allow resizing to zero - which is better ? |
98 " |
117 " |
99 limitMin := 0. |
118 limitMin := 0. |
100 limitMax := view innerHeight. |
119 limitMax := view innerHeight. |
101 |
120 |
102 movedHandle > 1 ifTrue:[ |
121 movedHandle > 1 ifTrue:[ |
103 limitMin := (subViews at:movedHandle) origin y + (barHeight // 2) |
122 limitMin := (subViews at:movedHandle) origin y + (barHeight // 2) |
104 ]. |
123 ]. |
105 movedHandle < (subViews size - 1) ifTrue:[ |
124 movedHandle < (subViews size - 1) ifTrue:[ |
106 limitMax := (subViews at:(movedHandle + 2)) origin y - barHeight |
125 limitMax := (subViews at:(movedHandle + 2)) origin y - barHeight |
107 ]. |
126 ]. |
108 ]. |
127 ]. |
109 |
128 |
110 limitMax := limitMax - barHeight. |
129 limitMax := limitMax - barHeight. |
111 (pos < limitMin) ifTrue:[ "check against view limits" |
130 (pos < limitMin) ifTrue:[ "check against view limits" |
112 pos := limitMin |
131 pos := limitMin |
113 ] ifFalse:[ |
132 ] ifFalse:[ |
114 (pos > limitMax) ifTrue:[ |
133 (pos > limitMax) ifTrue:[ |
115 pos := limitMax |
134 pos := limitMax |
116 ] |
135 ] |
117 ]. |
136 ]. |
118 |
137 |
119 prevPos == pos ifTrue:[^ self]. |
138 prevPos == pos ifTrue:[^ self]. |
120 |
139 |
121 view orientation ~~ #vertical ifTrue:[ |
140 view orientation ~~ #vertical ifTrue:[ |
122 oldHx := prevPos. |
141 oldHx := prevPos. |
123 newHx := pos. |
142 newHx := pos. |
124 oldHy := newHy := 0. |
143 oldHy := newHy := 0. |
125 ] ifFalse:[ |
144 ] ifFalse:[ |
126 oldHy := prevPos. |
145 oldHy := prevPos. |
127 newHy := pos. |
146 newHy := pos. |
128 oldHx := newHx := 0. |
147 oldHx := newHx := 0. |
129 ]. |
148 ]. |
130 view invertHandleBarAtX:oldHx y:oldHy. |
149 |
131 view invertHandleBarAtX:newHx y:newHy. |
150 OpaqueResize ~~ true ifTrue:[ |
132 |
151 view invertHandleBarAtX:oldHx y:oldHy. |
133 prevPos := pos |
152 view invertHandleBarAtX:newHx y:newHy. |
|
153 ]. |
|
154 prevPos := pos. |
|
155 |
|
156 OpaqueResize == true ifTrue:[ |
|
157 self buttonRelease:1 x:bx y:by. |
|
158 self buttonPress:1 x:bx y:by. |
|
159 ] |
|
160 |
|
161 "Modified: / 13.11.1998 / 15:13:47 / cg" |
134 ! |
162 ! |
135 |
163 |
136 buttonPress:button x:bx y:by |
164 buttonPress:button x:bx y:by |
137 "button was pressed - if it hits a handle, start move" |
165 "button was pressed - if it hits a handle, start move" |
138 |
166 |