19 classVariableNames:'' |
19 classVariableNames:'' |
20 poolDictionaries:'' |
20 poolDictionaries:'' |
21 privateIn:UIObjectView::UndoHistory |
21 privateIn:UIObjectView::UndoHistory |
22 ! |
22 ! |
23 |
23 |
|
24 !UIObjectView class methodsFor:'documentation'! |
|
25 |
|
26 documentation |
|
27 " |
|
28 buildIn view used by the UIPainter; from this view, the layout of the |
|
29 new application derives from. |
|
30 |
|
31 [see also:] |
|
32 UIBuilder |
|
33 UIPainterView |
|
34 " |
|
35 |
|
36 ! ! |
24 |
37 |
25 !UIObjectView class methodsFor:'conversion'! |
38 !UIObjectView class methodsFor:'conversion'! |
26 |
39 |
27 asLayoutFrameFromView:aView |
40 asLayoutFrameFromView:aView |
28 "convert layout from aView to a frameLayout. On success the frameLayout is |
41 "convert layout from aView to a frameLayout. On success the frameLayout is |
231 enabled:aState |
244 enabled:aState |
232 "set the modification / test mode |
245 "set the modification / test mode |
233 " |
246 " |
234 (aState == enableChannel value) ifFalse:[ |
247 (aState == enableChannel value) ifFalse:[ |
235 aState ifFalse:[ |
248 aState ifFalse:[ |
236 saveSelection := selection copy |
249 saveSelection := self selection copy. |
237 ]. |
|
238 enableChannel value:aState. |
|
239 |
|
240 aState ifFalse:[ |
|
241 self unselect. |
250 self unselect. |
242 inputView unrealize |
251 enableChannel value:aState. |
|
252 inputView unrealize. |
243 ] ifTrue:[ |
253 ] ifTrue:[ |
244 inputView raise. |
254 inputView raise. |
245 inputView realize. |
255 inputView realize. |
|
256 enableChannel value:aState. |
246 self select:saveSelection. |
257 self select:saveSelection. |
247 ] |
258 ] |
248 ] |
259 ] |
249 |
260 |
250 |
261 |
313 ^ self deleteSelection |
322 ^ self deleteSelection |
314 ]. |
323 ]. |
315 |
324 |
316 key == #Copy ifTrue:[ ^ self copySelection]. |
325 key == #Copy ifTrue:[ ^ self copySelection]. |
317 key == #Paste ifTrue:[ ^ self pasteBuffer]. |
326 key == #Paste ifTrue:[ ^ self pasteBuffer]. |
318 |
|
319 super keyPress:key x:x y:y |
|
320 |
|
321 |
|
322 ! |
327 ! |
323 |
328 |
324 processEvent:anEvent |
329 processEvent:anEvent |
325 "catch expose events for components, and redraw its handles after |
330 "catch expose events for components, and redraw its handles after |
326 the redraw when this happens |
331 the redraw when this happens |
327 " |
332 " |
328 |view| |
333 (anEvent type == #damage and:[self isSelected:(anEvent view)]) ifTrue:[ |
329 |
334 self showSelected:(anEvent view) |
330 selection notNil ifTrue:[ |
|
331 anEvent type == #damage ifTrue:[ |
|
332 view := anEvent view. |
|
333 (selection == view |
|
334 or:[selection isCollection |
|
335 and:[selection includes:view]]) ifTrue:[ |
|
336 self showSelected:view |
|
337 ] |
|
338 ] |
|
339 ]. |
335 ]. |
340 ^ false. |
336 ^ false. |
341 |
337 |
342 |
338 |
343 ! |
339 ! |
628 |
624 |
629 endObjectMove |
625 endObjectMove |
630 "cleanup after object(s) move |
626 "cleanup after object(s) move |
631 " |
627 " |
632 movedObject notNil ifTrue:[ |
628 movedObject notNil ifTrue:[ |
633 movedObject do:[:aView| |
629 movedObject do:[:aView|self invertOutlineOf:aView]. |
634 self invertOutlineOf:aView |
630 |
635 ]. |
|
636 |
|
637 movedObject do:[:aView| |
|
638 self showSelected:aView |
|
639 ]. |
|
640 movedObject size == 1 ifTrue:[ |
631 movedObject size == 1 ifTrue:[ |
641 selection := movedObject at:1 |
632 movedObject := movedObject first |
642 ] ifFalse:[ |
633 ]. |
643 selection := movedObject |
634 |
644 ]. |
635 self setSelection:movedObject withRedraw:true. |
645 |
|
646 movedObject := nil. |
636 movedObject := nil. |
647 self setDefaultActions. |
637 self setDefaultActions. |
648 self changed:#layout. |
638 self changed:#layout. |
649 ]. |
639 ]. |
650 ! |
640 ! |
670 ! |
660 ! |
671 |
661 |
672 startObjectMoveAt:aPoint |
662 startObjectMoveAt:aPoint |
673 "start object(s) move at a point |
663 "start object(s) move at a point |
674 " |
664 " |
675 self startObjectMove:selection at:aPoint. |
665 self startObjectMove:(self selection) at:aPoint. |
676 |
666 movedObject := self selection. |
677 selection isCollection ifTrue:[ |
667 |
678 movedObject := selection |
668 movedObject isCollection ifFalse:[ |
679 ] ifFalse:[ |
669 movedObject := Array with:movedObject |
680 movedObject := Array with:selection |
670 ]. |
681 ]. |
671 self setSelection:nil withRedraw:true. |
682 super unselect. |
|
683 |
672 |
684 moveDelta := movedObject collect:[:aView| |
673 moveDelta := movedObject collect:[:aView| |
685 aPoint - aView computeOrigin |
674 aPoint - aView computeOrigin |
686 ]. |
675 ]. |
687 |
676 |
815 actionData := nil. |
802 actionData := nil. |
816 |
803 |
817 self invertOutlineOf:object. |
804 self invertOutlineOf:object. |
818 self setDefaultActions. |
805 self setDefaultActions. |
819 self elementChangedSize:object. |
806 self elementChangedSize:object. |
820 super select:object. |
807 self setSelection:object withRedraw:true. |
821 self changed:#layout. |
808 self changed:#layout. |
822 ! |
809 ! |
823 |
810 |
824 startResizeBorder:b of:selection |
811 startResizeBorder:b of:selection |
825 "resize selected view |
812 "resize selected view |
830 self actionResize:object selector:b. |
817 self actionResize:object selector:b. |
831 |
818 |
832 self transaction:#resize selectionDo:[:aView| |
819 self transaction:#resize selectionDo:[:aView| |
833 self undoLayoutView:aView |
820 self undoLayoutView:aView |
834 ]. |
821 ]. |
835 super unselect. |
822 self setSelection:nil withRedraw:true. |
836 |
823 |
837 motionAction := [:movePoint | self doDragResize:movePoint]. |
824 motionAction := [:movePoint | self doDragResize:movePoint]. |
838 releaseAction := [self endResize]. |
825 releaseAction := [self endResize]. |
839 self invertOutlineOf:object |
826 self invertOutlineOf:object |
840 ! ! |
827 ! ! |
1211 |
1198 |
1212 ! ! |
1199 ! ! |
1213 |
1200 |
1214 !UIObjectView methodsFor:'selections'! |
1201 !UIObjectView methodsFor:'selections'! |
1215 |
1202 |
1216 addToSelection:something |
1203 addToSelection:anObject |
1217 "add something to selection |
1204 "add anObject to selection |
1218 " |
1205 " |
1219 (self canSelect:something) ifTrue:[ |
1206 |coll| |
1220 super addToSelection:something. |
1207 |
1221 self selectionChanged. |
1208 self enabled ifTrue:[ |
1222 ] |
1209 self hasSelection ifFalse:[ |
|
1210 self select:anObject |
|
1211 ] ifTrue:[ |
|
1212 (self isSelected:anObject) ifFalse:[ |
|
1213 (coll := self selection) isCollection ifFalse:[ |
|
1214 coll := OrderedCollection with:coll |
|
1215 ]. |
|
1216 coll add:anObject. |
|
1217 self setSelection:coll withRedraw:false. |
|
1218 self showSelected:anObject. |
|
1219 self selectionChanged. |
|
1220 ] |
|
1221 ] |
|
1222 ] |
|
1223 ! |
|
1224 |
|
1225 moveableSelection |
|
1226 "tests whether all selected objects are moveable and in case |
|
1227 of true the selection is returned, otherwise nil |
|
1228 " |
|
1229 |coll| |
|
1230 |
|
1231 self hasSelection ifTrue:[ |
|
1232 (self canMove:(coll := self selection)) ifTrue:[ |
|
1233 ^ coll |
|
1234 ] |
|
1235 ]. |
|
1236 ^ nil |
1223 ! |
1237 ! |
1224 |
1238 |
1225 numberOfSelections |
1239 numberOfSelections |
1226 "return the number of selected entries |
1240 "return the number of selected entries |
1227 " |
1241 " |
1228 |sz| |
1242 |coll size| |
1229 |
1243 |
1230 selection isNil ifTrue:[^ 0]. |
1244 coll := self selection. |
1231 |
1245 size := coll size. |
1232 selection isCollection ifTrue:[^ selection size] |
1246 |
1233 ifFalse:[^ 1 ] |
1247 (size ~~ 0 or:[coll isNil]) ifTrue:[^ size]. |
1234 ! |
1248 ^ 1 |
1235 |
1249 ! |
1236 removeFromSelection:something |
1250 |
1237 "remove something from selection |
1251 removeFromSelection:anObject |
1238 " |
1252 "remove anObject from selection |
1239 something notNil ifTrue:[ |
1253 " |
1240 super removeFromSelection:something. |
1254 |sel| |
1241 self selectionChanged |
1255 |
1242 ]. |
1256 (self isSelected:anObject) ifFalse:[ |
1243 |
1257 ^ self |
|
1258 ]. |
|
1259 |
|
1260 sel := self selection. |
|
1261 |
|
1262 sel size > 1 ifTrue:[ |
|
1263 sel := sel copy. |
|
1264 sel remove:anObject ifAbsent:nil. |
|
1265 ] ifFalse:[ |
|
1266 sel := nil |
|
1267 ]. |
|
1268 self setSelection:sel withRedraw:true. |
|
1269 self selectionChanged. |
1244 ! |
1270 ! |
1245 |
1271 |
1246 select:something |
1272 select:something |
1247 "change selection to something |
1273 "change selection to something |
1248 " |
1274 " |
1249 (self canSelect:something) ifTrue:[ |
1275 (self enabled and:[something ~= self selection]) ifTrue:[ |
1250 super select:something. |
1276 self setSelection:something withRedraw:true. |
1251 self selectionChanged |
1277 self selectionChanged |
1252 ] |
1278 ] |
1253 |
1279 |
1254 |
1280 |
1255 |
1281 |
1268 " |
1294 " |
1269 self subclassResponsibility |
1295 self subclassResponsibility |
1270 |
1296 |
1271 ! |
1297 ! |
1272 |
1298 |
|
1299 selectionDo:aBlock |
|
1300 "apply block to every selected object |
|
1301 " |
|
1302 self forEach:(self selection) do:aBlock |
|
1303 |
|
1304 |
|
1305 ! |
|
1306 |
|
1307 setSelection:aNewSelection withRedraw:doRedraw |
|
1308 "set a new selection |
|
1309 " |
|
1310 doRedraw ifTrue:[ |
|
1311 self hideSelection. |
|
1312 selection := aNewSelection. |
|
1313 self showSelection |
|
1314 ] ifFalse:[ |
|
1315 selection := aNewSelection |
|
1316 ] |
|
1317 ! |
|
1318 |
1273 showSelection |
1319 showSelection |
|
1320 "show the selection - draw handles |
|
1321 " |
1274 selectionHiddenLevel == 0 ifTrue:[ |
1322 selectionHiddenLevel == 0 ifTrue:[ |
1275 super showSelection. |
1323 self selectionDo:[:el| self showSelected:el ] |
1276 ]. |
1324 ]. |
1277 ! |
1325 ! |
1278 |
1326 |
1279 singleSelection |
1327 singleSelection |
1280 "returns single selection or nil |
1328 "returns single selection or nil |
1281 " |
1329 " |
1282 selection isCollection ifFalse:[ |
1330 |coll| |
1283 ^ selection |
1331 |
1284 ]. |
1332 (coll := self selection) isCollection ifFalse:[ |
1285 selection size == 1 ifTrue:[ ^ selection at:1] |
1333 ^ coll |
1286 ifFalse:[ ^ nil]. |
1334 ]. |
|
1335 |
|
1336 coll size == 1 ifTrue:[ ^ coll first]. |
|
1337 ^ nil |
1287 ! |
1338 ! |
1288 |
1339 |
1289 singleSelectionDo:aBlock |
1340 singleSelectionDo:aBlock |
1290 "perform block with argument a view in case of one selection |
1341 "perform block with argument a view in case of one selection |
1291 " |
1342 " |
1431 isHorizontalResizable:aComponent |
1477 isHorizontalResizable:aComponent |
1432 "returns true if instance is horizontal resizeable |
1478 "returns true if instance is horizontal resizeable |
1433 " |
1479 " |
1434 ^ self subclassResponsibility |
1480 ^ self subclassResponsibility |
1435 |
1481 |
|
1482 |
|
1483 ! |
|
1484 |
|
1485 isSelected:anObject |
|
1486 "return true, if the argument, anObject is selected |
|
1487 " |
|
1488 anObject notNil ifTrue:[ |
|
1489 self selectionDo:[:el| el == anObject ifTrue:[^ true]] |
|
1490 ]. |
|
1491 ^ false |
1436 |
1492 |
1437 ! |
1493 ! |
1438 |
1494 |
1439 isVerticalResizable:aComponent |
1495 isVerticalResizable:aComponent |
1440 "returns true if instance is vertical resizeable |
1496 "returns true if instance is vertical resizeable |
1465 |
1521 |
1466 transaction:aType selectionDo:aOneArgBlock |
1522 transaction:aType selectionDo:aOneArgBlock |
1467 "opens a transaction and evaluates a block within the transaction; the |
1523 "opens a transaction and evaluates a block within the transaction; the |
1468 argument to the block is a view from the selection |
1524 argument to the block is a view from the selection |
1469 " |
1525 " |
1470 self transaction:aType objects:selection do:aOneArgBlock |
1526 self transaction:aType objects:(self selection) do:aOneArgBlock |
1471 |
1527 |
1472 |
1528 |
1473 ! |
1529 ! |
1474 |
1530 |
1475 undoLayoutView:aView |
1531 undoLayoutView:aView |
1643 !UIObjectView methodsFor:'user actions - move'! |
1699 !UIObjectView methodsFor:'user actions - move'! |
1644 |
1700 |
1645 moveSelectionDown |
1701 moveSelectionDown |
1646 "move selection down |
1702 "move selection down |
1647 " |
1703 " |
1648 |gridY n| |
1704 |gridY n sel| |
1649 |
1705 |
1650 (self canMove:selection) ifTrue:[ |
1706 self moveableSelection notNil ifTrue:[ |
1651 gridAlign notNil ifTrue:[gridY := gridAlign y]. |
1707 gridAlign notNil ifTrue:[gridY := gridAlign y]. |
1652 |
1708 |
1653 self withSelectionHiddenDo:[ |
1709 self withSelectionHiddenDo:[ |
1654 self selectionDo:[:aView| |
1710 self selectionDo:[:aView| |
1655 aligning ifTrue:[ |
1711 aligning ifTrue:[ |
1749 |
1805 |
1750 alignSelectionBottom |
1806 alignSelectionBottom |
1751 "align selection to the bottom of the first object in the selection; in case |
1807 "align selection to the bottom of the first object in the selection; in case |
1752 of one selection the object is aligned to the bottom of its superview |
1808 of one selection the object is aligned to the bottom of its superview |
1753 " |
1809 " |
1754 |bmost delta| |
1810 |bmost delta sel| |
1755 |
1811 |
1756 (self canMove:selection) ifTrue:[ |
1812 (sel := self moveableSelection) notNil ifTrue:[ |
1757 self withSelectionHiddenDo:[ |
1813 self withSelectionHiddenDo:[ |
1758 self numberOfSelections > 1 ifTrue:[ |
1814 self numberOfSelections > 1 ifTrue:[ |
1759 bmost := (selection at:1) computeCorner y. |
1815 bmost := (sel first) computeCorner y. |
1760 |
1816 |
1761 self transaction:#alignBottom selectionDo:[:v| |
1817 self transaction:#alignBottom selectionDo:[:v| |
1762 (delta := bmost - (v computeCorner y)) ~~ 0 ifTrue:[ |
1818 (delta := bmost - (v computeCorner y)) ~~ 0 ifTrue:[ |
1763 self shiftLayout:v top:delta bottom:delta. |
1819 self shiftLayout:v top:delta bottom:delta. |
1764 ] |
1820 ] |
1779 |
1835 |
1780 alignSelectionCenterHor |
1836 alignSelectionCenterHor |
1781 "align selection to the center/horizontal of the first object in the selection; in case |
1837 "align selection to the center/horizontal of the first object in the selection; in case |
1782 of one selection the object is aligned to the center/horizontal of its superview |
1838 of one selection the object is aligned to the center/horizontal of its superview |
1783 " |
1839 " |
1784 |view center| |
1840 |view center sel| |
1785 |
1841 |
1786 (self canMove:selection) ifTrue:[ |
1842 (sel := self moveableSelection) notNil ifTrue:[ |
1787 self withSelectionHiddenDo:[ |
1843 self withSelectionHiddenDo:[ |
1788 view := self singleSelection. |
1844 view := self singleSelection. |
1789 |
1845 |
1790 view notNil ifTrue:[ |
1846 view notNil ifTrue:[ |
1791 view := view superView. |
1847 view := view superView. |
1792 center := view computeExtent |
1848 center := view computeExtent |
1793 ] ifFalse:[ |
1849 ] ifFalse:[ |
1794 view := selection at:1. |
1850 view := sel first. |
1795 center := view computeCorner + view computeOrigin. |
1851 center := view computeCorner + view computeOrigin. |
1796 ]. |
1852 ]. |
1797 center := center x // 2. |
1853 center := center x // 2. |
1798 |
1854 |
1799 self transaction:#alignCenterHorizontal selectionDo:[:v| |
1855 self transaction:#alignCenterHorizontal selectionDo:[:v| |
1815 |
1871 |
1816 alignSelectionCenterVer |
1872 alignSelectionCenterVer |
1817 "align selection to the center/vertical of the first object in the selection; in case |
1873 "align selection to the center/vertical of the first object in the selection; in case |
1818 of one selection the object is aligned to the center/vertical of its superview |
1874 of one selection the object is aligned to the center/vertical of its superview |
1819 " |
1875 " |
1820 |view center| |
1876 |view center sel| |
1821 |
1877 |
1822 (self canMove:selection) ifTrue:[ |
1878 (sel := self moveableSelection) notNil ifTrue:[ |
1823 self withSelectionHiddenDo:[ |
1879 self withSelectionHiddenDo:[ |
1824 view := self singleSelection. |
1880 view := self singleSelection. |
1825 |
1881 |
1826 view notNil ifTrue:[ |
1882 view notNil ifTrue:[ |
1827 view := view superView. |
1883 view := view superView. |
1828 center := view computeExtent |
1884 center := view computeExtent |
1829 ] ifFalse:[ |
1885 ] ifFalse:[ |
1830 view := selection at:1. |
1886 view := sel first. |
1831 center := view computeCorner + view computeOrigin. |
1887 center := view computeCorner + view computeOrigin. |
1832 ]. |
1888 ]. |
1833 center := center y // 2. |
1889 center := center y // 2. |
1834 |
1890 |
1835 self transaction:#alignCenterVertical selectionDo:[:v| |
1891 self transaction:#alignCenterVertical selectionDo:[:v| |
1848 |
1904 |
1849 alignSelectionLeft |
1905 alignSelectionLeft |
1850 "align selection to the left of the first object in the selection; in case |
1906 "align selection to the left of the first object in the selection; in case |
1851 of one selection the object is aligned to the left of its superview |
1907 of one selection the object is aligned to the left of its superview |
1852 " |
1908 " |
1853 |lmost delta| |
1909 |lmost delta sel| |
1854 |
1910 |
1855 (self canMove:selection) ifTrue:[ |
1911 (sel := self moveableSelection) notNil ifTrue:[ |
1856 self withSelectionHiddenDo:[ |
1912 self withSelectionHiddenDo:[ |
1857 self numberOfSelections > 1 ifTrue:[ |
1913 self numberOfSelections > 1 ifTrue:[ |
1858 lmost := (selection at:1) computeOrigin x. |
1914 lmost := (sel first) computeOrigin x. |
1859 |
1915 |
1860 self transaction:#alignLeft selectionDo:[:v| |
1916 self transaction:#alignLeft selectionDo:[:v| |
1861 (delta := lmost - (v computeOrigin x)) ~~ 0 ifTrue:[ |
1917 (delta := lmost - (v computeOrigin x)) ~~ 0 ifTrue:[ |
1862 self shiftLayout:v left:delta right:delta |
1918 self shiftLayout:v left:delta right:delta |
1863 ] |
1919 ] |
1875 |
1931 |
1876 alignSelectionLeftAndRight |
1932 alignSelectionLeftAndRight |
1877 "align selection to the left/right of the first object in the selection; in case |
1933 "align selection to the left/right of the first object in the selection; in case |
1878 of one selection the object is aligned to the left/right of its superview |
1934 of one selection the object is aligned to the left/right of its superview |
1879 " |
1935 " |
1880 |lmost rmost| |
1936 |lmost rmost sel| |
1881 |
1937 |
1882 (self canMove:selection) ifTrue:[ |
1938 (sel := self moveableSelection) notNil ifTrue:[ |
1883 self withSelectionHiddenDo:[ |
1939 self withSelectionHiddenDo:[ |
1884 self numberOfSelections > 1 ifTrue:[ |
1940 self numberOfSelections > 1 ifTrue:[ |
1885 lmost := (selection at:1) computeOrigin x. |
1941 lmost := (sel first) computeOrigin x. |
1886 rmost := (selection at:1) computeCorner x. |
1942 rmost := (sel first) computeCorner x. |
1887 |
1943 |
1888 self transaction:#alignLeftRight selectionDo:[:aView| |
1944 self transaction:#alignLeftRight selectionDo:[:aView| |
1889 |layout| |
1945 |layout| |
1890 layout := self class asLayoutFrameFromView:aView. |
1946 layout := self class asLayoutFrameFromView:aView. |
1891 |
1947 |
1916 |
1972 |
1917 alignSelectionRight |
1973 alignSelectionRight |
1918 "align selection to the right of the first object in the selection; in case |
1974 "align selection to the right of the first object in the selection; in case |
1919 of one selection the object is aligned to the right of its superview |
1975 of one selection the object is aligned to the right of its superview |
1920 " |
1976 " |
1921 |rmost delta| |
1977 |rmost delta sel| |
1922 |
1978 |
1923 (self canMove:selection) ifTrue:[ |
1979 (sel := self moveableSelection) notNil ifTrue:[ |
1924 self withSelectionHiddenDo:[ |
1980 self withSelectionHiddenDo:[ |
1925 self numberOfSelections > 1 ifTrue:[ |
1981 self numberOfSelections > 1 ifTrue:[ |
1926 rmost := (selection at:1) computeCorner x. |
1982 rmost := (sel first) computeCorner x. |
1927 |
1983 |
1928 self transaction:#alignRight selectionDo:[:v| |
1984 self transaction:#alignRight selectionDo:[:v| |
1929 (delta := rmost - (v computeCorner x)) ~~ 0 ifTrue:[ |
1985 (delta := rmost - (v computeCorner x)) ~~ 0 ifTrue:[ |
1930 self shiftLayout:v left:delta right:delta |
1986 self shiftLayout:v left:delta right:delta |
1931 ] |
1987 ] |
1943 |
1999 |
1944 alignSelectionTop |
2000 alignSelectionTop |
1945 "align selection to the top of the first object in the selection; in case |
2001 "align selection to the top of the first object in the selection; in case |
1946 of one selection the object is aligned to the top of its superview |
2002 of one selection the object is aligned to the top of its superview |
1947 " |
2003 " |
1948 |tmost delta| |
2004 |tmost delta sel| |
1949 |
2005 |
1950 (self canMove:selection) ifTrue:[ |
2006 (sel := self moveableSelection) notNil ifTrue:[ |
1951 self withSelectionHiddenDo:[ |
2007 self withSelectionHiddenDo:[ |
1952 self numberOfSelections > 1 ifTrue:[ |
2008 self numberOfSelections > 1 ifTrue:[ |
1953 tmost := (selection at:1) computeOrigin y. |
2009 tmost := (sel first) computeOrigin y. |
1954 |
2010 |
1955 self transaction:#alignTop selectionDo:[:v| |
2011 self transaction:#alignTop selectionDo:[:v| |
1956 (delta := tmost - (v computeOrigin y)) ~~ 0 ifTrue:[ |
2012 (delta := tmost - (v computeOrigin y)) ~~ 0 ifTrue:[ |
1957 self shiftLayout:v top:delta bottom:delta |
2013 self shiftLayout:v top:delta bottom:delta |
1958 ] |
2014 ] |
1971 |
2027 |
1972 alignSelectionTopAndBottom |
2028 alignSelectionTopAndBottom |
1973 "align selection to the top/bottom of the first object in the selection; in case |
2029 "align selection to the top/bottom of the first object in the selection; in case |
1974 of one selection the object is aligned to the top/bottom of its superview |
2030 of one selection the object is aligned to the top/bottom of its superview |
1975 " |
2031 " |
1976 |tmost bmost| |
2032 |tmost bmost sel| |
1977 |
2033 |
1978 (self canMove:selection) ifTrue:[ |
2034 (sel := self moveableSelection) notNil ifTrue:[ |
1979 self withSelectionHiddenDo:[ |
2035 self withSelectionHiddenDo:[ |
1980 self numberOfSelections > 1 ifTrue:[ |
2036 self numberOfSelections > 1 ifTrue:[ |
1981 tmost := (selection at:1) computeOrigin y. |
2037 tmost := (sel first) computeOrigin y. |
1982 bmost := (selection at:1) computeCorner y. |
2038 bmost := (sel first) computeCorner y. |
1983 |
2039 |
1984 self transaction:#alignTopBottom selectionDo:[:aView| |
2040 self transaction:#alignTopBottom selectionDo:[:aView| |
1985 |layout| |
2041 |layout| |
1986 layout := self class asLayoutFrameFromView:aView. |
2042 layout := self class asLayoutFrameFromView:aView. |
1987 |
2043 |
2013 "center selection horizontal or vertical dependant on the block result( x or y). |
2069 "center selection horizontal or vertical dependant on the block result( x or y). |
2014 The argument to the block is the point. |
2070 The argument to the block is the point. |
2015 " |
2071 " |
2016 |superview min max delta val| |
2072 |superview min max delta val| |
2017 |
2073 |
2018 (self canMove:selection) ifFalse:[ |
2074 (self moveableSelection) isNil ifTrue:[ |
2019 ^ self |
2075 ^ self |
2020 ]. |
2076 ]. |
2021 |
2077 |
2022 self withSelectionHiddenDo:[ |
2078 self withSelectionHiddenDo:[ |
2023 max := 0. |
2079 max := 0. |
2116 ifFalse:[min := min min:(aView left)]. |
2174 ifFalse:[min := min min:(aView left)]. |
2117 |
2175 |
2118 max := max max:(aView right). |
2176 max := max max:(aView right). |
2119 count := count + 1 |
2177 count := count + 1 |
2120 ]. |
2178 ]. |
2121 viewsInOrder := Array withAll:selection. |
2179 viewsInOrder := Array withAll:sel. |
2122 topsInOrder := viewsInOrder collect:[:aView | aView left]. |
2180 topsInOrder := viewsInOrder collect:[:aView | aView left]. |
2123 topsInOrder sortWith:viewsInOrder. |
2181 topsInOrder sortWith:viewsInOrder. |
2124 |
2182 |
2125 space := (((max - min) - sumWidths) / (count - 1)) rounded asInteger. |
2183 space := (((max - min) - sumWidths) / (count - 1)) rounded asInteger. |
2126 |
2184 |
2157 ifFalse:[min := min min:(aView top)]. |
2217 ifFalse:[min := min min:(aView top)]. |
2158 |
2218 |
2159 max := max max:(aView bottom). |
2219 max := max max:(aView bottom). |
2160 count := count + 1 |
2220 count := count + 1 |
2161 ]. |
2221 ]. |
2162 viewsInOrder := Array withAll:selection. |
2222 viewsInOrder := Array withAll:sel. |
2163 topsInOrder := viewsInOrder collect:[:aView|aView top]. |
2223 topsInOrder := viewsInOrder collect:[:aView|aView top]. |
2164 topsInOrder sortWith:viewsInOrder. |
2224 topsInOrder sortWith:viewsInOrder. |
2165 |
2225 |
2166 space := (((max - min) - sumHeights) / (count - 1)) rounded asInteger. |
2226 space := (((max - min) - sumHeights) / (count - 1)) rounded asInteger. |
2167 |
2227 |