--- a/UIObjectView.st Fri Feb 28 13:25:51 1997 +0100
+++ b/UIObjectView.st Fri Feb 28 18:03:28 1997 +0100
@@ -28,43 +28,66 @@
"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:[
+ |lF lO rF rO tF tO bF bO type layout newLyt|
+
+ type := self layoutType:aView.
+ layout := aView geometryLayout.
+
+ (type isNil or:[layout 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:[
+ type == #LayoutFrame ifTrue:[
+ ^ layout copy
+ ].
+
+ layout isLayout ifFalse:[
+ type == #Rectangle 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:0 offset:lO rightFraction:0 offset:rO
+ topFraction:0 offset:tO bottomFraction:0 offset:bO
].
- ^ LayoutFrame leftFraction:lF offset:lO rightFraction:rF offset:rO
- topFraction:tF offset:tO bottomFraction:bF offset:bO
+ 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.
+
+ newLyt := LayoutFrame leftFraction:lF offset:lO rightFraction:rF offset:rO
+ topFraction:tF offset:tO bottomFraction:bF offset:bO.
+
+ ( (type == #AlignmentOrigin)
+ and:[layout leftAlignmentFraction ~~ 0
+ or:[layout topAlignmentFraction ~~ 0]]
+ ) ifTrue:[
+ |svRc prBd dlta|
+
+ svRc := aView superView viewRectangle.
+ prBd := aView preferredBounds.
+ dlta := ( ((layout rectangleRelativeTo:svRc preferred:prBd) corner)
+ - ((newLyt rectangleRelativeTo:svRc preferred:prBd) corner)
+ ) rounded.
+
+ newLyt leftOffset:(lO + dlta x).
+ newLyt rightOffset:(rO + dlta x).
+ newLyt topOffset:(tO + dlta y).
+ newLyt bottomOffset:(bO + dlta y).
+ ].
+ ^ newLyt.
! !
!UIObjectView class methodsFor:'defaults'!
@@ -1608,6 +1631,8 @@
alignFrameLayout:aBlock
"perform block on a frameLayout assigned to the current single selection
"
+ |layout|
+
self transaction:#align selectionDo:[:aView|
layout := self class asLayoutFrameFromView:aView.