VariablePanelController.st
author Claus Gittinger <cg@exept.de>
Sat, 02 Feb 2002 13:57:54 +0100
changeset 2510 609971cc700d
parent 2396 8340b529e8ce
child 2512 57d79580ff7f
permissions -rw-r--r--
motion event compression
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.
2239
31a57c0002a2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2236
diff changeset
    81
                view cursor:(Cursor hand).
2179
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
    ].
2396
8340b529e8ce fix for windows MOUSE_MOVE event bug
Claus Gittinger <cg@exept.de>
parents: 2284
diff changeset
    90
2179
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
    91
    (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
    92
2396
8340b529e8ce fix for windows MOUSE_MOVE event bug
Claus Gittinger <cg@exept.de>
parents: 2284
diff changeset
    93
    "/ kludge: workaround Windows bug, which sends a MOUSEMOVE
8340b529e8ce fix for windows MOUSE_MOVE event bug
Claus Gittinger <cg@exept.de>
parents: 2284
diff changeset
    94
    "/ (with same coordinate as previous MOUSE_DOWN
8340b529e8ce fix for windows MOUSE_MOVE event bug
Claus Gittinger <cg@exept.de>
parents: 2284
diff changeset
    95
    view orientation ~~ #vertical ifTrue:[
8340b529e8ce fix for windows MOUSE_MOVE event bug
Claus Gittinger <cg@exept.de>
parents: 2284
diff changeset
    96
        clickPos == bx ifTrue:[^ self].
2510
609971cc700d motion event compression
Claus Gittinger <cg@exept.de>
parents: 2396
diff changeset
    97
        prevPos == bx ifTrue:[^ self].
2396
8340b529e8ce fix for windows MOUSE_MOVE event bug
Claus Gittinger <cg@exept.de>
parents: 2284
diff changeset
    98
    ] ifFalse:[
8340b529e8ce fix for windows MOUSE_MOVE event bug
Claus Gittinger <cg@exept.de>
parents: 2284
diff changeset
    99
        clickPos == by ifTrue:[^ self].
2510
609971cc700d motion event compression
Claus Gittinger <cg@exept.de>
parents: 2396
diff changeset
   100
        prevPos == by ifTrue:[^ self].
2396
8340b529e8ce fix for windows MOUSE_MOVE event bug
Claus Gittinger <cg@exept.de>
parents: 2284
diff changeset
   101
    ].
8340b529e8ce fix for windows MOUSE_MOVE event bug
Claus Gittinger <cg@exept.de>
parents: 2284
diff changeset
   102
2179
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   103
    "RESIZING"
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   104
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   105
    "compute new position ...."
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   106
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   107
    nextPos := self checkedHandleMovementX:bx y:by.
2252
67269562b687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   108
"/    nextPos = prevPos ifTrue:[
67269562b687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   109
"/        ^ self
67269562b687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   110
"/    ].
67269562b687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   111
2179
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   112
    opaqueResizing := UserPreferences current opaqueVariablePanelResizing == true.
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   113
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   114
    resizeMode == #active ifTrue:[
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   115
        "check position changed ..."
2252
67269562b687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   116
"/        nextPos > 10 ifTrue:[
67269562b687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   117
"/            (prevPos - nextPos) abs < 2 ifTrue:[^ self].
67269562b687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   118
"/        ].
2179
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   119
        opaqueResizing ifFalse:[
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   120
            self doInvertHandle   "undo the last invert"
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   121
        ]
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   122
    ] ifFalse:[
2252
67269562b687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   123
"/        nextPos > 10 ifTrue:[
67269562b687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   124
"/            (clickPos - nextPos) abs < 5 ifTrue:[^ self].
67269562b687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   125
"/        ].
2179
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   126
        resizeMode := #active.
131
claus
parents: 126
diff changeset
   127
2179
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   128
        "/ restore the snap cursor
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   129
        saveCursor notNil ifTrue:[
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   130
            view grabPointerWithCursor:saveCursor.
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   131
            saveCursor := nil.
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   132
            view drawSnapAt:movedHandle.
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   133
        ]
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   134
    ].
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   135
    prevPos := nextPos.
1720
896886032334 added opaqueResize option.
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   136
2179
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   137
    opaqueResizing ifFalse:[
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   138
        self doInvertHandle.
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   139
    ] ifTrue:[
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   140
        self doResize.
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   141
    ].
2396
8340b529e8ce fix for windows MOUSE_MOVE event bug
Claus Gittinger <cg@exept.de>
parents: 2284
diff changeset
   142
