--- a/UIObjectView.st Sat Mar 01 13:43:01 1997 +0100
+++ b/UIObjectView.st Sat Mar 01 13:44:39 1997 +0100
@@ -392,6 +392,27 @@
!
+minSetOfSuperViews:aCollectionOfViews
+ |setOfViews setOfSuperViews|
+
+ aCollectionOfViews isCollection ifFalse:[
+ ^ aCollectionOfViews
+ ].
+
+ setOfViews := aCollectionOfViews asIdentitySet.
+
+ setOfSuperViews := setOfViews select:[:aView|
+ (setOfViews detect:[:v|aView isComponentOf:v]
+ ifNone:nil
+ ) isNil
+ ].
+
+ setOfSuperViews size == 1 ifTrue:[
+ ^ setOfSuperViews first
+ ].
+ ^ setOfSuperViews asOrderedCollection
+!
+
setDefaultActions
"set default actions
"
@@ -694,7 +715,7 @@
"
motionAction := [:movePoint|
- (aPoint dist:movePoint) > 4.0 ifTrue:[
+ (aPoint dist:movePoint) > 8.0 ifTrue:[
self startObjectMoveAt:aPoint
]
].
@@ -761,7 +782,7 @@
object := self singleSelection.
self actionResize:object selector:b.
- self transaction:#extent selectionDo:[:aView|
+ self transaction:#resize selectionDo:[:aView|
self undoLayoutView:aView
].
super unselect.
@@ -1235,8 +1256,13 @@
aBlock valueNowOrOnUnwindDo:[
selectionHiddenLevel == 1 ifTrue:[
setOfSuperViewsSizeChanged notEmpty ifTrue:[
- setOfSuperViewsSizeChanged do:[:aSuperView|
- aSuperView sizeChanged:nil
+ |s|
+ s := self minSetOfSuperViews:setOfSuperViewsSizeChanged.
+
+ s isCollection ifTrue:[
+ s do:[:aSuperView|aSuperView sizeChanged:nil]
+ ] ifFalse:[
+ s sizeChanged:nil
].
setOfSuperViewsSizeChanged := IdentitySet new
].
@@ -1414,7 +1440,7 @@
"paste the copied extent to all objects in the selection
"
copiedExtent notNil ifTrue:[
- self transition:#extent dimensionDo:[:v|
+ self transition:#pasteExtent dimensionDo:[:v|
self resize:v corner:(v computeOrigin + copiedExtent)
]
]
@@ -1424,7 +1450,7 @@
"paste the copied extent height to all objects in the selection
"
copiedExtent notNil ifTrue:[
- self transition:'paste height' dimensionDo:[:v|
+ self transition:#pasteHeight dimensionDo:[:v|
self resize:v bottom:(v computeOrigin + copiedExtent)
]
]
@@ -1435,7 +1461,7 @@
"paste the copied extent width to all objects in the selection
"
copiedExtent notNil ifTrue:[
- self transition:'paste width' dimensionDo:[:v|
+ self transition:#pasteWidth dimensionDo:[:v|
self resize:v right:(v computeOrigin + copiedExtent)
]
]
@@ -1454,7 +1480,7 @@
setExtent:anExtent
"change extent for all selected objects
"
- self transition:#layout dimensionDo:[:v|
+ self transition:#extent dimensionDo:[:v|
v geometryLayout:nil.
v extent:anExtent.
].
@@ -1465,7 +1491,7 @@
setToDefaultExtent
"change extent of all selected views to their default extent
"
- self transition:#extent dimensionDo:[:v|
+ self transition:#defaultExtent dimensionDo:[:v|
self resize:v corner:(v computeOrigin + (v preferredExtent))
]
@@ -1474,7 +1500,7 @@
setToDefaultHeight
"change height of all selected views to their default height
"
- self transition:'default height' dimensionDo:[:v|
+ self transition:#defaultHeight dimensionDo:[:v|
self resize:v bottom:(v computeOrigin + (v preferredExtent))
]
@@ -1483,7 +1509,7 @@
setToDefaultWidth
"change width of all selected views to their default width
"
- self transition:'default width' dimensionDo:[:v|
+ self transition:#defaultWidth dimensionDo:[:v|
self resize:v right:(v computeOrigin + (v preferredExtent))
]
@@ -1517,7 +1543,7 @@
gridAlign notNil ifTrue:[gridY := gridAlign y].
self withSelectionHiddenDo:[
- self transaction:#move selectionDo:[:aView|
+ self transaction:#moveDown selectionDo:[:aView|
|n d|
n := aNumber.
@@ -1547,7 +1573,7 @@
gridAlign notNil ifTrue:[gridX := gridAlign x].
self withSelectionHiddenDo:[
- self transaction:#move selectionDo:[:aView|
+ self transaction:#moveLeft selectionDo:[:aView|
|n d|
n := aNumber.
@@ -1576,7 +1602,7 @@
gridAlign notNil ifTrue:[gridX := gridAlign x].
self withSelectionHiddenDo:[
- self transaction:#move selectionDo:[:aView|
+ self transaction:#moveRight selectionDo:[:aView|
|n d|
n := aNumber.
@@ -1605,7 +1631,7 @@
gridAlign notNil ifTrue:[gridY := gridAlign y].
self withSelectionHiddenDo:[
- self transaction:#move selectionDo:[:aView|
+ self transaction:#moveUp selectionDo:[:aView|
|n d|
n := aNumber.
@@ -1628,23 +1654,6 @@
!UIObjectView methodsFor:'user actions - position'!
-alignFrameLayout:aBlock
- "perform block on a frameLayout assigned to the current single selection
- "
- |layout|
-
- self transaction:#align selectionDo:[:aView|
- layout := self class asLayoutFrameFromView:aView.
-
- layout notNil ifTrue:[
- self undoLayoutView:aView.
- aBlock value:layout.
- aView geometryLayout:layout.
- self elementChangedSize:aView.
- ]
- ]
-!
-
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
@@ -1656,13 +1665,13 @@
self numberOfSelections > 1 ifTrue:[
bmost := (selection at:1) computeCorner y.
- self transaction:#align selectionDo:[:v|
+ self transaction:#alignBottom selectionDo:[:v|
(delta := bmost - (v computeCorner y)) ~~ 0 ifTrue:[
self shiftLayout:v top:delta bottom:delta.
]
]
] ifFalse:[
- self alignFrameLayout:[:aLayout|
+ self extentToFrame:#Bottom do:[:aLayout|
aLayout bottomOffset:0.
aLayout bottomFraction:1.0
]
@@ -1694,7 +1703,7 @@
].
center := center x // 2.
- self transaction:#align selectionDo:[:v|
+ self transaction:#alignCenterHorizontal selectionDo:[:v|
|newX oldX delta|
oldX := v computeOrigin x.
@@ -1730,7 +1739,7 @@
].
center := center y // 2.
- self transaction:#align selectionDo:[:v|
+ self transaction:#alignCenterVertical selectionDo:[:v|
|newY oldY delta|
oldY := v computeOrigin y.
@@ -1755,13 +1764,13 @@
self numberOfSelections > 1 ifTrue:[
lmost := (selection at:1) computeOrigin x.
- self transaction:#align selectionDo:[:v|
+ self transaction:#alignLeft selectionDo:[:v|
(delta := lmost - (v computeOrigin x)) ~~ 0 ifTrue:[
self shiftLayout:v left:delta right:delta
]
]
] ifFalse:[
- self alignFrameLayout:[:aLayout|
+ self extentToFrame:#Left do:[:aLayout|
aLayout leftOffset:0.
aLayout leftFraction:0.0.
]
@@ -1783,14 +1792,23 @@
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)).
-
- self elementChangedSize:v.
+ self transaction:#alignLeftRight selectionDo:[:aView|
+ |layout|
+ layout := self class asLayoutFrameFromView:aView.
+
+ layout notNil ifTrue:[
+ self undoLayoutView:aView.
+ aView geometryLayout:layout.
+
+ undoHistory disabledTransitionDo:[
+ self shiftLayout:aView left:(lmost - (aView computeOrigin x))
+ right:(rmost - (aView computeCorner x)).
+ ].
+ self elementChangedSize:aView
+ ]
]
] ifFalse:[
- self alignFrameLayout:[:aLayout|
+ self extentToFrame:#LeftRight do:[:aLayout|
aLayout leftOffset:0.
aLayout leftFraction:0.0.
aLayout rightOffset:0.
@@ -1814,13 +1832,13 @@
self numberOfSelections > 1 ifTrue:[
rmost := (selection at:1) computeCorner x.
- self transaction:#align selectionDo:[:v|
+ self transaction:#alignRight selectionDo:[:v|
(delta := rmost - (v computeCorner x)) ~~ 0 ifTrue:[
self shiftLayout:v left:delta right:delta
]
]
] ifFalse:[
- self alignFrameLayout:[:aLayout|
+ self extentToFrame:#Right do:[:aLayout|
aLayout rightOffset:0.
aLayout rightFraction:1.0.
]
@@ -1841,13 +1859,13 @@
self numberOfSelections > 1 ifTrue:[
tmost := (selection at:1) computeOrigin y.
- self transaction:#align selectionDo:[:v|
+ self transaction:#alignTop selectionDo:[:v|
(delta := tmost - (v computeOrigin y)) ~~ 0 ifTrue:[
self shiftLayout:v top:delta bottom:delta
]
]
] ifFalse:[
- self alignFrameLayout:[:aLayout|
+ self extentToFrame:#Top do:[:aLayout|
aLayout topOffset:0.
aLayout topFraction:0.0.
]
@@ -1870,13 +1888,23 @@
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)).
- self elementChangedSize:v.
+ self transaction:#alignTopBottom selectionDo:[:aView|
+ |layout|
+ layout := self class asLayoutFrameFromView:aView.
+
+ layout notNil ifTrue:[
+ self undoLayoutView:aView.
+ aView geometryLayout:layout.
+
+ undoHistory disabledTransitionDo:[
+ self shiftLayout:aView top:(tmost - (aView computeOrigin y))
+ bottom:(bmost - (aView computeCorner y)).
+ ].
+ self elementChangedSize:aView
+ ]
]
] ifFalse:[
- self alignFrameLayout:[:aLayout|
+ self extentToFrame:#TopBottom do:[:aLayout|
aLayout topOffset:0.
aLayout topFraction:0.0.
aLayout bottomOffset:0.
@@ -1888,33 +1916,6 @@
]
!
-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.
@@ -1949,9 +1950,12 @@
max := (min + val - max) // 2.
max == min ifFalse:[
+ |type|
+ (orientation == #y) ifTrue:[type := #centerVertical]
+ ifFalse:[type := #centerHorizontal].
delta := max - min.
- self transaction:#center selectionDo:[:v|
+ self transaction:type selectionDo:[:v|
orientation == #y ifTrue:[
self shiftLayout:v top:delta bottom:delta
] ifFalse:[
@@ -1979,6 +1983,25 @@
self centerSelection:[:aPoint| aPoint y] orientation:#y
!
+extentToFrame:toWhat do:aBlock
+ "align to frame (Left Right ...) and perform the block on a frameLayout
+ "
+ |layout type|
+
+ type := ('extent', toWhat asString) asSymbol.
+
+ self transaction:type selectionDo:[:aView|
+ layout := self class asLayoutFrameFromView:aView.
+
+ layout notNil ifTrue:[
+ self undoLayoutView:aView.
+ aBlock value:layout.
+ aView geometryLayout:layout.
+ self elementChangedSize:aView.
+ ]
+ ]
+!
+
spreadSelectionHor
"spread multiple selection horizontal
"
@@ -2008,7 +2031,7 @@
space := (((max - min) - sumWidths) / (count - 1)) rounded asInteger.
- self transaction:#spread objects:viewsInOrder do:[:aView|
+ self transaction:#spreadHorizontal objects:viewsInOrder do:[:aView|
|delta|
delta := min - aView computeOrigin x.
@@ -2049,7 +2072,7 @@
space := (((max - min) - sumHeights) / (count - 1)) rounded asInteger.
- self transaction:#spread objects:viewsInOrder do:[:aView|
+ self transaction:#spreadVertical objects:viewsInOrder do:[:aView|
|delta|
delta := min - aView computeOrigin y.
@@ -2062,6 +2085,12 @@
!UIObjectView methodsFor:'user actions - undo history'!
+enableUndoHistory:aState
+ "enable or disable undo history
+ "
+ undoHistory enabled:aState
+!
+
openUndoMenu
"open undo menu
"
@@ -2112,8 +2141,27 @@
!UIObjectView::UndoHistory methodsFor:'accessing'!
+enabled
+ ^ enabled
+!
+
+enabled:aState
+ enabled := aState
+!
+
historySize
^ history size
+!
+
+lastTypeAsString
+ "returns type of last undo asString or nil
+ "
+ history notEmpty ifTrue:[
+ ^ history last typeAsString
+ ].
+ ^ nil
+
+
! !
!UIObjectView::UndoHistory methodsFor:'initialization'!
@@ -2138,7 +2186,7 @@
!UIObjectView::UndoHistory methodsFor:'menu'!
openUndoMenu
- |list top slv hzp inset selection okButton|
+ |list tabs top slv hzp inset selection okButton|
history isEmpty ifTrue:[
^ self
@@ -2159,10 +2207,16 @@
slv bottomInset:inset.
slv := slv scrolledView.
+ tabs := TabulatorSpecification new.
+ tabs unit:#cm.
+ tabs positions:#(0 5).
+ tabs align:#(#left ##left).
+
list := history collect:[:aTrans||e|
e := MultiColListEntry new.
- e colAt:1 put:(aTrans type asString).
+ e colAt:1 put:(aTrans typeAsString).
e colAt:2 put:(aTrans text ? '').
+ e tabulatorSpecification:tabs.
e
].
@@ -2279,17 +2333,6 @@
!UIObjectView::UndoHistory::Transaction methodsFor:'accessing'!
-asString
- "returns printable string
- "
- |string|
-
- string := type asString.
-
- text notNil ifTrue:[^ string, ' ', text ]
- ifFalse:[^ string ]
-!
-
text
"returns text or nil assigned to transition
"
@@ -2306,6 +2349,32 @@
"change type assigned to transition
"
type := aType
+!
+
+typeAsString
+ "returns type as printable string
+ "
+ |line name size sep|
+
+ line := type asString.
+ size := 0.
+ line do:[:c| (c isUppercase) ifTrue:[size := size+1] ].
+ name := String new:(line size + size).
+ size := 1.
+ sep := Character space.
+
+ line do:[:c|
+ (c isUppercase) ifFalse:[
+ name at:size put:c
+ ] ifTrue:[
+ name at:size put:sep.
+ sep := $&.
+ size := size + 1.
+ name at:size put:(c asLowercase)
+ ].
+ size := size + 1
+ ].
+ ^ name
! !
!UIObjectView::UndoHistory::Transaction methodsFor:'add & undo'!