Skip to content

Commit

Permalink
first shot
Browse files Browse the repository at this point in the history
  • Loading branch information
akevalion committed Oct 6, 2023
1 parent dce7301 commit 24a5cfc
Show file tree
Hide file tree
Showing 92 changed files with 8,515 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
'srcDirectory' : 'src'
}
3 changes: 3 additions & 0 deletions src/.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
#format : #tonel
}
21 changes: 21 additions & 0 deletions src/BaselineOfRoassalLayouts/BaselineOfRoassalLayouts.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"
Based on roassal
https://github.com/ObjectProfile/Roassal3
"
Class {
#name : #BaselineOfRoassalLayouts,
#superclass : #BaselineOf,
#category : #BaselineOfRoassalLayouts
}

{ #category : #baselines }
BaselineOfRoassalLayouts >> baseline: spec [
<baseline>
spec for: #common do: [
spec
package: 'Roassal-Layouts';
package: 'Roassal-Layouts-Tests';
package: 'Roassal-Layouts-Util'.
spec group: 'default' with: 'Roassal-Layouts'
].
]
1 change: 1 addition & 0 deletions src/BaselineOfRoassalLayouts/package.st
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Package { #name : #BaselineOfRoassalLayouts }
136 changes: 136 additions & 0 deletions src/Roassal-Layouts-Tests/RSAlignmentTest.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
Class {
#name : #RSAlignmentTest,
#superclass : #TestCase,
#instVars : [
'align'
],
#category : #'Roassal-Layouts-Tests'
}