8340b529e8ce fix for windows MOUSE_MOVE event bug
Claus Gittinger <cg@exept.de>
parents: 2284
diff changeset
   143
    "Modified: / 24.8.2001 / 15:34:57 / cg"
104
ca75c90df7a9 Initial revision
claus
parents:
diff changeset
   144
!
ca75c90df7a9 Initial revision
claus
parents:
diff changeset
   145
200
aa3e56929a5a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   146
buttonPress:button x:bx y:by
2179
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   147
    "button was pressed - setup resizing if a handle is hit
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   148
    "
2236
cd77d04c9a0a snapMode: #both
Claus Gittinger <cg@exept.de>
parents: 2223
diff changeset
   149
    |handleView hindex isMin isMax layout|
200
aa3e56929a5a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   150
2179
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   151
    ((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
   152
        movedHandle isNil ifTrue:[
a0fe280353ba ignore other button-presses/releases while moving the bar
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   153
            self pointerLeave:0.
a0fe280353ba ignore other button-presses/releases while moving the bar
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   154
            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
   155
        ].
a0fe280353ba ignore other button-presses/releases while moving the bar
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   156
        ^ self.
2179
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   157
    ].
2396
8340b529e8ce fix for windows MOUSE_MOVE event bug
Claus Gittinger <cg@exept.de>
parents: 2284
diff changeset
   158
2510
609971cc700d motion event compression
Claus Gittinger <cg@exept.de>
parents: 2396
diff changeset
   159
    view compressMotionEvents:true.
2179
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   160
    hindex := self detectHandleIndexAt:bx y:by.
1626
3013631d4384 do nothing if pointer was never moved;
Claus Gittinger <cg@exept.de>
parents: 1483
diff changeset
   161
2179
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   162
    movedHandle notNil ifTrue:[
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   163
        hindex ~~ movedHandle ifTrue:[self pointerLeave:0].     "restore the cursor"
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   164
    ].
200
aa3e56929a5a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   165
2179
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   166
    (     (movedHandle := hindex) notNil
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   167
     and:[(view canChangeExtentOfViewAt:movedHandle)]
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   168
    ) ifFalse:[
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   169
        ^ self
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   170
    ].
2236
cd77d04c9a0a snapMode: #both
Claus Gittinger <cg@exept.de>
parents: 2223
diff changeset
   171
2179
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   172
    view grabPointerWithCursor:(view cursor).
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   173
    handleView := view subViews at:movedHandle.
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   174
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   175
    "setup resizeing"
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   176
    resizeMode := #init.
2159
2864c0de7f33 make certain, that handles can always be clicked on;
Claus Gittinger <cg@exept.de>
parents: 2005
diff changeset
   177
2179
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   178
    view orientation ~~ #vertical ifTrue:[
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   179
        clickPos := bx.
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   180
        prevPos  := handleView right.
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   181
    ] ifFalse:[
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   182
        clickPos := by.
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   183
        prevPos  := handleView bottom.
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   184
    ].
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   185
    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
   186
