-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
418 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
Extension { #name : #RSAlignment } | ||
|
||
{ #category : #'*Roassal-Class-Examples' } | ||
RSAlignment class >> exampleAlignBottom [ | ||
| canvas boxes | | ||
canvas := RSCanvas new. | ||
boxes := (1 to: 5) collect: [ :v | | ||
RSBox new | ||
color: Color gray translucent; | ||
size: v * 5 ] as: RSGroup. | ||
RSHorizontalLineLayout new alignBottom; on: boxes. | ||
"align := self new. | ||
align shapes: boxes. | ||
align bottom." | ||
canvas addAll: boxes. | ||
^ canvas open | ||
] | ||
|
||
{ #category : #'*Roassal-Class-Examples' } | ||
RSAlignment class >> exampleAlignCenter [ | ||
| canvas boxes | | ||
canvas := RSCanvas new. | ||
boxes := (1 to: 5) collect: [ :v | RSBox new size: v * 5 ] as: RSGroup. | ||
RSVerticalLineLayout new alignCenter; on: boxes. | ||
|
||
"align := self new. | ||
align shapes: boxes. | ||
align center." | ||
canvas addAll: boxes. | ||
^ canvas open | ||
] | ||
|
||
{ #category : #'*Roassal-Class-Examples' } | ||
RSAlignment class >> exampleAlignLabel [ | ||
| canvas labels | | ||
canvas := RSCanvas new. | ||
labels := (1 to: 5) collect: [ :v | | ||
RSLabel new | ||
text: v; | ||
fontSize: v * 5 ] as: RSGroup. | ||
RSHorizontalLineLayout new alignLabel; on: labels. | ||
|
||
"align := self new. | ||
align shapes: labels. | ||
align label." | ||
canvas addAll: labels. | ||
"note that each label, have different encompassing rectangle" | ||
canvas showEncompassingRectangles. | ||
^ canvas open | ||
] | ||
|
||
{ #category : #'*Roassal-Class-Examples' } | ||
RSAlignment class >> exampleAlignMiddle [ | ||
| canvas boxes | | ||
canvas := RSCanvas new. | ||
boxes := (1 to: 5) collect: [ :v | | ||
RSBox new | ||
color: Color gray translucent; | ||
size: v * 5 ] as: RSGroup. | ||
RSHorizontalLineLayout new alignMiddle; on: boxes. | ||
"align := self new. | ||
align shapes: boxes. | ||
align middle." | ||
canvas addAll: boxes. | ||
^ canvas open | ||
] | ||
|
||
{ #category : #'*Roassal-Class-Examples' } | ||
RSAlignment class >> exampleAlignRight [ | ||
| canvas boxes | | ||
canvas := RSCanvas new. | ||
boxes := (1 to: 5) collect: [ :v | RSBox new size: v * 5 ] as: RSGroup. | ||
RSVerticalLineLayout new alignRight; on: boxes. | ||
|
||
"align := self new. | ||
align shapes: boxes. | ||
align right." | ||
canvas addAll: boxes. | ||
^ canvas open | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
Extension { #name : #RSCircleLayout } | ||
|
||
{ #category : #'*Roassal-Class-Examples' } | ||
RSCircleLayout class >> example1 [ | ||
| aLayout objects | | ||
aLayout := self new. | ||
aLayout center: 200@200. | ||
aLayout radius: 100. | ||
objects := RSBox models: (1 to: 10). | ||
aLayout on: objects. | ||
^ RSCanvas new | ||
addAll: objects; | ||
@ RSCanvasController; | ||
open | ||
] | ||
|
||
{ #category : #'*Roassal-Class-Examples' } | ||
RSCircleLayout class >> example2 [ | ||
| nodes canvas shapes | | ||
nodes := (1 to: 5). | ||
|
||
canvas := RSCanvas new. | ||
shapes := RSCircle models: nodes. | ||
shapes size: 30. | ||
canvas addAll: shapes. | ||
|
||
self new radius: 20; on: shapes. | ||
canvas @ RSCanvasController. | ||
^ canvas open | ||
] |
28 changes: 28 additions & 0 deletions
28
src/Roassal-Class-Examples/RSClusterRadialTreeLayout.extension.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
Extension { #name : #RSClusterRadialTreeLayout } | ||
|
||
{ #category : #'*Roassal-Class-Examples' } | ||
RSClusterRadialTreeLayout class >> exampleWithNumber [ | ||
| canvas shapes color | | ||
canvas := RSCanvas new. | ||
|
||
color := RSColorPalette sequential bupu3. | ||
shapes := (1 to: 100) collect: [ :m | | ||
RSBox new | ||
size: 7; | ||
model: m; | ||
draggable; | ||
withBorder; | ||
color: (color scale: m); | ||
yourself. | ||
]. | ||
RSLineBuilder line | ||
shapes: shapes; | ||
canvas: canvas; | ||
connectFrom: [ :n | n // 2 ]. | ||
canvas edges do: #withBorder. | ||
canvas addAll: shapes. | ||
canvas shapes @ RSHighlightable red. | ||
self on: shapes. | ||
canvas zoomToFit. | ||
^ canvas open | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Extension { #name : #RSFlowLayout } | ||
|
||
{ #category : #'*Roassal-Class-Examples' } | ||
RSFlowLayout class >> exampleLabel [ | ||
|
||
| words r wordShapes c | | ||
words := (String loremIpsum: 100) substrings. | ||
r := Random new. | ||
wordShapes := words collect: [ :w | | ||
RSLabel new | ||
fontSize: (r nextInteger: 30); | ||
text: w ] as: RSGroup. | ||
|
||
c := RSCanvas new. | ||
c addAll: wordShapes. | ||
self new alignLabel; on: wordShapes. | ||
c @ RSCanvasController. | ||
^ c open | ||
] |
18 changes: 18 additions & 0 deletions
18
src/Roassal-Class-Examples/RSHorizontalFlowLayout.extension.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
Extension { #name : #RSHorizontalFlowLayout } | ||
|
||
{ #category : #'*Roassal-Class-Examples' } | ||
RSHorizontalFlowLayout class >> exampleLabel [ | ||
|
||
| string characterShapes c | | ||
string := 'KISSItemSameStar'. | ||
characterShapes := RSLabel models: string. | ||
|
||
c := RSCanvas new. | ||
c addAll: characterShapes. | ||
|
||
self new maxWidth: characterShapes first height * 4; alignCenter; gapSize: 0; on: characterShapes. | ||
|
||
c @ RSCanvasController. | ||
c showEncompassingRectangles. | ||
^ c open | ||
] |
35 changes: 35 additions & 0 deletions
35
src/Roassal-Class-Examples/RSHorizontalLineLayout.extension.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
Extension { #name : #RSHorizontalLineLayout } | ||
|
||
{ #category : #'*Roassal-Class-Examples' } | ||
RSHorizontalLineLayout class >> example1 [ | ||
| c | | ||
c := self canvasExample. | ||
self new | ||
alignMiddle; | ||
gapSize: 30; | ||
on: c nodes. | ||
^ c open | ||
] | ||
|
||
{ #category : #'*Roassal-Class-Examples' } | ||
RSHorizontalLineLayout class >> exampleLabel [ | ||
| c | | ||
c := RSCanvas new. | ||
c addAll: (#(This is very important) collect: [ :string | | label | | ||
label := RSLabel new | ||
text: string; | ||
color: Color black; | ||
yourself. | ||
string == #This | ||
ifTrue: [ label bold; color: Color blue; fontSize: 20 ]. | ||
string == #important | ||
ifTrue: [ label bold; color: Color red; fontSize: 30 ]. | ||
label | ||
] ). | ||
c @ RSCanvasController. | ||
self new | ||
alignLabel; | ||
gapSize: 3; | ||
on: c nodes. | ||
^ c open | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
Extension { #name : #RSLayout } | ||
|
||
{ #category : #'*Roassal-Class-Examples' } | ||
RSLayout class >> basicExample [ | ||
| canvas | | ||
canvas := self canvasExample. | ||
self on: canvas nodes. | ||
^ canvas open | ||
] | ||
|
||
{ #category : #'*Roassal-Class-Examples' } | ||
RSLayout class >> canvasExample [ | ||
| canvas | | ||
canvas := RSCanvas new. | ||
self canvasExampleIn: canvas. | ||
canvas @ RSCanvasController. | ||
^ canvas | ||
] | ||
|
||
{ #category : #'*Roassal-Class-Examples' } | ||
RSLayout class >> canvasExampleIn: canvas [ | ||
self canvasExampleIn: canvas models: Collection withAllSubclasses | ||
] | ||
|
||
{ #category : #'*Roassal-Class-Examples' } | ||
RSLayout class >> canvasExampleIn: canvas models: aCollection [ | ||
| shapes colorPalette | | ||
self cartensianLinesIn: canvas. | ||
shapes := RSBox models: aCollection. | ||
canvas addAll: shapes. | ||
colorPalette := NSScale category20c. | ||
shapes do: [ :shape | | ||
shape color: (colorPalette scale: shape model) | ||
]. | ||
shapes | ||
@ RSPopup new; | ||
@ RSDraggable new. | ||
RSLineBuilder arrowedLine | ||
shapes: shapes; | ||
withBorderAttachPoint; | ||
connectFrom: #superclass. | ||
RSNormalizer size | ||
shapes: shapes; | ||
normalize: #linesOfCode | ||
] | ||
|
||
{ #category : #'*Roassal-Class-Examples' } | ||
RSLayout class >> cartensianLinesIn: canvas [ | ||
| lineX lineY zeroLabel | | ||
lineX := RSArrowedLine new | ||
color: Color black; | ||
startPoint: 0@0; | ||
endPoint: 300@0; | ||
yourself. | ||
lineY := lineX copy | ||
startPoint: 0@0; | ||
endPoint: 0 @ 300; | ||
yourself. | ||
zeroLabel := RSLabel new | ||
text: '0@0'; | ||
addInteraction: (RSPopup themeText: 'Origin in a box of 300@300'); | ||
position: 0@0; | ||
color: Color black; | ||
yourself. | ||
canvas | ||
addShape: lineX; | ||
addShape: lineY; | ||
addShape: zeroLabel | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
Extension { #name : #RSLayoutBuilder } | ||
|
||
{ #category : #'*Roassal-Class-Examples' } | ||
RSLayoutBuilder class >> exampleTidyTree [ | ||
| canvas notConnected | | ||
canvas := RSCanvas new. | ||
canvas @ RSCanvasController. | ||
notConnected := {self. RSEvent. RSShape }. | ||
RSLayout | ||
canvasExampleIn: canvas | ||
models: SequenceableCollection withAllSubclasses, | ||
Set withAllSubclasses, notConnected. | ||
self new tidyTree; on: canvas nodes. | ||
^ canvas open. | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
Extension { #name : #RSLocation } | ||
|
||
{ #category : #'*Roassal-Class-Examples' } | ||
RSLocation class >> example1 [ | ||
| canvas box1 box2 label | | ||
canvas := RSCanvas new. | ||
|
||
box1 := RSBox new size: 50; color: Color gray translucent. | ||
box2 := RSBox new size: 30; color: Color gray translucent. | ||
box1 @ RSDraggable. | ||
box2 @ RSDraggable. | ||
canvas add: box1; add: box2. | ||
|
||
box1 translateBy: 150 @ -40. | ||
|
||
label := RSLabel new text: 'Move the mouse above me'. | ||
canvas add: label. | ||
self new | ||
above; | ||
stick: label on: box1. | ||
^ canvas open | ||
] | ||
|
||
{ #category : #'*Roassal-Class-Examples' } | ||
RSLocation class >> example2 [ | ||
| canvas group baseShape redShape | | ||
canvas := RSCanvas new. | ||
|
||
group := RSGroup new. | ||
group add: (RSLabel new text: 'Base shape, drag me'). | ||
baseShape := group asShape adjustToChildren. | ||
baseShape color: #lightBlue. | ||
baseShape @ RSDraggable. | ||
canvas add: baseShape. | ||
|
||
redShape := RSBox new extent: 60 @ 30; color: #red. | ||
canvas add: redShape. | ||
|
||
self new | ||
bottom; | ||
outer; | ||
right; | ||
offset: 20@0; | ||
stick: redShape on: baseShape. | ||
"Try changing stick:on: by move:on. Replacing bottom by top" | ||
^ canvas open | ||
] |
36 changes: 36 additions & 0 deletions
36
src/Roassal-Class-Examples/RSRectanglePackLayout.extension.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
Extension { #name : #RSRectanglePackLayout } | ||
|
||
{ #category : #'*Roassal-Class-Examples' } | ||
RSRectanglePackLayout class >> example1 [ | ||
<noTest> | ||
| numberOfBoxes random shapes canvas | | ||
numberOfBoxes := 900. | ||
random := Random seed: 42. | ||
shapes := RSGroup new. | ||
numberOfBoxes timesRepeat: [ | ||
shapes add: (RSBox new width: (random nextInteger: 40); height: (random nextInteger: 40)) ]. | ||
|
||
canvas := RSCanvas new. | ||
canvas addAll: shapes. | ||
self new useProgressBar; on: shapes. | ||
canvas @ RSCanvasController. | ||
^ canvas open | ||
] | ||
|
||
{ #category : #'*Roassal-Class-Examples' } | ||
RSRectanglePackLayout class >> example2 [ | ||
| nodes canvas shapes | | ||
nodes := (1 to: 20) asArray shuffleBy: (Random seed: 42). | ||
|
||
canvas := RSCanvas new. | ||
shapes := RSCircle models: nodes. | ||
shapes size: 30. | ||
canvas addAll: shapes. | ||
RSNormalizer size | ||
shapes: shapes; | ||
normalize. | ||
|
||
self on: shapes. | ||
canvas zoomToFit. | ||
^ canvas open | ||
] |
Oops, something went wrong.