UIObjectView.st
changeset 2514 faf45b01db30
parent 2513 1c2ac34566ab
child 2516 6c0bc4ed2d88
equal deleted inserted replaced
2513:1c2ac34566ab 2514:faf45b01db30
   763 ! !
   763 ! !
   764 
   764 
   765 !UIObjectView methodsFor:'object moving'!
   765 !UIObjectView methodsFor:'object moving'!
   766 
   766 
   767 doObjectMove:aPoint
   767 doObjectMove:aPoint
   768     "move selection"
   768     "move movedOject (which is a misnomer - its actually a collection of objects to move)"
   769 
   769 
   770     movedObject notNil ifTrue:[
   770     movedObject notNil ifTrue:[
   771         self hideSelection.
   771         self hideSelection.
   772         self repairDamage.
       
   773 
   772 
   774         self invertOutlineOf:movedObject.
   773         self invertOutlineOf:movedObject.
   775 
   774 
   776         movedObject keysAndValuesDo:[:i :v|
   775         movedObject keysAndValuesDo:[:i :v|
   777             self moveObject:v to:(aPoint - (moveDelta at:i)).
   776             self moveObject:v to:(aPoint - (moveDelta at:i)).
   778         ].
   777         ].
   779         self invertOutlineOf:movedObject.
   778         self invertOutlineOf:movedObject.
   780 
   779 
   781         self showSelection.
   780         self showSelection.
   782         self repairDamage.
       
   783     ]
   781     ]
   784 !
   782 !
   785 
   783 
   786 endObjectMove
   784 endObjectMove
   787     "cleanup after object(s) move
   785     "cleanup after object(s) move
   812         self layoutChanged.
   810         self layoutChanged.
   813     ].
   811     ].
   814 !
   812 !
   815 
   813 
   816 moveObject:anObject to:aPoint
   814 moveObject:anObject to:aPoint
   817     "move anObject to newOrigin, aPoint
   815     "move anObject to newOrigin, aPoint"
   818     "
   816 
   819     |dX dY org delta|
   817     |dX dY org delta|
   820 
   818 
   821     anObject notNil ifTrue:[
   819     anObject notNil ifTrue:[
   822         org := anObject computeOrigin.
   820         org := anObject computeOrigin.
   823 
   821 
   825         delta := (self alignToGrid:aPoint) - org.
   823         delta := (self alignToGrid:aPoint) - org.
   826         dX := delta x.
   824         dX := delta x.
   827         dY := delta y.
   825         dY := delta y.
   828 
   826 
   829         undoHistory withoutTransactionDo:[
   827         undoHistory withoutTransactionDo:[
   830             self shiftLayout:anObject top:dY bottom:dY left:dX right:dX
   828             self shiftLayout:anObject horizontal:dX vertical:dY
   831         ]
   829         ]
   832     ]
   830     ]
   833 !
   831 !
   834 
   832 
   835 startObjectMoveAt:aPoint
   833 startObjectMoveAt:aPoint
   981     "
   979     "
   982     |p object|
   980     |p object|
   983 
   981 
   984     object := resizeData object.
   982     object := resizeData object.
   985 
   983 
   986 self hideSelection.
   984     self hideSelection.
   987 self repairDamage.
   985 
   988     self invertOutlineOf:object.
   986     self invertOutlineOf:object.
   989     p := (self alignToGrid:aPoint) - (resizeData delta).
   987     p := (self alignToGrid:aPoint) - (resizeData delta).
   990 
   988 
   991     self perform:(resizeData selector) with:object with:p.
   989     self perform:(resizeData selector) with:object with:p.
   992     Delay waitForSeconds:0.05.
   990     Delay waitForSeconds:0.05.
   995     ].
   993     ].
   996 
   994 
   997    "/ object geometryLayout:(object geometryLayout).
   995    "/ object geometryLayout:(object geometryLayout).
   998     self invertOutlineOf:object.
   996     self invertOutlineOf:object.
   999 
   997 
  1000 self showSelection.
   998     self showSelection.
  1001 self repairDamage.
       
  1002 !
   999 !
  1003 
  1000 
  1004 endResize
  1001 endResize
  1005     "cleanup after object resize
  1002     "cleanup after object resize
  1006     "
  1003     "
  1197 !UIObjectView methodsFor:'private-shift layout'!
  1194 !UIObjectView methodsFor:'private-shift layout'!
  1198 
  1195 
  1199 shiftLayout:aViewOrComponent horizontal:n
  1196 shiftLayout:aViewOrComponent horizontal:n
  1200     "shift layout for a view; in case of an open transaction, the undo action is registered"
  1197     "shift layout for a view; in case of an open transaction, the undo action is registered"
  1201 
  1198 
  1202     (aViewOrComponent isKindOf:LineSegmentMorph) ifTrue:[
  1199     self shiftLayout:aViewOrComponent horizontal:n vertical:0
  1203         self shiftLayout:aViewOrComponent 
  1200 !
  1204              startPoint:(n @ 0) endPoint:(n @ 0)
  1201 
       
  1202 shiftLayout:aViewOrComponent horizontal:h vertical:v
       
  1203     "shift layout for a view; in case of an open transaction, the undo action is registered"
       
  1204 
       
  1205     (self specFor:aViewOrComponent) hasLayout ifTrue:[
       
  1206         self shiftLayout:aViewOrComponent top:v bottom:v left:h right:h
  1205     ] ifFalse:[
  1207     ] ifFalse:[
  1206         self shiftLayout:aViewOrComponent top:0 bottom:0 left:n right:n
  1208         self shiftLayout:aViewOrComponent startPoint:(h @ v) endPoint:(h @ v)
  1207     ]
  1209     ].
  1208 !
  1210 !
  1209 
  1211 
  1210 shiftLayout:aView left:l right:r
  1212 shiftLayout:aView left:l right:r
  1211     "shift layout for a view; in case of an open transaction, the undo action is registered"
  1213     "shift layout for a view; in case of an open transaction, the undo action is registered"
  1212 
  1214 
  1269 !
  1271 !
  1270 
  1272 
  1271 shiftLayout:aViewOrComponent vertical:n
  1273 shiftLayout:aViewOrComponent vertical:n
  1272     "shift layout for a view; in case of an open transaction, the undo action is registered"
  1274     "shift layout for a view; in case of an open transaction, the undo action is registered"
  1273 
  1275 
  1274     (aViewOrComponent isKindOf:LineSegmentMorph) ifTrue:[
  1276     self shiftLayout:aViewOrComponent horizontal:0 vertical:n
  1275         self shiftLayout:aViewOrComponent 
       
  1276              startPoint:(0 @ n) endPoint:(0 @ n)
       
  1277     ] ifFalse:[
       
  1278         self shiftLayout:aViewOrComponent top:n bottom:n left:0 right:0
       
  1279     ].
       
  1280 ! !
  1277 ! !
  1281 
  1278 
  1282 !UIObjectView methodsFor:'searching'!
  1279 !UIObjectView methodsFor:'searching'!
  1283 
  1280 
  1284 findObjectAt:aPoint
  1281 findObjectAt:aPoint
  1342 !UIObjectView methodsFor:'selections'!
  1339 !UIObjectView methodsFor:'selections'!
  1343 
  1340 
  1344 hideSelection
  1341 hideSelection
  1345     "hide the selection - undraw hilights - whatever that is
  1342     "hide the selection - undraw hilights - whatever that is
  1346     "
  1343     "
  1347 super hideSelection.
  1344 
       
  1345     super hideSelection.
       
  1346     self repairDamage.   
  1348 "/    self showUnselected:selection.
  1347 "/    self showUnselected:selection.
  1349 !
  1348 !
  1350 
  1349 
  1351 moveableSelection
  1350 moveableSelection
  1352     "checks whether the selection is not empty and all selected instances
  1351     "checks whether the selection is not empty and all selected instances
  1409 
  1408 
  1410 showSelection
  1409 showSelection
  1411     "show the selection - draw handles"
  1410     "show the selection - draw handles"
  1412 
  1411 
  1413     selectionHiddenLevel == 0 ifTrue:[
  1412     selectionHiddenLevel == 0 ifTrue:[
  1414         super showSelection
  1413         super showSelection.
       
  1414         self repairDamage.   
  1415     ].
  1415     ].
  1416 !
  1416 !
  1417 
  1417 
  1418 singleSelection
  1418 singleSelection
  1419     "checks whether a single element is selected; in this case the element is
  1419     "checks whether a single element is selected; in this case the element is
  1470         device flush.
  1470         device flush.
  1471     ].
  1471     ].
  1472     selectionHiddenLevel := selectionHiddenLevel + 1.
  1472     selectionHiddenLevel := selectionHiddenLevel + 1.
  1473 
  1473 
  1474     aBlock ensure:[
  1474     aBlock ensure:[
  1475         selectionHiddenLevel == 1 ifTrue:[
  1475         selectionHiddenLevel := selectionHiddenLevel - 1.
       
  1476         selectionHiddenLevel == 0 ifTrue:[
  1476             setOfSuperViewsSizeChanged notEmpty ifTrue:[
  1477             setOfSuperViewsSizeChanged notEmpty ifTrue:[
  1477                 coll := self minClosedViewSetFor:setOfSuperViewsSizeChanged.
  1478                 coll := self minClosedViewSetFor:setOfSuperViewsSizeChanged.
  1478                 coll do:[:aView| aView sizeChanged:nil].
  1479                 coll do:[:aView| aView sizeChanged:nil].
  1479                 setOfSuperViewsSizeChanged := IdentitySet new
  1480                 setOfSuperViewsSizeChanged := IdentitySet new
  1480             ].
  1481             ].
  1481             selectionHiddenLevel := 0.
  1482             self showSelection.
  1482             self selectionDo:[:aView| self showSelected:aView].
       
  1483         ] ifFalse:[
       
  1484             selectionHiddenLevel := selectionHiddenLevel - 1.
       
  1485         ]
  1483         ]
  1486     ]
  1484     ]
  1487 !
  1485 !
  1488 
  1486 
  1489 withoutSelectionDo:aBlock
  1487 withoutSelectionDo:aBlock