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