# HG changeset patch # User Claus Gittinger # Date 1213954760 -7200 # Node ID 121c79884983b20a4d2307305a4aa75be85bba41 # Parent 4c74ed85b3a44d73a09900d2f03a0b9ed7f1d395 *** empty log message *** diff -r 4c74ed85b3a4 -r 121c79884983 UIObjectView.st --- a/UIObjectView.st Fri Jun 20 11:39:04 2008 +0200 +++ b/UIObjectView.st Fri Jun 20 11:39:20 2008 +0200 @@ -15,7 +15,7 @@ instanceVariableNames:'saveSelection undoHistory copiedExtent copiedLayout resizeData clipChildren selectionHiddenLevel gridParameters setOfSuperViewsSizeChanged hasUndoHistoryHolder' - classVariableNames:'' + classVariableNames:'CopiedLayout CopiedExtent' poolDictionaries:'' category:'Interface-UIPainter' ! @@ -256,26 +256,25 @@ isVerticalResizable:aComponent "returns true if instance is vertical resizeable " - (aComponent isKindOf:EditField) ifTrue:[ - ^ false - ]. - (aComponent isKindOf:ComboBoxView) ifTrue:[ - ^ false - ]. - (aComponent isKindOf:CheckBox) ifTrue:[ - ^ false - ]. - (aComponent isKindOf:ScrollBar) ifTrue:[ - ^ aComponent orientation == #vertical - ]. - (aComponent isKindOf:Scroller) ifTrue:[ - ^ aComponent orientation == #vertical - ]. - (aComponent isKindOf:Slider) ifTrue:[ - ^ aComponent orientation == #vertical - ]. +"/ (aComponent isKindOf:EditField) ifTrue:[ +"/ ^ false +"/ ]. +"/ (aComponent isKindOf:ComboBoxView) ifTrue:[ +"/ ^ false +"/ ]. +"/ (aComponent isKindOf:CheckBox) ifTrue:[ +"/ ^ false +"/ ]. +"/ (aComponent isKindOf:ScrollBar) ifTrue:[ +"/ ^ aComponent orientation == #vertical +"/ ]. +"/ (aComponent isKindOf:Scroller) ifTrue:[ +"/ ^ aComponent orientation == #vertical +"/ ]. +"/ (aComponent isKindOf:Slider) ifTrue:[ +"/ ^ aComponent orientation == #vertical +"/ ]. ^ true - ! layoutType:aView @@ -400,7 +399,7 @@ !UIObjectView methodsFor:'accessing-behavior'! enableStateChanged - "set the modification / test mode + "toggle the test mode " self shown ifTrue:[ enableChannel value ifFalse:[ @@ -867,12 +866,13 @@ self enabled ifFalse:[^ self]. selectedView := self singleSelection. - clickedView := self findObjectAt:aPoint. - - (clickedView isComponentOf:selectedView) ifTrue:[ - self unselect. - selectedView := nil. - ]. + +"/ clickedView := self findObjectAt:aPoint. +"/ (clickedView notNil +"/ and:[clickedView isComponentOf:selectedView]) ifTrue:[ +"/ self unselect. +"/ selectedView := nil. +"/ ]. selectedView notNil ifTrue:[ containerOfSelectedView := self findContainerOfView:selectedView. @@ -895,6 +895,14 @@ ] ]. + clickedView := self findObjectAt:aPoint. + (clickedView notNil + and:[clickedView isComponentOf:selectedView]) ifTrue:[ + self unselect. + selectedView := nil. + viewOperatedUpon := nil + ]. + viewOperatedUpon isNil ifTrue:[ clickedView isNil ifTrue:[ self select:nil. @@ -992,7 +1000,7 @@ ]. self setSelection:object withRedraw:true. - self forEach:selection do:[:aView | + self forEach:self selection do:[:aView | self recomputeShapeIfTransparentBox:aView. ]. self layoutChanged. @@ -1256,11 +1264,11 @@ |coll| self hasSelection ifTrue:[ - (self canMove:(coll := self selection)) ifTrue:[ - ^ coll - ] + (self canMove:(coll := self selection)) ifTrue:[ + ^ coll + ] ]. - ^ nil + ^ nil ! numberOfSelections @@ -1471,9 +1479,8 @@ selection "returns the current selection " +"/^ super selection ^ selection - - ! setSelection:newSelection withRedraw:doRedraw @@ -1609,37 +1616,29 @@ !UIObjectView methodsFor:'user actions-dimension'! copyExtent - "copy the extent from the selected object - " + "copy the extent from the selected object" + |object| object := self singleSelection. - object notNil ifTrue:[ - copiedExtent := object computeExtent + CopiedExtent := object computeExtent ] ifFalse:[ - self warn:'exactly one element must be selected'. + self warn:'Exactly one element must be selected!!'. ] - - - ! copyLayout - "copy the layout from the selected object - " + "copy the layout from the selected object" + |object| object := self singleSelection. - object notNil ifTrue:[ - copiedLayout := object geometryLayout copy + CopiedLayout := object geometryLayout copy ] ifFalse:[ - self warn:'exactly one element must be selected'. + self warn:'Exactly one element must be selected!!'. ] - - - ! exchangeLayouts @@ -1669,45 +1668,43 @@ ! pasteExtent - "paste the copied extent to all objects in the selection - " - copiedExtent notNil ifTrue:[ - self transaction:#pasteExtent dimensionDo:[:v| - self resize:v corner:(v computeOrigin + copiedExtent) - ] + "paste the copied extent to all objects in the selection" + + CopiedExtent notNil ifTrue:[ + self transaction:#pasteExtent dimensionDo:[:v| + self resize:v corner:(v computeOrigin + CopiedExtent) + ] ] ! pasteHeight - "paste the copied extent height to all objects in the selection - " - copiedExtent notNil ifTrue:[ - self transaction:#pasteHeight dimensionDo:[:v| - self resize:v bottom:(v computeOrigin + copiedExtent) - ] + "paste the copied extent's height to all objects in the selection" + + CopiedExtent notNil ifTrue:[ + self transaction:#pasteHeight dimensionDo:[:v| + self resize:v bottom:(v computeOrigin + CopiedExtent y) + ] ] - ! pasteLayout - "paste layout to all objects in the selection - " - copiedLayout notNil ifTrue:[ - self transaction:#pasteLayout dimensionDo:[:v| - v geometryLayout:(copiedLayout copy) - ] + "paste the layout to all objects in the selection" + + CopiedLayout notNil ifTrue:[ + self transaction:#pasteLayout dimensionDo:[:v| + v geometryLayout:(CopiedLayout copy) + ] ] ! pasteWidth - "paste the copied extent width to all objects in the selection - " - copiedExtent notNil ifTrue:[ - self transaction:#pasteWidth dimensionDo:[:v| - self resize:v right:(v computeOrigin + copiedExtent) - ] + "paste the copied extent's width to all objects in the selection" + + CopiedExtent notNil ifTrue:[ + self transaction:#pasteWidth dimensionDo:[:v| + self resize:v right:(v computeOrigin + CopiedExtent x) + ] ] - ! setExtent:anExtent @@ -1926,6 +1923,60 @@ !UIObjectView methodsFor:'user actions-position'! +alignResizeSelectionLeft + "resize the selection on the left to align their left edge with the + of the first object in the selection; + in case of a single object selection, the objects left edge is aligned with the left of its superview" + + |lmost delta sel| + + (sel := self moveableSelection) notNil ifTrue:[ + self withSelectionHiddenDo:[ + self numberOfSelections > 1 ifTrue:[ + lmost := (sel first) computeOrigin x. + + self transaction:#alignResizeLeft selectionDo:[:v| + (delta := lmost - (v computeOrigin x)) ~~ 0 ifTrue:[ + self shiftLayout:v left:delta right:0 + ] + ] + ] ifFalse:[ + self extentToFrame:#Left do:[:aLayout| + aLayout leftFraction:0.0 offset:0. + ] + ] + ]. + self layoutChanged + ] +! + +alignResizeSelectionRight + "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 sel| + + (sel := self moveableSelection) notNil ifTrue:[ + self withSelectionHiddenDo:[ + self numberOfSelections > 1 ifTrue:[ + rmost := (sel first) computeCorner x. + + self transaction:#alignRight selectionDo:[:v| + (delta := rmost - (v computeCorner x)) ~~ 0 ifTrue:[ + self shiftLayout:v left:0 right:delta + ] + ] + ] ifFalse:[ + self extentToFrame:#Right do:[:aLayout| + aLayout rightOffset:0. + aLayout rightFraction:1.0. + ] + ] + ]. + self layoutChanged + ] +! + 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 @@ -2027,25 +2078,24 @@ ! alignSelectionLeft - "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 sel| + "align the selection with the left edge of the first object in the selection. + in case of a single object selection, the object is moved to the left of its superview" + + |dominantLeft delta sel| (sel := self moveableSelection) notNil ifTrue:[ self withSelectionHiddenDo:[ + dominantLeft := (sel first) computeOrigin x. self numberOfSelections > 1 ifTrue:[ - lmost := (sel first) computeOrigin x. - self transaction:#alignLeft selectionDo:[:v| - (delta := lmost - (v computeOrigin x)) ~~ 0 ifTrue:[ + (delta := dominantLeft - (v computeOrigin x)) ~~ 0 ifTrue:[ self shiftLayout:v left:delta right:delta ] ] ] ifFalse:[ - self extentToFrame:#Left do:[:aLayout| - aLayout leftFraction:0.0 offset:0. - ] + self transaction:#alignLeft selectionDo:[:v| + self shiftLayout:v left:dominantLeft negated right:dominantLeft negated + ]. ] ]. self layoutChanged @@ -2094,26 +2144,29 @@ "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 sel| + |dominantRight delta sel| (sel := self moveableSelection) notNil ifTrue:[ - self withSelectionHiddenDo:[ - self numberOfSelections > 1 ifTrue:[ - rmost := (sel first) computeCorner x. - - self transaction:#alignRight selectionDo:[:v| - (delta := rmost - (v computeCorner x)) ~~ 0 ifTrue:[ - self shiftLayout:v left:delta right:delta - ] - ] - ] ifFalse:[ - self extentToFrame:#Right do:[:aLayout| - aLayout rightOffset:0. - aLayout rightFraction:1.0. - ] - ] - ]. - self layoutChanged + self withSelectionHiddenDo:[ + dominantRight := (sel first) computeCorner x. + self numberOfSelections > 1 ifTrue:[ + self transaction:#alignRight selectionDo:[:v| + (delta := dominantRight - (v computeCorner x)) ~~ 0 ifTrue:[ + self shiftLayout:v left:delta right:delta + ] + ] + ] ifFalse:[ + self transaction:#alignRight selectionDo:[:v| + delta := v superView width - dominantRight. + self shiftLayout:v left:delta right:delta + ] +"/ self extentToFrame:#Right do:[:aLayout| +"/ aLayout rightOffset:0. +"/ aLayout rightFraction:1.0. +"/ ] + ] + ]. + self layoutChanged ] !