{ #category : #running }
RSAlignmentTest >> setUp [
super setUp.
align := RSAlignment new
]

{ #category : #tests }
RSAlignmentTest >> testCenter [
| es |
es := (1 to: 5) collect: [ :v | RSBox new size: 10 ] as: RSGroup.
RSHorizontalLineLayout on: es.
align shapes: es.
self assert: align middle equals: align.
self assert: es encompassingRectangle equals: ((0.0@0.0) corner: (70.0@10.0))
]

{ #category : #tests }
RSAlignmentTest >> testFromBottom [
| es |
es := (10 to: 100 by: 10) collect: [ :n | RSBox new size: n; yourself ].
align shapes: es.
RSHorizontalLineLayout on: es.
es second translateBy: 0 @ 150.
self assert: (es collect: [ :e | e encompassingRectangle bottom ]) asArray equals: #(10.0 170.0 30.0 40.0 50.0 60.0 70.0 80.0 90.0 100.0).
self assert: align bottomMostShape equals: es second.
align bottom.
self assert: (es collect: [ :e | e encompassingRectangle bottom ]) asArray equals: #(170.0 170.0 170.0 170.0 170.0 170.0 170.0 170.0 170.0 170.0)
]

{ #category : #tests }
RSAlignmentTest >> testFromLeft [
| es |
es := (10 to: 100 by: 10) collect: [ :n | RSBox new size: n; yourself ].
align shapes: es.
RSVerticalLineLayout on: es.
es second translateBy: -150 @ 0.
self assert: (es collect: [ :e | e encompassingRectangle left ]) asArray equals: #(0.0 -150.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0).
self assert: align leftMostShape equals: es second.
align left.
self assert: (es collect: [ :e | e encompassingRectangle left ]) asArray equals: #(-150.0 -150.0 -150.0 -150.0 -150.0 -150.0 -150.0 -150.0 -150.0 -150.0)
]

{ #category : #tests }
RSAlignmentTest >> testFromLeftWithAFixShape [
| es |
es := (10 to: 100 by: 10) collect: [ :n | RSBox new size: n; yourself ].
align shapes: es.
RSVerticalLineLayout on: es.
es second translateBy: -150 @ 0.
align fixedShape: es first.
align left.
self assert: (es collect: [ :e | e encompassingRectangle left ]) asArray equals: #(0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0)
]

{ #category : #tests }
RSAlignmentTest >> testFromLeftWithFixedShape [
| es c |
es := (10 to: 100 by: 10) collect: [ :n | RSBox new size: n; yourself ].
align shapes: es.
RSVerticalLineLayout on: es.
es second translateBy: -150 @ 0.

c := RSCanvas new.
c addAll: es.
es do: [ :s | s setAsFixed ].

self assert: (es collect: [ :e | e encompassingRectangle left ]) asArray equals: #(0.0 -150.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0).
self assert: align leftMostShape equals: es second.
align left.
self assert: (es collect: [ :e | e encompassingRectangle left ]) asArray equals: #(-150.0 -150.0 -150.0 -150.0 -150.0 -150.0 -150.0 -150.0 -150.0 -150.0)
]

{ #category : #tests }
RSAlignmentTest >> testFromRight [
| es |
es := (10 to: 100 by: 10) collect: [ :n | RSBox new size: n; yourself ].
align shapes: es.
RSVerticalLineLayout on: es.
es second translateBy: 150 @ 0.
self assert: (es collect: [ :e | e encompassingRectangle right ]) asArray equals: #(10.0 170.0 30.0 40.0 50.0 60.0 70.0 80.0 90.0 100.0).
self assert: align rightMostShape equals: es second.
align right.
self assert: (es collect: [ :e | e encompassingRectangle right ]) asArray equals: #(170.0 170.0 170.0 170.0 170.0 170.0 170.0 170.0 170.0 170.0)
]

{ #category : #tests }
RSAlignmentTest >> testFromTop [
| es |
es := (10 to: 100 by: 10) collect: [ :n | RSBox new size: n; yourself ].
align shapes: es.
RSHorizontalLineLayout on: es.
es second translateBy: 0 @ -50.
self assert: (es collect: [ :e | e encompassingRectangle top ]) asArray equals: #(0.0 -50.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0).
self assert: align topMostShape equals: es second.
align top.
self assert: (es collect: [ :e | e encompassingRectangle top ]) asArray equals: #(-50.0 -50.0 -50.0 -50.0 -50.0 -50.0 -50.0 -50.0 -50.0 -50.0)
]

{ #category : #tests }
RSAlignmentTest >> testFromTopWithAFixShape [
| es |
es := (10 to: 100 by: 10) collect: [ :n | RSBox new size: n; yourself ].
align shapes: es.
RSHorizontalLineLayout on: es.
es second translateBy: 0 @ -50.
align fixedShape: es third.

self assert: (es collect: [ :e | e encompassingRectangle top ]) asArray equals: #(0.0 -50.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0).
self assert: align topMostShape equals: es third.
align top.
self assert: (es collect: [ :e | e encompassingRectangle top ]) asArray equals: #(0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0)
]

{ #category : #tests }
RSAlignmentTest >> testHasElement [
self deny: align hasShape.
align shapes: (Array with: RSBox new).
self assert: align hasShape.
align shapes: #().
self deny: align hasShape
]

{ #category : #tests }
RSAlignmentTest >> testNoErrorOnDefault [

RSAlignment new left; right; top; bottom
]
68 changes: 68 additions & 0 deletions src/Roassal-Layouts-Tests/RSAngleLineLayoutTest.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
Class {
#name : #RSAngleLineLayoutTest,
#superclass : #RSLayoutTest,
#category : #'Roassal-Layouts-Tests'
}

{ #category : #tests }
RSAngleLineLayoutTest >> testBasic [

| layout angle |
layout := RSAngleLineLayout new.
self assert: layout angle equals: layout defaultAngle.
angle := 45 degreesToRadians.
layout angle: angle.
self assert: layout angle equals: angle
]

{ #category : #tests }
RSAngleLineLayoutTest >> testGapSize [

| layout var1st var2nd |
layout := RSAngleLineLayout new gapSize: 100.
layout on: shapes.
var1st := shapes first.
var2nd := shapes second.
self assert: var1st position closeTo: 2.5 @ 2.5.
self assert: var2nd position closeTo: 107.5 @ 2.5
]

{ #category : #tests }
RSAngleLineLayoutTest >> testLayoutWith0Angle [

| layout x gap |
layout := RSAngleLineLayout new angle: 0.
gap := layout gapSize.
layout on: shapes.
x := 2.5.
shapes do: [ :each |
self assert: each position closeTo: x @ 2.5.
x := x + each width + gap ]
]

{ #category : #tests }
RSAngleLineLayoutTest >> testLayoutWith90Angle [

| layout y gap |
layout := RSAngleLineLayout new.
layout angleByDegrees: 90.
gap := layout gapSize.
layout on: shapes.
y := 2.5.
shapes do: [ :each |
self assert: each position closeTo: 2.5 @ y.
y := y + each height + gap ]
]

{ #category : #tests }
RSAngleLineLayoutTest >> testLayoutWithThreeElements [
| layout gap extent |
layout := RSAngleLineLayout new.
gap := layout gapSize.
shapes := shapes first: 3.
extent := shapes first extent.
layout on: shapes.
self assert: shapes first position equals: extent * (0.5@ 0.5).
self assert: shapes second position equals: extent * (1.5 @ 0.5) + (gap@0).
self assert: shapes third position equals: extent * (2.5 @ 0.5) + (gap*2@0).
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
"
A RSCircularAroundAVertexLayoutTest is a test class for testing the behavior of RSCircularAroundAVertexLayout
"
Class {
#name : #RSCircularAroundAVertexLayoutTest,
#superclass : #RSLayoutTest,
#category : #'Roassal-Layouts-Tests'
}

{ #category : #tests }
RSCircularAroundAVertexLayoutTest >> testApplyDefaultLayoutOverlapsShapes [
| layout first second |
layout := RSCircularAroundAVertexLayout new.
layout on: canvas nodes.
first := canvas nodes first.
second := canvas nodes second.
self deny: (first encompassingRectangle intersects: second encompassingRectangle).
self deny: first position equals: second position.
]

{ #category : #tests }
RSCircularAroundAVertexLayoutTest >> testApplyLayoutShouldChangeOldPositions [
| layout oldPositions |
layout := RSCircularAroundAVertexLayout new.
oldPositions := canvas nodes collect: #position.
layout on: canvas nodes.
self deny: (canvas nodes collect: #position) equals: oldPositions
]

{ #category : #tests }
RSCircularAroundAVertexLayoutTest >> testRadius [
| layout boundingBox |
layout := RSCircularAroundAVertexLayout new.
layout radius: 1000.
layout on: canvas nodes.

boundingBox := canvas encompassingRectangle.
self assert: boundingBox width > 100
]
Loading

0 comments on commit 24a5cfc

Please sign in to comment.