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