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