# HG changeset patch # User mawalch # Date 1494949934 -7200 # Node ID bd1aa4795dcf99ae74824fed515d1b2a8824ed4a # Parent 4d705dd47c2d62f881b938186a7f6e24aa418935 #DOCUMENTATION by mawalch class: UIObjectView comment/format in: #centerSelection:orientation: diff -r 4d705dd47c2d -r bd1aa4795dcf UIObjectView.st --- a/UIObjectView.st Thu May 11 13:31:27 2017 +0200 +++ b/UIObjectView.st Tue May 16 17:52:14 2017 +0200 @@ -1,3 +1,5 @@ +"{ Encoding: utf8 }" + " COPYRIGHT (c) 1995 by eXept Software AG All Rights Reserved @@ -2593,56 +2595,56 @@ ! centerSelection:aOneArgBlockXorY orientation:orientation - "center selection horizontal or vertical dependant on the block result( x or y). + "center selection horizontally or vertically depending on the block result (x or y). The argument to the block is the point. " |superview min max delta val| (self moveableSelection) isNil ifTrue:[ - ^ self + ^ self ]. self withSelectionHiddenDo:[ - max := 0. - - self selectionDo:[:aView | - superview isNil ifTrue:[ - superview := self findContainerOfView:aView - ] ifFalse:[ - (self findContainerOfView:aView) == superview ifFalse:[ - ^ self notify:'views must have same superview'. - ] - ]. - val := aOneArgBlockXorY value:(aView computeOrigin). - - min isNil ifTrue:[min := val] - ifFalse:[min := min min:val]. - - val := aOneArgBlockXorY value:(aView computeCorner). - max := max max:val. - ]. - - val := aOneArgBlockXorY value:(superview computeExtent). - max := (min + val - max) // 2. - - max == min ifFalse:[ - |type| - (orientation == #y) ifTrue:[type := #centerVertical] - ifFalse:[type := #centerHorizontal]. - delta := max - min. - - self transaction:type selectionDo:[:v| - orientation == #y ifTrue:[ - self shiftLayout:v top:delta bottom:delta - ] ifFalse:[ - self shiftLayout:v left:delta right:delta - ] - ] - ]. - self layoutChanged + max := 0. + + self selectionDo:[:aView | + superview isNil ifTrue:[ + superview := self findContainerOfView:aView + ] ifFalse:[ + (self findContainerOfView:aView) == superview ifFalse:[ + ^ self notify:'views must have same superview'. + ] + ]. + val := aOneArgBlockXorY value:(aView computeOrigin). + + min isNil ifTrue:[min := val] + ifFalse:[min := min min:val]. + + val := aOneArgBlockXorY value:(aView computeCorner). + max := max max:val. + ]. + + val := aOneArgBlockXorY value:(superview computeExtent). + max := (min + val - max) // 2. + + max == min ifFalse:[ + |type| + (orientation == #y) ifTrue:[type := #centerVertical] + ifFalse:[type := #centerHorizontal]. + delta := max - min. + + self transaction:type selectionDo:[:v| + orientation == #y ifTrue:[ + self shiftLayout:v top:delta bottom:delta + ] ifFalse:[ + self shiftLayout:v left:delta right:delta + ] + ] + ]. + self layoutChanged ] - + "Modified (format): / 16-05-2017 / 17:45:24 / mawalch" ! centerSelectionHor