--- a/UIObjectView.st Tue Feb 25 15:07:09 1997 +0100
+++ b/UIObjectView.st Fri Feb 28 10:20:51 1997 +0100
@@ -1,8 +1,7 @@
-'From Smalltalk/X, Version:3.1.4 on 25-feb-1997 at 2:17:24 pm' !
-
ObjectView subclass:#UIObjectView
instanceVariableNames:'inputView testMode undoHistory copiedExtent actionData
- createClass clipChildren'
+ createClass clipChildren selectionHiddenLevel
+ setOfSuperViewsSizeChanged'
classVariableNames:''
poolDictionaries:''
category:'Interface-UIPainter'
@@ -46,14 +45,45 @@
! !
+!UIObjectView class methodsFor:'queries'!
+
+layoutType:aView
+ "returns layout type of aView or nil
+ "
+ |layout spec|
+
+ layout := aView geometryLayout.
+
+ layout notNil ifTrue:[
+ layout isLayout ifTrue:[
+ layout isLayoutFrame ifTrue:[ ^ #LayoutFrame ].
+ layout isLayoutOrigin ifTrue:[ ^ #LayoutOrigin ].
+ layout isAlignmentOrigin ifTrue:[ ^ #AlignmentOrigin ].
+ ] ifFalse:[
+ layout isRectangle ifTrue:[ ^ #Rectangle ].
+ layout isPoint ifTrue:[ ^ #Point ].
+ ]
+ ] ifFalse:[
+ spec := aView superView specClass.
+
+ spec canResizeSubComponents ifTrue:[ ^ #Extent ].
+ ].
+ ^ nil
+
+! !
+
!UIObjectView methodsFor:'accessing'!
gridAlign
+ "returns state of aligning to grid
+ "
^ aligning
!
gridAlign:aBool
+ "change state of aligning to grid
+ "
aBool ifTrue:[self alignOn]
ifFalse:[self alignOff]
@@ -83,32 +113,30 @@
!
gridShown:aBool
+ "change visibility of grid
+ "
aBool ifTrue:[self showGrid]
ifFalse:[self hideGrid]
!
hideGrid
+ "hide grid
+ "
gridShown ifTrue:[
- self withSelectionHiddenDo:[
- super hideGrid
- ]
+ self withSelectionHiddenDo:[super hideGrid]
]
!
showGrid
- self withSelectionHiddenDo:[
- super showGrid
- ]
-
- "Modified: 5.9.1995 / 12:47:46 / claus"
-
-
+ "show grid
+ "
+ self withSelectionHiddenDo:[super showGrid]
!
testMode
- "returns testMode
+ "returns true if running test
"
^ testMode
@@ -116,7 +144,7 @@
!
testMode:aBoolean
- "change testMode
+ "change test mode
"
(aBoolean == testMode) ifFalse:[
testMode := aBoolean.
@@ -136,51 +164,45 @@
!UIObjectView methodsFor:'blocked'!
addObject:anObject
- "add the argument, anObject to the contents - with redraw"
-
+ "add the argument, anObject to the contents - with redraw
+ "
self halt
!
addObjectWithoutRedraw:anObject
- "add the argument, anObject to the contents - with redraw"
-
+ "add the argument, anObject to the contents - with redraw
+ "
self halt
! !
!UIObjectView methodsFor:'event handling'!
-elementChanged:aView
- "some element has been changed - kludge to force a resizing
- operation (for child layout recomputation) in its superView"
-
- aView superView sizeChanged:nil.
- self changed:#any.
-
-
-!
-
-elementChangedLayout:aView
- "some element has been changed - kludge to force a resizing
- operation (for child layout recomputation) in its superView"
-
- aView superView sizeChanged:nil.
- self changed:#layout.
-
-
+elementChangedSize:aView
+ "some element has changed its size; collect them during selectionHiddenLevel
+ is on
+ "
+ selectionHiddenLevel ~~ 0 ifTrue:[
+ setOfSuperViewsSizeChanged add:aView superView
+ ] ifFalse:[
+ aView superView sizeChanged:nil
+ ]
!
exposeX:x y:y width:w height:h
"handle an expose event from device; redraw selection
"
super exposeX:x y:y width:w height:h.
- self selectionDo:[:v | self showSelected:v]
-
+"/ selectionHiddenLevel == 0 ifTrue:[
+ self selectionDo:[:v | self showSelected:v]
+"/ ]
!
keyPress:key x:x y:y
+ "any key pressed
+ "
<resource: #keyboard ( #InspectIt #Delete #BackSpace #Cut) >
key == #InspectIt ifTrue:[
@@ -218,6 +240,8 @@
!
sizeChanged:how
+ "size of a view(s) changed
+ "
self withSelectionHiddenDo:[
super sizeChanged:how
]
@@ -228,6 +252,8 @@
!UIObjectView methodsFor:'initialization'!
initialize
+ "setup attributes
+ "
super initialize.
"funny: since I do not want the created widgets to get pointer
@@ -236,6 +262,7 @@
is always on top
"
inputView := InputView origin:0.0@0.0 extent:1.0@1.0 in:self.
+ setOfSuperViewsSizeChanged := IdentitySet new.
inputView eventReceiver:self.
inputView enableButtonEvents.
@@ -246,6 +273,7 @@
undoHistory := UndoHistory new.
testMode := false.
clipChildren := true.
+ selectionHiddenLevel := 0.
(self class gridShown) ifTrue:[
super showGrid
@@ -262,6 +290,8 @@
!UIObjectView methodsFor:'misc'!
cursor:aCursor
+ "set cursor
+ "
inputView realized ifTrue:[
inputView cursor:aCursor
].
@@ -271,6 +301,8 @@
!
invertOutlineOf:anObject
+ "invert outline of an object
+ "
|wasClipped delta|
(wasClipped := clipChildren) ifTrue:[
@@ -292,7 +324,8 @@
!
setDefaultActions
-
+ "set default actions
+ "
pressAction := [:pressPoint | self startSelectOrMove:pressPoint].
shiftPressAction := [:pressPoint | self startSelectMoreOrMove:pressPoint].
motionAction := [:movePoint | nil].
@@ -301,61 +334,10 @@
self cursor:Cursor normal.
-!
-
-showDragging:something offset:anOffset
- "drag around a View"
-
- |top|
-
- self forEach:something do:[:anObject |
- self drawRectangle:((anObject origin + anOffset) extent:(anObject extent))
- ]
-
! !
!UIObjectView methodsFor:'object creation'!
-XXstartCreate:aPoint
- "start a widget create
- "
- |widget object start frame delta|
-
- (createClass isNil or:[self numberOfSelections > 1]) ifTrue:[
- self unselect.
- ^ self setDefaultActions.
- ].
-
- motionAction := [:movePoint| self doDragCreate:movePoint].
- releaseAction := [ self endCreate].
-
- widget := self singleSelection.
-
- ( widget notNil
- and:[(self isPoint:aPoint containedIn:widget)
- and:[self supportsSubComponents:widget]]
- ) ifFalse:[
- self unselect.
- widget := self.
- ].
-
- object := createClass new.
- widget addSubView:object.
-
- start := self alignToGrid:aPoint.
- delta := widget originRelativeTo:self.
- frame := Rectangle origin:(start - delta) corner:start.
-
- object origin:(frame origin).
- self setupCreatedObject:object.
- object realize.
-
- self actionCreate:object frame:frame delta:delta.
- self invertOutlineOf:object.
-
-
-!
-
actionCreate:anObject frame:aFrame delta:aDelta
"create and initialize action data
"
@@ -471,7 +453,7 @@
(self isPoint:aPoint containedIn:widget) ifFalse:[
widget := self
] ifTrue:[
- (self supportsSubComponents:widget) ifFalse:[
+ widget specClass supportsSubComponents ifFalse:[
^ self setDefaultActions.
]
]
@@ -515,8 +497,8 @@
!
endObjectMove
- "cleanup after object move"
-
+ "cleanup after object(s) move
+ "
movedObject notNil ifTrue:[
movedObject do:[:aView|
self invertOutlineOf:aView
@@ -558,7 +540,8 @@
!
startObjectMoveAt:aPoint
-
+ "start object(s) move at a point
+ "
self startObjectMove:selection at:aPoint.
selection isCollection ifTrue:[
@@ -597,41 +580,42 @@
!
startSelectOrMove:aPoint
- "a button is pressed at a point
+ "a button is pressed at a point; start moving or selection
"
- |anObject b|
+ |aView b|
testMode ifTrue:[^ self].
- "if there is one object selected and point hits a handle, start a resize
- "
- anObject := self singleSelection.
-
- anObject notNil ifTrue:[
- b := self whichHandleOf:anObject isHitBy:aPoint.
-
- (b notNil and:[b ~~ #view]) ifTrue:[
- ^ self startResizeBorder:b of:anObject.
+ aView := self singleSelection.
+
+ aView notNil ifTrue:[
+ (aView superView specClass canResizeSubComponents) ifTrue:[
+ b := self whichHandleOf:aView isHitBy:aPoint.
+
+ (b notNil and:[b ~~ #view]) ifTrue:[
+ ^ self startResizeBorder:b of:aView.
+ ]
]
].
- anObject := self findObjectAt:aPoint.
-
- "nothing is selected
- "
- anObject isNil ifTrue:[
+ (aView := self findObjectAt:aPoint) isNil ifTrue:[
^ self unselect
].
- (self isSelected:anObject) ifFalse:[
+ (self canMove:aView) ifFalse:[
super unselect.
- self select:anObject.
+ ^ self select:aView
+ ].
+
+ (self isSelected:aView) ifFalse:[
+ super unselect.
+ self select:aView.
].
(self numberOfSelections ~~ 1) ifTrue:[
releaseAction := [
self setDefaultActions.
- self select:anObject
+ self select:aView
]
] ifFalse:[
releaseAction := [self setDefaultActions]
@@ -639,6 +623,7 @@
"prepare move operation for an object
"
+
motionAction := [:movePoint|
(aPoint dist:movePoint) > 4.0 ifTrue:[
self startObjectMoveAt:aPoint
@@ -670,8 +655,8 @@
!
doDragResize:aPoint
- "do a widget resize drag"
-
+ "do a widget resize drag
+ "
|p object|
object := actionData object.
@@ -685,13 +670,18 @@
!
endResize
- "cleanup after object resize"
-
- self invertOutlineOf:(actionData object).
+ "cleanup after object resize
+ "
+ |object|
+
+ object := actionData object.
+ actionData := nil.
+
+ self invertOutlineOf:object.
self setDefaultActions.
- super select:(actionData object).
+ self elementChangedSize:object.
+ super select:object.
self changed:#layout.
- actionData := nil
!
startResizeBorder:b of:selection
@@ -700,11 +690,6 @@
|object|
object := self singleSelection.
-
- (object geometryLayout) isNil ifTrue:[
- ^ self setDefaultActions.
- ].
-
self actionResize:object selector:b.
self transaction:#extent selectionDo:[:aView|
@@ -719,45 +704,54 @@
!UIObjectView methodsFor:'private handles'!
-handlesOf:aComponent do:aBlock
- |delta layout vertical horizontal|
-
- layout := aComponent geometryLayout.
- delta := (aComponent originRelativeTo:self) - aComponent origin.
-
- (layout isLayout not or:[layout isLayoutFrame]) ifTrue:[
- vertical := self isVerticalResizable:aComponent.
- horizontal := self isHorizontalResizable:aComponent.
- ] ifFalse:[
- vertical := false.
- horizontal := false.
- ].
-
- horizontal ifTrue:[
- aBlock value:(aComponent leftCenter + delta) value:#left.
- aBlock value:(aComponent rightCenter + delta) value:#right.
+handlesOf:aView do:aBlock
+ |dlta type v h|
+
+ dlta := (aView originRelativeTo:self) - aView origin.
+ type := self class layoutType:aView.
+
+ (type == #LayoutFrame or:[type == #Rectangle]) ifTrue:[
+ v := self isVerticalResizable:aView.
+ h := self isHorizontalResizable:aView.
+
+ h ifTrue:[ aBlock value:(aView leftCenter + dlta) value:#left.
+ aBlock value:(aView rightCenter + dlta) value:#right.
+ ].
+ v ifTrue:[ aBlock value:(aView topCenter + dlta) value:#top.
+ aBlock value:(aView bottomCenter + dlta) value:#bottom.
+ ].
+
+ (h and:[v]) ifTrue:[
+ aBlock value:(aView origin + dlta) value:#origin.
+ aBlock value:(aView topRight + dlta) value:#topRight.
+ aBlock value:(aView bottomLeft + dlta) value:#bottomLeft.
+ aBlock value:(aView corner + dlta) value:#corner.
+ ^ self
+ ]
].
- vertical ifTrue:[
- aBlock value:(aComponent topCenter + delta) value:#top.
- aBlock value:(aComponent bottomCenter + delta) value:#bottom.
+ aBlock value:(aView origin + dlta) value:#view.
+ aBlock value:(aView topRight + dlta) value:#view.
+ aBlock value:(aView bottomLeft + dlta) value:#view.
+
+ type == #Extent ifTrue:[
+ v := self isVerticalResizable:aView.
+ h := self isHorizontalResizable:aView.
+
+ v ifTrue:[aBlock value:(aView bottomCenter + dlta) value:#bottom].
+ h ifTrue:[aBlock value:(aView rightCenter + dlta) value:#right ].
+
+ (h and:[v]) ifTrue:[
+ aBlock value:(aView corner + dlta) value:#corner.
+ ^ self
+ ]
].
-
- (horizontal and:[vertical]) ifTrue:[
- aBlock value:(aComponent origin + delta) value:#origin.
- aBlock value:(aComponent corner + delta) value:#corner.
- aBlock value:(aComponent topRight + delta) value:#topRight.
- aBlock value:(aComponent bottomLeft + delta) value:#bottomLeft.
- ] ifFalse:[
- aBlock value:(aComponent origin + delta) value:#view.
- aBlock value:(aComponent corner + delta) value:#view.
- aBlock value:(aComponent topRight + delta) value:#view.
- aBlock value:(aComponent bottomLeft + delta) value:#view.
- ].
-
+ aBlock value:(aView corner + dlta) value:#view.
!
showSelected:aComponent
+ "show object selected
+ "
|wasClipped delta oldPaint|
self paint:Color black.
@@ -778,6 +772,8 @@
!
showUnselected:aComponent
+ "show object unselected
+ "
|wasClipped delta r oldPaint|
r := aComponent origin extent:8@8.
@@ -817,6 +813,8 @@
!
whichHandleOf:aView isHitBy:aPoint
+ "returns kind of handle or nil
+ "
|bounds|
self handlesOf:aView do:[:pnt :what |
@@ -834,14 +832,16 @@
!UIObjectView methodsFor:'private resizing-subviews'!
resize:aView bottom:aPoint
-
+ "resize a views bottom
+ "
undoHistory disabledTransitionDo:[
self shiftLayout:aView top:0 bottom:((aPoint y) - (aView computeCorner y))
]
!
resize:aView bottomLeft:aPoint
-
+ "resize a views bottom and left
+ "
undoHistory disabledTransitionDo:[
self shiftLayout:aView top:0
bottom:((aPoint y) - (aView computeCorner y))
@@ -854,6 +854,8 @@
!
resize:aView corner:aPoint
+ "resize a views corner
+ "
|delta|
delta := aPoint - aView computeCorner.
@@ -864,7 +866,8 @@
!
resize:aView left:aPoint
-
+ "resize a views left
+ "
undoHistory disabledTransitionDo:[
self shiftLayout:aView left:((aPoint x) - (aView computeOrigin x)) right:0
]
@@ -872,6 +875,8 @@
!
resize:aView origin:aPoint
+ "resize a views origin
+ "
|delta|
delta := aPoint - aView computeOrigin.
@@ -883,21 +888,24 @@
!
resize:aView right:aPoint
-
+ "resize a views right
+ "
undoHistory disabledTransitionDo:[
self shiftLayout:aView left:0 right:((aPoint x) - (aView computeCorner x))
]
!
resize:aView top:aPoint
-
+ "resize a views top
+ "
undoHistory disabledTransitionDo:[
self shiftLayout:aView top:((aPoint y) - (aView computeOrigin y)) bottom:0
]
!
resize:aView topRight:aPoint
-
+ "resize a views top and right
+ "
undoHistory disabledTransitionDo:[
self shiftLayout:aView top:((aPoint y) - (aView computeOrigin y))
bottom:0
@@ -931,30 +939,39 @@
"shift layout for a view; in case of an open transaction, the undo
action is registered
"
- |layout|
-
- layout := aView geometryLayout.
-
- self undoLayoutView:aView.
-
- layout isLayout ifTrue:[
- layout leftOffset:(layout leftOffset + l)
- topOffset:(layout topOffset + t).
-
- layout isLayoutFrame ifTrue:[
- layout bottomOffset:(layout bottomOffset + b).
- layout rightOffset:(layout rightOffset + r).
+ |type layout|
+
+ type := self class layoutType:aView.
+
+ type notNil ifTrue:[
+ self undoLayoutView:aView.
+
+ type == #Extent ifTrue:[
+ ^ aView geometryLayout:layout
].
- aView geometryLayout:layout.
- ] ifFalse:[
- |pixelOrigin|
-
- pixelOrigin := aView pixelOrigin.
- pixelOrigin := pixelOrigin + (l@t).
- aView pixelOrigin:pixelOrigin
+
+ layout := aView geometryLayout.
+
+ layout isLayout ifTrue:[
+ layout leftOffset:(layout leftOffset + l)
+ topOffset:(layout topOffset + t).
+
+ type == #LayoutFrame ifTrue:[
+ layout bottomOffset:(layout bottomOffset + b).
+ layout rightOffset:(layout rightOffset + r).
+ ]
+ ] ifFalse:[
+ type == #Rectangle ifTrue:[
+ layout left:(layout left + l)
+ right:(layout right + r)
+ top:(layout top + t)
+ bottom:(layout bottom + b).
+ ] ifFalse:[ "POINT"
+ layout x:(layout x + l) y:(layout y + t).
+ ]
+ ].
+ aView geometryLayout:layout
]
-
-
! !
!UIObjectView methodsFor:'searching'!
@@ -1047,6 +1064,8 @@
!UIObjectView methodsFor:'selections'!
addToSelection:something
+ "add something to selection
+ "
(self canSelect:something) ifTrue:[
super addToSelection:something.
self changed:#selection.
@@ -1054,14 +1073,16 @@
!
inspectSelection
+ "inspect selection
+ "
self singleSelectionDo:[:aView |
aView inspect
]
!
numberOfSelections
- "return the number of selected entries"
-
+ "return the number of selected entries
+ "
|sz|
selection isNil ifTrue:[^ 0].
@@ -1071,12 +1092,16 @@
!
removeFromSelection:something
+ "remove something from selection
+ "
super removeFromSelection:something.
self changed:#selection
!
select:something
+ "change selection to something
+ "
(self canSelect:something) ifTrue:[
super select:something.
self changed:#selection
@@ -1085,24 +1110,17 @@
!
selection
+ "returns selection
+ "
^ selection
!
-selectionHiddenDo:aBlock
- "apply block to every object in selection"
-
- self selectionDo:[:aView |
- self showUnselected:aView.
+showSelection
+ selectionHiddenLevel == 0 ifTrue:[
+ super showSelection.
].
- device flush.
- aBlock value.
- self selectionDo:[:aView |
- self showSelected:aView
- ]
-
-
!
singleSelection
@@ -1116,6 +1134,8 @@
!
singleSelectionDo:aBlock
+ "perform block with argument a view in case of one selection
+ "
|view|
(view := self singleSelection) notNil ifTrue:[
@@ -1124,6 +1144,8 @@
!
unselect
+ "clear selection
+ "
selection notNil ifTrue:[
super unselect.
self changed:#selection
@@ -1132,8 +1154,33 @@
!
withSelectionHiddenDo:aBlock
- "evaluate aBlock while selection is hidden"
-
+ "apply block with selection hidden (no handles)
+ "
+ selectionHiddenLevel := selectionHiddenLevel + 1.
+
+ selectionHiddenLevel == 1 ifTrue:[
+ self selectionDo:[:aView| self showUnselected:aView].
+ device flush.
+ ].
+
+ aBlock valueNowOrOnUnwindDo:[
+ selectionHiddenLevel == 1 ifTrue:[
+ setOfSuperViewsSizeChanged notEmpty ifTrue:[
+ setOfSuperViewsSizeChanged do:[:aSuperView|
+ aSuperView sizeChanged:nil
+ ].
+ setOfSuperViewsSizeChanged := IdentitySet new
+ ].
+ self selectionDo:[:aView| self showSelected:aView].
+ ].
+ selectionHiddenLevel := selectionHiddenLevel - 1.
+ ]
+
+!
+
+withoutSelectionDo:aBlock
+ "evaluate aBlock while selection is nilled
+ "
|sel|
selection isNil ifTrue:[
@@ -1145,16 +1192,28 @@
super select:sel
]
- "Modified: 6.9.1995 / 01:46:16 / claus"
-
! !
!UIObjectView methodsFor:'testing'!
canMove:something
- ^ true
-
+ "returns always true; all contained views can be moved
+ "
+ |sv|
+
+ something notNil ifTrue:[
+ self forEach:something do:[:v|
+ sv ~~ v superView ifTrue:[
+ (sv notNil or:[v superView specClass isLayoutContainer]) ifTrue:[
+ ^ false
+ ].
+ sv := v superView
+ ]
+ ].
+ ^ true
+ ].
+ ^ false
!
@@ -1174,7 +1233,23 @@
!
+canPasteInto:something
+ "can paste into something ?
+ "
+ something notNil ifTrue:[
+ something isCollection ifFalse:[
+ ^ something specClass supportsSubComponents
+ ].
+ something size == 1 ifTrue:[
+ ^ (something at:1) specClass supportsSubComponents
+ ]
+ ].
+ ^ false
+!
+
canSelect:something
+ "returns true if something can be selected and testMode is disabled
+ "
^ (testMode not and:[something ~~ selection])
!
@@ -1186,35 +1261,19 @@
!
isHorizontalResizable:aComponent
+ "returns true if instance is horizontal resizeable
+ "
^ self subclassResponsibility
!
isVerticalResizable:aComponent
- ^ self subclassResponsibility
-
-
-!
-
-supportsSubComponents:something
- "returns true if somrthing supports subcomponents
+ "returns true if instance is vertical resizeable
"
- |specClass|
-
- something notNil ifTrue:[
- something isCollection ifFalse:[
- specClass := something specClass
- ] ifTrue:[
- something size == 1 ifTrue:[
- specClass := (something at:1) specClass
- ]
- ].
- specClass notNil ifTrue:[
- ^ specClass basicNew supportsSubComponents
- ]
- ].
- ^ false
+ ^ self subclassResponsibility
+
+
! !
!UIObjectView methodsFor:'transaction'!
@@ -1247,12 +1306,16 @@
!UIObjectView methodsFor:'user actions - arrange'!
lowerSelection
+ "lower all objects in the selection
+ "
self selectionDo:[:aView| aView lower ].
!
raiseSelection
+ "raise all objects in the selection
+ "
self selectionDo:[:aView| aView raise ].
inputView raise.
@@ -1262,6 +1325,8 @@
!UIObjectView methodsFor:'user actions - dimension'!
copyExtent
+ "copy the extent from the selected object
+ "
|object|
object := self singleSelection.
@@ -1277,6 +1342,8 @@
!
pasteExtent
+ "paste the copied extent to all objects in the selection
+ "
copiedExtent notNil ifTrue:[
self transition:#extent dimensionDo:[:v|
self resize:v corner:(v computeOrigin + copiedExtent)
@@ -1285,6 +1352,8 @@
!
pasteHeight
+ "paste the copied extent height to all objects in the selection
+ "
copiedExtent notNil ifTrue:[
self transition:'paste height' dimensionDo:[:v|
self resize:v bottom:(v computeOrigin + copiedExtent)
@@ -1294,6 +1363,8 @@
!
pasteWidth
+ "paste the copied extent width to all objects in the selection
+ "
copiedExtent notNil ifTrue:[
self transition:'paste width' dimensionDo:[:v|
self resize:v right:(v computeOrigin + copiedExtent)
@@ -1303,27 +1374,25 @@
!
setDimension:aLayout
- |type|
-
- aLayout isLayout ifTrue:[
- aLayout isLayoutFrame ifTrue:[
- type := #layoutFrame
- ] ifFalse:[
- aLayout isAlignmentOrigin ifTrue:[
- type := #layoutAlignOrigin.
- ] ifFalse:[
- type := #layoutOrigin
- ]
- ]
- ] ifFalse:[
- type := #layout
- ].
-
- self transition:type dimensionDo:[:v| v geometryLayout:(aLayout copy)]
-
+ "change layout for all selected objects
+ "
+ self transition:#layout dimensionDo:[:v|
+ v geometryLayout:(aLayout copy)
+ ].
+
+!
+
+setExtent:anExtent
+ "change extent for all selected objects
+ "
+ self transition:#layout dimensionDo:[:v|
+ v extent:anExtent.
+ ].
!
setToDefaultExtent
+ "change extent of all selected views to their default extent
+ "
self transition:#extent dimensionDo:[:v|
self resize:v corner:(v computeOrigin + (v preferredExtent))
]
@@ -1331,6 +1400,8 @@
!
setToDefaultHeight
+ "change height of all selected views to their default height
+ "
self transition:'default height' dimensionDo:[:v|
self resize:v bottom:(v computeOrigin + (v preferredExtent))
]
@@ -1338,6 +1409,8 @@
!
setToDefaultWidth
+ "change width of all selected views to their default width
+ "
self transition:'default width' dimensionDo:[:v|
self resize:v right:(v computeOrigin + (v preferredExtent))
]
@@ -1348,44 +1421,49 @@
"change dimension within a transaction for the selected elements by evaluating
the block with the argument a view.
"
- self selectionHiddenDo:[
+ self withSelectionHiddenDo:[
self transaction:aType selectionDo:[:aView|
- self undoLayoutView:aView.
- aOneArgBlock value:aView.
- ].
- self changed:#layout
- ]
+ (self class layoutType:aView) notNil ifTrue:[
+ self undoLayoutView:aView.
+ aOneArgBlock value:aView.
+ self elementChangedSize:aView.
+ ]
+ ]
+ ].
+ self changed:#layout
+
! !
!UIObjectView methodsFor:'user actions - move'!
moveSelectionDown:aNumber
+ "move selection down
+ "
|gridY|
- gridAlign notNil ifTrue:[
- gridY := gridAlign y.
- ].
-
- self selectionHiddenDo:[
- self transaction:#move selectionDo:[:aView|
- |n d|
-
- n := aNumber.
-
- aligning ifTrue:[
- d := ((aView computeCorner y) \\ gridY).
- n := n * gridY.
-
- d ~~ 0 ifTrue:[
- n := n - d + 1.
- ]
- ].
- self shiftLayout:aView top:n bottom:n
+ (self canMove:selection) ifTrue:[
+ gridAlign notNil ifTrue:[gridY := gridAlign y].
+
+ self withSelectionHiddenDo:[
+ self transaction:#move selectionDo:[:aView|
+ |n d|
+
+ n := aNumber.
+
+ aligning ifTrue:[
+ d := ((aView computeCorner y) \\ gridY).
+ n := n * gridY.
+
+ d ~~ 0 ifTrue:[
+ n := n - d + 1.
+ ]
+ ].
+ self shiftLayout:aView top:n bottom:n
+ ]
].
self changed:#layout
]
-
!
moveSelectionLeft:aNumber
@@ -1393,26 +1471,25 @@
"
|gridX|
- gridAlign notNil ifTrue:[
- gridX := gridAlign x.
- ].
-
- self selectionHiddenDo:[
- self transaction:#move selectionDo:[:aView|
- |n d|
-
- n := aNumber.
-
- aligning ifTrue:[
- d := ((aView computeOrigin x) \\ gridX).
- d ~~ 0 ifTrue:[
- n := n-1.
+ (self canMove:selection) ifTrue:[
+ gridAlign notNil ifTrue:[gridX := gridAlign x].
+
+ self withSelectionHiddenDo:[
+ self transaction:#move selectionDo:[:aView|
+ |n d|
+
+ n := aNumber.
+
+ aligning ifTrue:[
+ d := ((aView computeOrigin x) \\ gridX).
+ d ~~ 0 ifTrue:[
+ n := n-1.
+ ].
+ n := (n * gridX) + d.
].
- n := (n * gridX) + d.
- ].
- n := n negated.
- self shiftLayout:aView left:n right:n
-
+ n := n negated.
+ self shiftLayout:aView left:n right:n
+ ]
].
self changed:#layout
]
@@ -1423,26 +1500,25 @@
"
|gridX|
- gridAlign notNil ifTrue:[
- gridX := gridAlign x.
- ].
-
- self selectionHiddenDo:[
- self transaction:#move selectionDo:[:aView|
- |n d|
-
- n := aNumber.
-
- aligning ifTrue:[
- d := ((aView computeCorner x) \\ gridX).
- n := n * gridX.
-
- d ~~ 0 ifTrue:[
- n := n - d + 1.
- ]
- ].
- self shiftLayout:aView left:n right:n
-
+ (self canMove:selection) ifTrue:[
+ gridAlign notNil ifTrue:[gridX := gridAlign x].
+
+ self withSelectionHiddenDo:[
+ self transaction:#move selectionDo:[:aView|
+ |n d|
+
+ n := aNumber.
+
+ aligning ifTrue:[
+ d := ((aView computeCorner x) \\ gridX).
+ n := n * gridX.
+
+ d ~~ 0 ifTrue:[
+ n := n - d + 1.
+ ]
+ ].
+ self shiftLayout:aView left:n right:n
+ ]
].
self changed:#layout
]
@@ -1453,39 +1529,41 @@
"
|gridY|
- gridAlign notNil ifTrue:[
- gridY := gridAlign y.
- ].
-
- self selectionHiddenDo:[
- self transaction:#move selectionDo:[:aView|
- |n d|
-
- n := aNumber.
-
- aligning ifTrue:[
- d := ((aView computeOrigin x) \\ gridY).
- d ~~ 0 ifTrue:[
- n := n-1.
+ (self canMove:selection) ifTrue:[
+ gridAlign notNil ifTrue:[gridY := gridAlign y].
+
+ self withSelectionHiddenDo:[
+ self transaction:#move selectionDo:[:aView|
+ |n d|
+
+ n := aNumber.
+
+ aligning ifTrue:[
+ d := ((aView computeOrigin x) \\ gridY).
+ d ~~ 0 ifTrue:[
+ n := n-1.
+ ].
+ n := (n * gridY) + d.
].
- n := (n * gridY) + d.
- ].
- n := n negated.
- self shiftLayout:aView top:n bottom:n
+ n := n negated.
+ self shiftLayout:aView top:n bottom:n
+ ]
].
self changed:#layout
]
-
! !
!UIObjectView methodsFor:'user actions - position'!
alignSelectionBottom
+ "align selection to the bottom of the first object in the selection; in case
+ of one selection the object is aligned to the bottom of its superview
+ "
|bmost delta layout|
- selection notNil ifTrue:[
- self selectionHiddenDo:[
+ (self canMove:selection) ifTrue:[
+ self withSelectionHiddenDo:[
self numberOfSelections > 1 ifTrue:[
bmost := (selection at:1) computeCorner y.
@@ -1497,16 +1575,14 @@
] ifFalse:[
layout := selection geometryLayout.
- (layout isLayout and:[layout isLayoutFrame]) ifFalse:[
- ^ self
- ].
-
- self transaction:#layout selectionDo:[:aView|
- self undoLayoutView:aView.
- layout := aView geometryLayout.
- layout bottomOffset:0.
- layout bottomFraction:1.0.
- aView geometryLayout:layout.
+ (layout isLayout and:[layout isLayoutFrame]) ifTrue:[
+ self transaction:#layout selectionDo:[:aView|
+ self undoLayoutView:aView.
+ layout := aView geometryLayout.
+ layout bottomOffset:0.
+ layout bottomFraction:1.0.
+ aView geometryLayout:layout.
+ ]
]
]
].
@@ -1518,10 +1594,13 @@
!
alignSelectionCenterHor
+ "align selection to the center/horizontal of the first object in the selection; in case
+ of one selection the object is aligned to the center/horizontal of its superview
+ "
|view center|
- selection notNil ifTrue:[
- self selectionHiddenDo:[
+ (self canMove:selection) ifTrue:[
+ self withSelectionHiddenDo:[
view := self singleSelection.
view notNil ifTrue:[
@@ -1541,9 +1620,9 @@
delta := newX - oldX.
self shiftLayout:v left:delta right:delta
- ].
- self changed:#layout
- ]
+ ]
+ ].
+ self changed:#layout
]
@@ -1551,10 +1630,13 @@
!
alignSelectionCenterVer
+ "align selection to the center/vertical of the first object in the selection; in case
+ of one selection the object is aligned to the center/vertical of its superview
+ "
|view center|
- selection notNil ifTrue:[
- self selectionHiddenDo:[
+ (self canMove:selection) ifTrue:[
+ self withSelectionHiddenDo:[
view := self singleSelection.
view notNil ifTrue:[
@@ -1574,17 +1656,20 @@
delta := newY - oldY.
self shiftLayout:v top:delta bottom:delta
- ].
- self changed:#layout
- ]
+ ]
+ ].
+ self changed:#layout
]
!
alignSelectionLeft
+ "align selection to the left of the first object in the selection; in case
+ of one selection the object is aligned to the left of its superview
+ "
|lmost delta layout|
- selection notNil ifTrue:[
- self selectionHiddenDo:[
+ (self canMove:selection) ifTrue:[
+ self withSelectionHiddenDo:[
self numberOfSelections > 1 ifTrue:[
lmost := (selection at:1) computeOrigin x.
@@ -1611,17 +1696,22 @@
!
alignSelectionLeftAndRight
+ "align selection to the left/right of the first object in the selection; in case
+ of one selection the object is aligned to the left/right of its superview
+ "
|lmost rmost layout|
- selection notNil ifTrue:[
- self selectionHiddenDo:[
+ (self canMove:selection) ifTrue:[
+ self withSelectionHiddenDo:[
self numberOfSelections > 1 ifTrue:[
lmost := (selection at:1) computeOrigin x.
rmost := (selection at:1) computeCorner x.
self transaction:#align selectionDo:[:v|
self shiftLayout:v left:(lmost - (v computeOrigin x))
- right:(rmost - (v computeCorner x))
+ right:(rmost - (v computeCorner x)).
+
+ self elementChangedSize:v.
]
] ifFalse:[
self transaction:#layout selectionDo:[:aView|
@@ -1637,19 +1727,24 @@
layout rightFraction:1.0.
].
aView geometryLayout:layout.
+ self elementChangedSize:aView.
]
]
]
].
self changed:#layout
- ]
+ ].
+
!
alignSelectionRight
+ "align selection to the right of the first object in the selection; in case
+ of one selection the object is aligned to the right of its superview
+ "
|rmost delta layout|
- selection notNil ifTrue:[
- self selectionHiddenDo:[
+ (self canMove:selection) ifTrue:[
+ self withSelectionHiddenDo:[
self numberOfSelections > 1 ifTrue:[
rmost := (selection at:1) computeCorner x.
@@ -1661,16 +1756,14 @@
] ifFalse:[
layout := selection geometryLayout.
- (layout isLayout and:[layout isLayoutFrame]) ifFalse:[
- ^ self
- ].
-
- self transaction:#layout selectionDo:[:aView|
- self undoLayoutView:aView.
- layout := aView geometryLayout.
- layout rightOffset:0.
- layout rightFraction:1.0.
- aView geometryLayout:layout.
+ (layout isLayout and:[layout isLayoutFrame]) ifTrue:[
+ self transaction:#layout selectionDo:[:aView|
+ self undoLayoutView:aView.
+ layout := aView geometryLayout.
+ layout rightOffset:0.
+ layout rightFraction:1.0.
+ aView geometryLayout:layout.
+ ]
]
]
].
@@ -1679,10 +1772,13 @@
!
alignSelectionTop
+ "align selection to the top of the first object in the selection; in case
+ of one selection the object is aligned to the top of its superview
+ "
|tmost delta layout|
- selection notNil ifTrue:[
- self selectionHiddenDo:[
+ (self canMove:selection) ifTrue:[
+ self withSelectionHiddenDo:[
self numberOfSelections > 1 ifTrue:[
tmost := (selection at:1) computeOrigin y.
@@ -1710,20 +1806,24 @@
!
alignSelectionTopAndBottom
+ "align selection to the top/bottom of the first object in the selection; in case
+ of one selection the object is aligned to the top/bottom of its superview
+ "
|tmost bmost layout|
- selection notNil ifTrue:[
- self selectionHiddenDo:[
+ (self canMove:selection) ifTrue:[
+ self withSelectionHiddenDo:[
self numberOfSelections > 1 ifTrue:[
tmost := (selection at:1) computeOrigin y.
bmost := (selection at:1) computeCorner y.
self transaction:#align selectionDo:[:v|
self shiftLayout:v top:(tmost - (v computeOrigin y))
- bottom:(bmost - (v computeCorner y))
+ bottom:(bmost - (v computeCorner y)).
+ self elementChangedSize:v.
]
] ifFalse:[
- self transaction:#layout selectionDo:[:aView|
+ self transaction:#align selectionDo:[:aView|
layout := aView geometryLayout.
layout isLayout ifTrue:[
@@ -1736,7 +1836,15 @@
layout bottomFraction:1.0.
].
aView geometryLayout:layout.
- ]
+ ] ifFalse:[
+ |y x|
+
+ self undoLayoutView:aView.
+ x := aView extent x.
+ y := aView superView extent y.
+ aView extent:(x @ y)
+ ].
+ self elementChangedSize:aView.
]
]
].
@@ -1744,13 +1852,44 @@
]
!
+alignSingleSelection:aBlock
+
+ |type layout|
+
+ self withSelectionHiddenDo:[
+ self transaction:#align selectionDo:[:aView|
+ type := self class layoutType:aView.
+
+ type notNil ifTrue:[
+ self undoLayoutView:aView.
+
+ layout := aView layout.
+
+ type == #LayoutFrame ifFalse:[
+ layout := aView bounds asLayout
+ ].
+ aBlock value:layout.
+ aView geometryLayout:layout.
+ ]
+ ]
+ ].
+ self changed:#layout
+
+
+
+!
+
centerSelection:aOneArgBlockXorY orientation:orientation
"center selection horizontal or vertical dependant on the block result( x or y).
The argument to the block is the point.
"
|superview min max delta val|
- self selectionHiddenDo:[
+ (self canMove:selection) ifFalse:[
+ ^ self
+ ].
+
+ self withSelectionHiddenDo:[
max := 0.
self selectionDo:[:aView |
@@ -1782,9 +1921,9 @@
] ifFalse:[
self shiftLayout:v left:delta right:delta
]
- ].
- self changed:#layout
- ]
+ ]
+ ].
+ self changed:#layout
]
@@ -1805,13 +1944,15 @@
!
spreadSelectionHor
+ "spread multiple selection horizontal
+ "
|sumWidths min max viewsInOrder topsInOrder count space|
- (self numberOfSelections > 1) ifFalse:[
+ (self numberOfSelections > 1 and:[self canMove:selection]) ifFalse:[
^ self
].
- self selectionHiddenDo:[
+ self withSelectionHiddenDo:[
count := 0.
sumWidths := 0.
max := 0.
@@ -1837,20 +1978,22 @@
delta := min - aView computeOrigin x.
self shiftLayout:aView left:delta right:delta.
min := min + aView computeExtent x + space
- ].
- self changed:#layout
- ]
+ ]
+ ].
+ self changed:#layout
!
spreadSelectionVer
+ "spread multiple selection vertical
+ "
|sumHeights min max viewsInOrder topsInOrder count space|
- (self numberOfSelections > 1) ifFalse:[
+ (self numberOfSelections > 1 and:[self canMove:selection]) ifFalse:[
^ self
].
- self selectionHiddenDo:[
+ self withSelectionHiddenDo:[
count := 0.
sumHeights := 0.
max := 0.
@@ -1876,16 +2019,21 @@
delta := min - aView computeOrigin y.
self shiftLayout:aView top:delta bottom:delta.
min := min + aView height + space
- ].
- self changed:#layout
- ]
+ ]
+ ].
+ self changed:#layout
! !
!UIObjectView methodsFor:'user actions - undo history'!
openUndoMenu
+ "open undo menu
+ "
self unselect.
- undoHistory openUndoMenu.
+
+ self withSelectionHiddenDo:[
+ undoHistory openUndoMenu
+ ].
self changed:#tree
!
@@ -1897,8 +2045,13 @@
!
undoLast
+ "undo last action
+ "
self unselect.
- undoHistory undoLast:1.
+
+ self withSelectionHiddenDo:[
+ undoHistory undoLast:1
+ ].
self changed:#tree
! !