2179
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   187
    saveCursor notNil ifTrue:[
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   188
        "there is a snap under the cursor; redraw selected"
2236
cd77d04c9a0a snapMode: #both
Claus Gittinger <cg@exept.de>
parents: 2223
diff changeset
   189
        view snapMode == #both ifTrue:[
cd77d04c9a0a snapMode: #both
Claus Gittinger <cg@exept.de>
parents: 2223
diff changeset
   190
            layout := view snapLayoutAt:movedHandle.
cd77d04c9a0a snapMode: #both
Claus Gittinger <cg@exept.de>
parents: 2223
diff changeset
   191
            view orientation == #vertical ifTrue:[
cd77d04c9a0a snapMode: #both
Claus Gittinger <cg@exept.de>
parents: 2223
diff changeset
   192
                isMax := bx > (layout right - (layout width//3)).
cd77d04c9a0a snapMode: #both
Claus Gittinger <cg@exept.de>
parents: 2223
diff changeset
   193
                isMin := bx < (layout left + (layout width//3)).
cd77d04c9a0a snapMode: #both
Claus Gittinger <cg@exept.de>
parents: 2223
diff changeset
   194
            ] ifFalse:[
cd77d04c9a0a snapMode: #both
Claus Gittinger <cg@exept.de>
parents: 2223
diff changeset
   195
                isMax := by > (layout bottom - (layout height//3)).
cd77d04c9a0a snapMode: #both
Claus Gittinger <cg@exept.de>
parents: 2223
diff changeset
   196
                isMin := by < (layout top + (layout height//3)).
cd77d04c9a0a snapMode: #both
Claus Gittinger <cg@exept.de>
parents: 2223
diff changeset
   197
            ].
cd77d04c9a0a snapMode: #both
Claus Gittinger <cg@exept.de>
parents: 2223
diff changeset
   198
            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
   199
        ].
2179
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   200
        view drawSnapAt:movedHandle
200
aa3e56929a5a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   201
    ]
2396
8340b529e8ce fix for windows MOUSE_MOVE event bug
Claus Gittinger <cg@exept.de>
parents: 2284
diff changeset
   202
8340b529e8ce fix for windows MOUSE_MOVE event bug
Claus Gittinger <cg@exept.de>
parents: 2284
diff changeset
   203
    "Modified: / 24.8.2001 / 15:35:27 / cg"
200
aa3e56929a5a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   204
!
aa3e56929a5a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   205
1626
3013631d4384 do nothing if pointer was never moved;
Claus Gittinger <cg@exept.de>
parents: 1483
diff changeset
   206
buttonRelease:button x:bx y:by
104
ca75c90df7a9 Initial revision
claus
parents:
diff changeset
   207
    "end bar-move"
ca75c90df7a9 Initial revision
claus
parents:
diff changeset
   208
2179
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   209
    |subViews layout aboveView|
1871
a6b15bdfcc92 better opaque resize
Claus Gittinger <cg@exept.de>
parents: 1802
diff changeset
   210
2179
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   211
    ((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
   212
        movedHandle isNil ifTrue:[
a0fe280353ba ignore other button-presses/releases while moving the bar
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   213
            resizeMode := nil.
a0fe280353ba ignore other button-presses/releases while moving the bar
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   214
            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
   215
        ].
a0fe280353ba ignore other button-presses/releases while moving the bar
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   216
        ^ self.
2179
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   217
    ].
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   218
2510
609971cc700d motion event compression
Claus Gittinger <cg@exept.de>
parents: 2396
diff changeset
   219
    view compressMotionEvents:false.
2179
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   220
    view ungrabPointer.
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   221
    movedHandle isNil ifTrue:[^ self].
1871
a6b15bdfcc92 better opaque resize
Claus Gittinger <cg@exept.de>
parents: 1802
diff changeset
   222
2179
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   223
    resizeMode notNil ifTrue:[
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   224
        resizeMode == #active ifTrue:[
2236
cd77d04c9a0a snapMode: #both
Claus Gittinger <cg@exept.de>
parents: 2223
diff changeset
   225
            (view snapMode == #both) ifFalse:[
cd77d04c9a0a snapMode: #both
Claus Gittinger <cg@exept.de>
parents: 2223
diff changeset
   226
                aboveView := view subViews at:movedHandle.
cd77d04c9a0a snapMode: #both
Claus Gittinger <cg@exept.de>
parents: 2223
diff changeset
   227
                aboveView objectAttributeAt:#vpext put:(aboveView relativeCorner).
cd77d04c9a0a snapMode: #both
Claus Gittinger <cg@exept.de>
parents: 2223
diff changeset
   228
            ].
2252
67269562b687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   229
            (UserPreferences current opaqueVariablePanelResizing == true) ifFalse:[
67269562b687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   230
                self doResize
67269562b687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   231
            ].
2179
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   232
        ] ifFalse:[
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   233
            (    (layout := view snapLayoutAt:movedHandle) notNil
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   234
             and:[layout containsPointX:bx y:by]
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   235
            ) ifTrue:[
2236
cd77d04c9a0a snapMode: #both
Claus Gittinger <cg@exept.de>
parents: 2223
diff changeset
   236
                self doSnapPressedX:bx y:by
2179
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   237
            ].
1871
a6b15bdfcc92 better opaque resize
Claus Gittinger <cg@exept.de>
parents: 1802
diff changeset
   238
        ].
2179
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   239
    ].
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   240
    self pointerLeave:0.
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   241
    self pointerEnter:0 x:bx y:by.      "check whether mouse on a handle"
2396
8340b529e8ce fix for windows MOUSE_MOVE event bug
Claus Gittinger <cg@exept.de>
parents: 2284
diff changeset
   242
8340b529e8ce fix for windows MOUSE_MOVE event bug
Claus Gittinger <cg@exept.de>
parents: 2284
diff changeset
   243
    "Modified: / 24.8.2001 / 15:35:33 / cg"
1871
a6b15bdfcc92 better opaque resize
Claus Gittinger <cg@exept.de>
parents: 1802
diff changeset
   244
!
a6b15bdfcc92 better opaque resize
Claus Gittinger <cg@exept.de>
parents: 1802
diff changeset
   245
2179
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   246
pointerEnter:state x:bx y:by
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   247
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   248
    state == 0 ifTrue:[
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   249
        view snapMode notNil ifTrue:[
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   250
            (movedHandle := self detectHandleIndexAt:bx y:by) notNil ifTrue:[
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   251
                self buttonMotion:state x:bx y:by
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   252
            ]
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   253
        ]
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   254
    ]
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   255
!
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   256
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   257
pointerLeave:state
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   258
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   259
    saveCursor notNil ifTrue:[
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   260
        "restore the cursor"
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   261
        view cursor:saveCursor.
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   262
        saveCursor := nil
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   263
    ].
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   264
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   265
    state == 0 ifTrue:[
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   266
        resizeMode := nil.
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   267
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   268
        movedHandle notNil ifTrue:[
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   269
            view drawSnapAt:movedHandle.
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   270
            movedHandle := nil.
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   271
        ]
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   272
    ].
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   273
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   274
! !
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   275
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   276
!VariablePanelController methodsFor:'private'!
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   277
2159
2864c0de7f33 make certain, that handles can always be clicked on;
Claus Gittinger <cg@exept.de>
parents: 2005
diff changeset
   278
checkedHandleMovementX:bx y:by
2179
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   279
    "check and return valid position a handle can be placed
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   280
    "
2252
67269562b687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   281
    |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
   282
2864c0de7f33 make certain, that handles can always be clicked on;
Claus Gittinger <cg@exept.de>
parents: 2005
diff changeset
   283
    subViews := view subViews.
2252
67269562b687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   284
    barHeight := view barHeight.
2245
e561458f9232 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   285
"/    halfBarHeight := view barHeight + 1 // 2.
2252
67269562b687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   286
    halfBarHeight := barHeight // 2.
67269562b687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   287
67269562b687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   288
    thisView := subViews at:movedHandle.
67269562b687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   289
    nextView := subViews at:movedHandle + 1.
67269562b687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   290
    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
   291
2179
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   292
    view orientation == #vertical ifTrue:[
2245
e561458f9232 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   293
        pos := by.
2252
67269562b687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   294
        min := thisView top.
67269562b687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   295
        nextView2 isNil ifTrue:[
67269562b687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   296
            max := view height.
67269562b687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   297
        ] ifFalse:[
67269562b687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   298
            max := nextView2 top.
67269562b687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   299
        ].
2159
2864c0de7f33 make certain, that handles can always be clicked on;
Claus Gittinger <cg@exept.de>
parents: 2005
diff changeset
   300
    ] ifFalse:[
2245
e561458f9232 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   301
        pos := bx.
2252
67269562b687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   302
        min := thisView left.
67269562b687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   303
        nextView2 isNil ifTrue:[
67269562b687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   304
            max := view width.
67269562b687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   305
        ] ifFalse:[
67269562b687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   306
            max := nextView2 left.
67269562b687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   307
        ].
2159
2864c0de7f33 make certain, that handles can always be clicked on;
Claus Gittinger <cg@exept.de>
parents: 2005
diff changeset
   308
    ].
2864c0de7f33 make certain, that handles can always be clicked on;
Claus Gittinger <cg@exept.de>
parents: 2005
diff changeset
   309
2260
ce3be65862db min/max - make certain that handle can still be grabbed
Claus Gittinger <cg@exept.de>
parents: 2252
diff changeset
   310
    min := min + halfBarHeight "- 1".
2252
67269562b687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   311
    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
   312
    movedHandle == 1 ifTrue:[
ce3be65862db min/max - make certain that handle can still be grabbed
Claus Gittinger <cg@exept.de>
parents: 2252
diff changeset
   313
        min := min + view margin
ce3be65862db min/max - make certain that handle can still be grabbed
Claus Gittinger <cg@exept.de>
parents: 2252
diff changeset
   314
    ].
2245
e561458f9232 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   315
e561458f9232 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2239
diff changeset
   316
"/    max := max - halfBarHeight.
2252
67269562b687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   317
"/    movedHandle == (subViews size-1) ifTrue:[
67269562b687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   318
"/        max := max - barHeight + 2.
67269562b687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   319
"/    ] ifFalse:[
67269562b687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   320
        max := max - halfBarHeight + 1.
67269562b687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   321
        barHeight odd ifTrue:[ max := max - 1 ].
67269562b687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   322
"/    ].
2159
2864c0de7f33 make certain, that handles can always be clicked on;
Claus Gittinger <cg@exept.de>
parents: 2005
diff changeset
   323
2260
ce3be65862db min/max - make certain that handle can still be grabbed
Claus Gittinger <cg@exept.de>
parents: 2252
diff changeset
   324
    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
   325
        max := max - view margin
ce3be65862db min/max - make certain that handle can still be grabbed
Claus Gittinger <cg@exept.de>
parents: 2252
diff changeset
   326
    ].
ce3be65862db min/max - make certain that handle can still be grabbed
Claus Gittinger <cg@exept.de>
parents: 2252
diff changeset
   327
2179
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   328
    pos < min ifTrue:[^ min].
2252
67269562b687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   329
    pos > max ifTrue:[^ max].
67269562b687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   330
    ^ pos
2159
2864c0de7f33 make certain, that handles can always be clicked on;
Claus Gittinger <cg@exept.de>
parents: 2005
diff changeset
   331
!
2864c0de7f33 make certain, that handles can always be clicked on;
Claus Gittinger <cg@exept.de>
parents: 2005
diff changeset
   332
2179
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   333
detectHandleIndexAt:x y:y
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   334
    "returns the handle index at position x@y or nil if none detected
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   335
    "
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   336
    |subViews
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   337
     size "{ Class: SmallInteger }"|
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   338
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   339
    subViews := view subViews.
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   340
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   341
    (size := subViews size) > 1 ifTrue:[
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   342
	view orientation == #vertical ifTrue:[
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   343
	    2 to:size do:[:i|
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   344
		(subViews at:i) top >= y ifTrue:[
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   345
		    ^ (subViews at:(i-1)) bottom < y ifTrue:[i-1] ifFalse:[nil]
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   346
		]
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   347
	    ]
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   348
	] ifFalse:[
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   349
	    2 to:size do:[:i|
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   350
		(subViews at:i) left >= x ifTrue:[
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   351
		    ^ (subViews at:(i-1)) right < x ifTrue:[i-1] ifFalse:[nil]
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   352
		]
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   353
	    ]
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   354
	]
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   355
    ].
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   356
    ^ nil
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   357
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   358
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   359
! !
1871
a6b15bdfcc92 better opaque resize
Claus Gittinger <cg@exept.de>
parents: 1802
diff changeset
   360
2179
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   361
!VariablePanelController methodsFor:'queries'!
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   362
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   363
isSnapEntered:anIndex
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   364
    ^ saveCursor notNil and:[anIndex == movedHandle]
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   365
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   366
!
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   367
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   368
isSnapPressed
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   369
    ^ resizeMode notNil and:[resizeMode ~~ #active]
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   370
! !
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   371
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   372
!VariablePanelController methodsFor:'user operations'!
104
ca75c90df7a9 Initial revision
claus
parents:
diff changeset
   373
2179
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   374
doInvertHandle
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   375
    "invert a handle
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   376
    "
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   377
    |pos|
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   378
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   379
    pos := prevPos - (view barHeight + 1 // 2).
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   380
    view invertHandleBarAtX:pos y:pos.
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   381
!
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   382
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   383
doResize
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   384
    "perform the resize
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   385
    "
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   386
    |aboveView belowView aboveIndex belowIndex newRelPos subViews isVertical 
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   387
     opaqueResizing newCorner newOrigin halfBarHg|
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   388
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   389
    opaqueResizing := UserPreferences current opaqueVariablePanelResizing == true.
104
ca75c90df7a9 Initial revision
claus
parents:
diff changeset
   390
1871
a6b15bdfcc92 better opaque resize
Claus Gittinger <cg@exept.de>
parents: 1802
diff changeset
   391
    "undo the last invert"
2179
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   392
    (resizeMode == #active and:[opaqueResizing not]) ifTrue:[
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   393
        self doInvertHandle
1871
a6b15bdfcc92 better opaque resize
Claus Gittinger <cg@exept.de>
parents: 1802
diff changeset
   394
    ].
2179
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   395
    "check if position changed"
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   396
    prevPos == clickPos ifTrue:[^ self].
104
ca75c90df7a9 Initial revision
claus
parents:
diff changeset
   397
2179
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   398
    "compute the new relative origins & corners"
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   399
    isVertical := view orientation == #vertical.
1871
a6b15bdfcc92 better opaque resize
Claus Gittinger <cg@exept.de>
parents: 1802
diff changeset
   400
    aboveIndex := movedHandle.
a6b15bdfcc92 better opaque resize
Claus Gittinger <cg@exept.de>
parents: 1802
diff changeset
   401
    belowIndex := movedHandle + 1.
2179
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   402
    subViews   := view subViews.
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   403
    aboveView  := subViews at:aboveIndex.
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   404
    belowView  := subViews at:belowIndex.
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   405
    halfBarHg  := view barHeight + 1 // 2.
1626
3013631d4384 do nothing if pointer was never moved;
Claus Gittinger <cg@exept.de>
parents: 1483
diff changeset
   406
2179
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   407
    isVertical ifFalse:[
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   408
        "X complains badly if you try to create/resize a view with a dimension <= 0
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   409
        "
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   410
        prevPos - halfBarHg == aboveView left ifTrue:[prevPos := prevPos + 1].
104
ca75c90df7a9 Initial revision
claus
parents:
diff changeset
   411
2179
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   412
        newRelPos := (prevPos / view width) asFloat.
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   413
        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
   414
        newOrigin := newRelPos @ belowView relativeOrigin y.
2179
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   415
    ] ifTrue:[
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   416
        "X complains badly if you try to create/resize a view with a dimension <= 0
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   417
        "
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   418
        prevPos - halfBarHg == aboveView top ifTrue:[prevPos := prevPos + 1].
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   419
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   420
        newRelPos := (prevPos / view height) asFloat.
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   421
        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
   422
        newOrigin := belowView relativeOrigin x @ newRelPos.
1871
a6b15bdfcc92 better opaque resize
Claus Gittinger <cg@exept.de>
parents: 1802
diff changeset
   423
    ].
2179
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   424
    view lockRedraw.
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   425
1871
a6b15bdfcc92 better opaque resize
Claus Gittinger <cg@exept.de>
parents: 1802
diff changeset
   426
    aboveView relativeCorner:newCorner.
a6b15bdfcc92 better opaque resize
Claus Gittinger <cg@exept.de>
parents: 1802
diff changeset
   427
    belowView relativeOrigin:newOrigin.
104
ca75c90df7a9 Initial revision
claus
parents:
diff changeset
   428
2179
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   429
    prevPos > clickPos ifTrue:[ "above view grows"
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   430
        view resizeSubviewsFrom:aboveIndex to:belowIndex.
104
ca75c90df7a9 Initial revision
claus
parents:
diff changeset
   431
    ] ifFalse:[
2179
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   432
        view resizeSubviewsFrom:belowIndex to:aboveIndex
1871
a6b15bdfcc92 better opaque resize
Claus Gittinger <cg@exept.de>
parents: 1802
diff changeset
   433
    ].
a6b15bdfcc92 better opaque resize
Claus Gittinger <cg@exept.de>
parents: 1802
diff changeset
   434
    view unlockRedraw.
1626
3013631d4384 do nothing if pointer was never moved;
Claus Gittinger <cg@exept.de>
parents: 1483
diff changeset
   435
2179
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   436
    prevPos := isVertical ifTrue:[aboveView bottom] ifFalse:[aboveView right].
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   437
    prevPos := prevPos + (view barHeight + 1 // 2).
1483
e0fb580b5131 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
   438
!
e0fb580b5131 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
   439
2236
cd77d04c9a0a snapMode: #both
Claus Gittinger <cg@exept.de>
parents: 2223
diff changeset
   440
doSnapPressedX:x y:y
2179
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   441
    "perform the snap press
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   442
    "
2236
cd77d04c9a0a snapMode: #both
Claus Gittinger <cg@exept.de>
parents: 2223
diff changeset
   443
    |layout handle curRCorner prvRCorner isVertical newPos mode isMax isMin doRememberPosition|
2179
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   444
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   445
    (mode := view snapMode) isNil ifTrue:[^ self].
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   446
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   447
    layout     := view snapLayoutAt:movedHandle.
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   448
    handle     := view subViews at:movedHandle.
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   449
    isVertical := view orientation == #vertical.
2236
cd77d04c9a0a snapMode: #both
Claus Gittinger <cg@exept.de>
parents: 2223
diff changeset
   450
2179
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   451
    curRCorner := handle relativeCorner.
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   452
    prvRCorner := handle objectAttributeAt:#vpext.
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   453
2236
cd77d04c9a0a snapMode: #both
Claus Gittinger <cg@exept.de>
parents: 2223
diff changeset
   454
    isMax := isMin := false.
cd77d04c9a0a snapMode: #both
Claus Gittinger <cg@exept.de>
parents: 2223
diff changeset
   455
    mode == #both ifTrue:[
cd77d04c9a0a snapMode: #both
Claus Gittinger <cg@exept.de>
parents: 2223
diff changeset
   456
        isVertical ifTrue:[
cd77d04c9a0a snapMode: #both
Claus Gittinger <cg@exept.de>
parents: 2223
diff changeset
   457
            isMax := x > (layout right - (layout width//3)).
cd77d04c9a0a snapMode: #both
Claus Gittinger <cg@exept.de>
parents: 2223
diff changeset
   458
            isMin := x < (layout left + (layout width//3)).
cd77d04c9a0a snapMode: #both
Claus Gittinger <cg@exept.de>
parents: 2223
diff changeset
   459
        ] ifFalse:[
2239
31a57c0002a2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2236
diff changeset
   460
            isMin := y > (layout bottom - (layout height//3)).
31a57c0002a2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2236
diff changeset
   461
            isMax := y < (layout top + (layout height//3)).
2236
cd77d04c9a0a snapMode: #both
Claus Gittinger <cg@exept.de>
parents: 2223
diff changeset
   462
        ].
cd77d04c9a0a snapMode: #both
Claus Gittinger <cg@exept.de>
parents: 2223
diff changeset
   463
        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
   464
        doRememberPosition := (isMin or:[isMax]) and:[prvRCorner isNil].
cd77d04c9a0a snapMode: #both
Claus Gittinger <cg@exept.de>
parents: 2223
diff changeset
   465
    ] ifFalse:[
cd77d04c9a0a snapMode: #both
Claus Gittinger <cg@exept.de>
parents: 2223
diff changeset
   466
        isMax := view snapAtIndexWillGrow:movedHandle.
cd77d04c9a0a snapMode: #both
Claus Gittinger <cg@exept.de>
parents: 2223
diff changeset
   467
        isMin := isMax not.
cd77d04c9a0a snapMode: #both
Claus Gittinger <cg@exept.de>
parents: 2223
diff changeset
   468
        isMax ifTrue:[
cd77d04c9a0a snapMode: #both
Claus Gittinger <cg@exept.de>
parents: 2223
diff changeset
   469
           isMax := prvRCorner isNil or:[mode ~~ #min]
cd77d04c9a0a snapMode: #both
Claus Gittinger <cg@exept.de>
parents: 2223
diff changeset
   470
        ] ifFalse:[
cd77d04c9a0a snapMode: #both
Claus Gittinger <cg@exept.de>
parents: 2223
diff changeset
   471
           isMin := prvRCorner isNil or:[mode ~~ #max]
cd77d04c9a0a snapMode: #both
Claus Gittinger <cg@exept.de>
parents: 2223
diff changeset
   472
        ].
cd77d04c9a0a snapMode: #both
Claus Gittinger <cg@exept.de>
parents: 2223
diff changeset
   473
        doRememberPosition := true.
cd77d04c9a0a snapMode: #both
Claus Gittinger <cg@exept.de>
parents: 2223
diff changeset
   474
    ].
cd77d04c9a0a snapMode: #both
Claus Gittinger <cg@exept.de>
parents: 2223
diff changeset
   475
cd77d04c9a0a snapMode: #both
Claus Gittinger <cg@exept.de>
parents: 2223
diff changeset
   476
    isMax ifTrue:[
cd77d04c9a0a snapMode: #both
Claus Gittinger <cg@exept.de>
parents: 2223
diff changeset
   477
        newPos := 99999        "set extent to max"
cd77d04c9a0a snapMode: #both
Claus Gittinger <cg@exept.de>
parents: 2223
diff changeset
   478
    ] ifFalse:[
cd77d04c9a0a snapMode: #both
Claus Gittinger <cg@exept.de>
parents: 2223
diff changeset
   479
        isMin ifTrue:[
cd77d04c9a0a snapMode: #both
Claus Gittinger <cg@exept.de>
parents: 2223
diff changeset
   480
            newPos := 0        "set extent to min"
cd77d04c9a0a snapMode: #both
Claus Gittinger <cg@exept.de>
parents: 2223
diff changeset
   481
        ] ifFalse:[
cd77d04c9a0a snapMode: #both
Claus Gittinger <cg@exept.de>
parents: 2223
diff changeset
   482
            newPos := nil      "restore previous extent"
cd77d04c9a0a snapMode: #both
Claus Gittinger <cg@exept.de>
parents: 2223
diff changeset
   483
        ]
2179
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   484
    ].
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   485
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   486
    newPos isNil ifTrue:[
2236
cd77d04c9a0a snapMode: #both
Claus Gittinger <cg@exept.de>
parents: 2223
diff changeset
   487
        prvRCorner isNil ifTrue:[
cd77d04c9a0a snapMode: #both
Claus Gittinger <cg@exept.de>
parents: 2223
diff changeset
   488
            "/ nothing to do
cd77d04c9a0a snapMode: #both
Claus Gittinger <cg@exept.de>
parents: 2223
diff changeset
   489
            ^ self
cd77d04c9a0a snapMode: #both
Claus Gittinger <cg@exept.de>
parents: 2223
diff changeset
   490
        ].
cd77d04c9a0a snapMode: #both
Claus Gittinger <cg@exept.de>
parents: 2223
diff changeset
   491
2179
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   492
        "restore previous extent"
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   493
        newPos := isVertical ifTrue:[view height * prvRCorner y]
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   494
                            ifFalse:[view width  * prvRCorner x].
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   495
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   496
        newPos := self checkedHandleMovementX:newPos y:newPos.
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   497
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   498
        (prevPos - newPos) abs < 2 ifTrue:[
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   499
            "cannot resize; set extent to min or max dependent on the current extent"
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   500
            isVertical ifTrue:[
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   501
                newPos := handle height > 2 ifTrue:[0] ifFalse:[99999]
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   502
            ] ifFalse:[
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   503
                newPos := handle width  > 2 ifTrue:[0] ifFalse:[99999]
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   504
            ].
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   505
            newPos := self checkedHandleMovementX:newPos y:newPos.
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   506
        ].
2236
cd77d04c9a0a snapMode: #both
Claus Gittinger <cg@exept.de>
parents: 2223
diff changeset
   507
cd77d04c9a0a snapMode: #both
Claus Gittinger <cg@exept.de>
parents: 2223
diff changeset
   508
        mode == #both ifTrue:[
cd77d04c9a0a snapMode: #both
Claus Gittinger <cg@exept.de>
parents: 2223
diff changeset
   509
           handle objectAttributeAt:#vpext put:nil.         "clear previous corner"
cd77d04c9a0a snapMode: #both
Claus Gittinger <cg@exept.de>
parents: 2223
diff changeset
   510
           doRememberPosition := false.
cd77d04c9a0a snapMode: #both
Claus Gittinger <cg@exept.de>
parents: 2223
diff changeset
   511
        ].
cd77d04c9a0a snapMode: #both
Claus Gittinger <cg@exept.de>
parents: 2223
diff changeset
   512
2179
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   513
    ] ifFalse:[
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   514
        newPos := self checkedHandleMovementX:newPos y:newPos
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   515
    ].
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   516
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   517
    (newPos - prevPos) abs < 2 ifFalse:[
2236
cd77d04c9a0a snapMode: #both
Claus Gittinger <cg@exept.de>
parents: 2223
diff changeset
   518
        doRememberPosition ifTrue:[
cd77d04c9a0a snapMode: #both
Claus Gittinger <cg@exept.de>
parents: 2223
diff changeset
   519
            handle objectAttributeAt:#vpext put:curRCorner.         "save previous corner"
cd77d04c9a0a snapMode: #both
Claus Gittinger <cg@exept.de>
parents: 2223
diff changeset
   520
        ].
2179
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   521
        prevPos := newPos.
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   522
        self doResize.
1483
e0fb580b5131 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
   523
    ]
200
aa3e56929a5a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   524
! !
104
ca75c90df7a9 Initial revision
claus
parents:
diff changeset
   525
203
8a38b0b03233 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   526
!VariablePanelController class methodsFor:'documentation'!
8a38b0b03233 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   527
8a38b0b03233 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   528
version
2510
609971cc700d motion event compression
Claus Gittinger <cg@exept.de>
parents: 2396
diff changeset
   529
    ^ '$Header: /cvs/stx/stx/libwidg/VariablePanelController.st,v 1.35 2002-02-02 12:57:54 cg Exp $'
2179
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   530
ae22ac1e068e support snap
ca
parents: 2163
diff changeset
   531
203
8a38b0b03233 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   532
! !