UIObjectView.st
changeset 68 889c3877baf0
parent 67 09e9d4b57142
child 72 a5a7054e2b7d
equal deleted inserted replaced
67:09e9d4b57142 68:889c3877baf0
    26 
    26 
    27 asLayoutFrameFromView:aView
    27 asLayoutFrameFromView:aView
    28     "convert layout from aView to a frameLayout. On success the frameLayout is
    28     "convert layout from aView to a frameLayout. On success the frameLayout is
    29      returned otherwise nil
    29      returned otherwise nil
    30     "
    30     "
    31     |lF lO rF rO tF tO bF bO layout|
    31     |lF lO rF rO tF tO bF bO type layout newLyt|
    32 
    32 
    33     (layout := aView geometryLayout) isNil ifTrue:[
    33     type   := self layoutType:aView.
       
    34     layout := aView geometryLayout.
       
    35 
       
    36     (type isNil or:[layout isNil]) ifTrue:[
    34         ^ nil
    37         ^ nil
    35     ].
    38     ].
    36 
    39 
    37     layout isLayout ifTrue:[
    40     type == #LayoutFrame ifTrue:[
    38         layout isLayoutFrame ifTrue:[^ layout copy].
    41         ^ layout copy
    39 
    42     ].
    40         lF := layout leftFraction.
    43 
    41         lO := layout leftOffset.
    44     layout isLayout ifFalse:[
    42         tF := layout topFraction.
    45         type == #Rectangle ifTrue:[
    43         tO := layout topOffset.
       
    44         bF := tF.
       
    45         bO := tO + aView extent y.
       
    46         rF := lF.
       
    47         rO := lO + aView extent x.
       
    48     ] ifFalse:[
       
    49         lF := rF := tF := bF := 0.
       
    50 
       
    51         layout isRectangle ifTrue:[
       
    52             lO := layout left.
    46             lO := layout left.
    53             tO := layout top.
    47             tO := layout top.
    54             rO := layout right.
    48             rO := layout right.
    55             bO := layout bottom.
    49             bO := layout bottom.
    56         ] ifFalse:[
    50         ] ifFalse:[
    57             layout isPoint ifFalse:[ ^ nil ].
       
    58 
       
    59             lO := layout x.
    51             lO := layout x.
    60             tO := layout y.
    52             tO := layout y.
    61             rO := lO + aView extent x.
    53             rO := lO + aView extent x.
    62             bO := tO + aView extent y.
    54             bO := tO + aView extent y.
    63         ].
    55         ].
    64     ].
    56 
    65 
    57         ^ LayoutFrame leftFraction:0 offset:lO  rightFraction:0 offset:rO
    66     ^ LayoutFrame leftFraction:lF offset:lO  rightFraction:rF offset:rO
    58                        topFraction:0 offset:tO bottomFraction:0 offset:bO
    67                    topFraction:tF offset:tO bottomFraction:bF offset:bO
    59     ].
       
    60 
       
    61     lF := layout leftFraction.
       
    62     lO := layout leftOffset.
       
    63     tF := layout topFraction.
       
    64     tO := layout topOffset.
       
    65     bF := tF.
       
    66     bO := tO + aView extent y.
       
    67     rF := lF.
       
    68     rO := lO + aView extent x.
       
    69 
       
    70     newLyt := LayoutFrame leftFraction:lF offset:lO  rightFraction:rF offset:rO
       
    71                            topFraction:tF offset:tO bottomFraction:bF offset:bO.
       
    72 
       
    73     (    (type == #AlignmentOrigin)
       
    74      and:[layout leftAlignmentFraction ~~ 0
       
    75       or:[layout topAlignmentFraction  ~~ 0]]
       
    76     ) ifTrue:[
       
    77         |svRc prBd dlta|
       
    78 
       
    79         svRc := aView superView viewRectangle.
       
    80         prBd := aView preferredBounds.
       
    81         dlta := (  ((layout rectangleRelativeTo:svRc preferred:prBd) corner)
       
    82                  - ((newLyt rectangleRelativeTo:svRc preferred:prBd) corner)
       
    83                 ) rounded.
       
    84 
       
    85         newLyt leftOffset:(lO + dlta x).
       
    86         newLyt rightOffset:(rO + dlta x).
       
    87         newLyt topOffset:(tO + dlta y).
       
    88         newLyt bottomOffset:(bO + dlta y).
       
    89     ].
       
    90   ^ newLyt.
    68 ! !
    91 ! !
    69 
    92 
    70 !UIObjectView class methodsFor:'defaults'!
    93 !UIObjectView class methodsFor:'defaults'!
    71 
    94 
    72 defaultGrid
    95 defaultGrid
  1606 !UIObjectView methodsFor:'user actions - position'!
  1629 !UIObjectView methodsFor:'user actions - position'!
  1607 
  1630 
  1608 alignFrameLayout:aBlock
  1631 alignFrameLayout:aBlock
  1609     "perform block on a frameLayout assigned to the current single selection
  1632     "perform block on a frameLayout assigned to the current single selection
  1610     "
  1633     "
       
  1634     |layout|
       
  1635 
  1611     self transaction:#align selectionDo:[:aView|
  1636     self transaction:#align selectionDo:[:aView|
  1612         layout := self class asLayoutFrameFromView:aView.
  1637         layout := self class asLayoutFrameFromView:aView.
  1613 
  1638 
  1614         layout notNil ifTrue:[
  1639         layout notNil ifTrue:[
  1615             self undoLayoutView:aView.
  1640             self undoLayoutView:aView.