--- a/UIObjectView.st Fri Feb 28 10:22:30 1997 +0100
+++ b/UIObjectView.st Fri Feb 28 12:38:52 1997 +0100
@@ -22,6 +22,51 @@
!
+!UIObjectView class methodsFor:'conversion'!
+
+asLayoutFrameFromView:aView
+ "convert layout from aView to a frameLayout. On success the frameLayout is
+ returned otherwise nil
+ "
+ |lF lO rF rO tF tO bF bO layout|
+
+ (layout := aView geometryLayout) isNil ifTrue:[
+ ^ nil
+ ].
+
+ layout isLayout ifTrue:[
+ layout isLayoutFrame ifTrue:[^ layout copy].
+
+ lF := layout leftFraction.
+ lO := layout leftOffset.
+ tF := layout topFraction.
+ tO := layout topOffset.
+ bF := tF.
+ bO := tO + aView extent y.
+ rF := lF.
+ rO := lO + aView extent x.
+ ] ifFalse:[
+ lF := rF := tF := bF := 0.
+
+ layout isRectangle ifTrue:[
+ lO := layout left.
+ tO := layout top.
+ rO := layout right.
+ bO := layout bottom.
+ ] ifFalse:[
+ layout isPoint ifFalse:[ ^ nil ].
+
+ lO := layout x.
+ tO := layout y.
+ rO := lO + aView extent x.
+ bO := tO + aView extent y.
+ ].
+ ].
+
+ ^ LayoutFrame leftFraction:lF offset:lO rightFraction:rF offset:rO
+ topFraction:tF offset:tO bottomFraction:bF offset:bO
+! !
+
!UIObjectView class methodsFor:'defaults'!
defaultGrid
@@ -1556,11 +1601,26 @@
!UIObjectView methodsFor:'user actions - position'!
+alignFrameLayout:aBlock
+ "perform block on a frameLayout assigned to the current single selection
+ "
+ 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
"
- |bmost delta layout|
+ |bmost delta|
(self canMove:selection) ifTrue:[
self withSelectionHiddenDo:[
@@ -1573,16 +1633,9 @@
]
]
] ifFalse:[
- layout := selection geometryLayout.
-
- (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.
- ]
+ self alignFrameLayout:[:aLayout|
+ aLayout bottomOffset:0.
+ aLayout bottomFraction:1.0
]
]
].
@@ -1666,7 +1719,7 @@
"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|
+ |lmost delta|
(self canMove:selection) ifTrue:[
self withSelectionHiddenDo:[
@@ -1679,15 +1732,9 @@
]
]
] ifFalse:[
- self transaction:#layout selectionDo:[:aView|
- layout := aView geometryLayout.
-
- layout isLayout ifTrue:[
- self undoLayoutView:aView.
- layout leftOffset:0.
- layout leftFraction:0.0.
- aView geometryLayout:layout.
- ]
+ self alignFrameLayout:[:aLayout|
+ aLayout leftOffset:0.
+ aLayout leftFraction:0.0.
]
]
].
@@ -1699,7 +1746,7 @@
"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|
+ |lmost rmost|
(self canMove:selection) ifTrue:[
self withSelectionHiddenDo:[
@@ -1714,21 +1761,11 @@
self elementChangedSize:v.
]
] ifFalse:[
- self transaction:#layout selectionDo:[:aView|
- layout := aView geometryLayout.
-
- layout isLayout ifTrue:[
- self undoLayoutView:aView.
- layout leftOffset:0.
- layout leftFraction:0.0.
-
- (layout isLayout and:[layout isLayoutFrame]) ifTrue:[
- layout rightOffset:0.
- layout rightFraction:1.0.
- ].
- aView geometryLayout:layout.
- self elementChangedSize:aView.
- ]
+ self alignFrameLayout:[:aLayout|
+ aLayout leftOffset:0.
+ aLayout leftFraction:0.0.
+ aLayout rightOffset:0.
+ aLayout rightFraction:1.0.
]
]
].
@@ -1741,7 +1778,7 @@
"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|
+ |rmost delta|
(self canMove:selection) ifTrue:[
self withSelectionHiddenDo:[
@@ -1754,16 +1791,9 @@
]
]
] ifFalse:[
- layout := selection geometryLayout.
-
- (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.
- ]
+ self alignFrameLayout:[:aLayout|
+ aLayout rightOffset:0.
+ aLayout rightFraction:1.0.
]
]
].
@@ -1775,7 +1805,7 @@
"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|
+ |tmost delta|
(self canMove:selection) ifTrue:[
self withSelectionHiddenDo:[
@@ -1788,15 +1818,9 @@
]
]
] ifFalse:[
- self transaction:#layout selectionDo:[:aView|
- layout := aView geometryLayout.
-
- layout isLayout ifTrue:[
- self undoLayoutView:aView.
- layout topOffset:0.
- layout topFraction:0.0.
- aView geometryLayout:layout.
- ]
+ self alignFrameLayout:[:aLayout|
+ aLayout topOffset:0.
+ aLayout topFraction:0.0.
]
]
].
@@ -1809,7 +1833,7 @@
"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|
+ |tmost bmost|
(self canMove:selection) ifTrue:[
self withSelectionHiddenDo:[
@@ -1823,28 +1847,11 @@
self elementChangedSize:v.
]
] ifFalse:[
- self transaction:#align selectionDo:[:aView|
- layout := aView geometryLayout.
-
- layout isLayout ifTrue:[
- self undoLayoutView:aView.
- layout topOffset:0.
- layout topFraction:0.0.
-
- (layout isLayout and:[layout isLayoutFrame]) ifTrue:[
- layout bottomOffset:0.
- 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.
+ self alignFrameLayout:[:aLayout|
+ aLayout topOffset:0.
+ aLayout topFraction:0.0.
+ aLayout bottomOffset:0.
+ aLayout bottomFraction:1.0.
]
]
].
@@ -1852,33 +1859,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.