Skip to content

Commit

Permalink
PenShape is now based on Geometry package
Browse files Browse the repository at this point in the history
  • Loading branch information
nolwennfournier committed Jan 24, 2020
1 parent 451c728 commit a83782d
Show file tree
Hide file tree
Showing 23 changed files with 176 additions and 37 deletions.
44 changes: 30 additions & 14 deletions src/BaselineOfPenfeld/BaselineOfPenfeld.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,10 @@ BaselineOfPenfeld >> baseline: spec [
<baseline>
spec
for: #common
do: [ "Bloc"
spec
baseline: 'Bloc'
with: [ spec repository: 'github://pharo-graphics/Bloc/src' ].

"Brick text editor"
spec
baseline: 'Brick'
with: [ spec repository: 'github://StevenCostiou/Brick/src'. ].

"PharoStylesheet"
spec
baseline: 'PharoStylesheet'
with: [ spec repository: 'github://GlennCavarle/PharoStylesheet/src' ].
do: [
self geometry: spec.
self stylesheet: spec.
self bloc: spec.

"Penfeld"
spec
Expand All @@ -36,3 +26,29 @@ BaselineOfPenfeld >> baseline: spec [
with: [ spec requires: 'Penfeld-Bloc' ].
spec package: 'Penfeld-Tests' with: [ spec requires: 'Penfeld' ] ]
]

{ #category : #dependencies }
BaselineOfPenfeld >> bloc: spec [
spec
baseline: 'Bloc'
with: [ spec repository: 'github://feenkcom/Bloc/src' ].

"Brick text editor"
spec
baseline: 'Brick'
with: [ spec repository: 'github://StevenCostiou/Brick/src'. ].
]

{ #category : #dependencies }
BaselineOfPenfeld >> geometry: spec [
spec
baseline: 'Geometry'
with: [ spec repository: 'github://TelescopeSt/Geometry/src' ]
]

{ #category : #dependencies }
BaselineOfPenfeld >> stylesheet: spec [
spec
baseline: 'PharoStylesheet'
with: [ spec repository: 'github://GlennCavarle/PharoStylesheet/src' ]
]
33 changes: 33 additions & 0 deletions src/Penfeld-Bloc-Tests/PenBlocShapeDresserTest.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"
A PenBlocShapeDresserTest is a test class for testing the behavior of PenBlocShapeDresser
"
Class {
#name : #PenBlocShapeDresserTest,
#superclass : #TestCase,
#category : #'Penfeld-Bloc-Tests-Dressers'
}

{ #category : #'tests - build geometry' }
PenBlocShapeDresserTest >> testBuildCircle [
PenShape new shape: (GCircle center: 100 , 100 radius: 30); build.
]

{ #category : #'tests - build geometry' }
PenBlocShapeDresserTest >> testBuildEllipse [
PenShape new shape: (GEllipse center: 40 , 10 vertex: 60 , 10 coVertex: 40 , 20); build.
]

{ #category : #'tests - build geometry' }
PenBlocShapeDresserTest >> testBuildPolygon [
PenShape new shape: (GPolygon vertices: {(10 , 10) . (-10 , 10) . (-10 , -10)}); build.
]

{ #category : #'tests - build geometry' }
PenBlocShapeDresserTest >> testBuildRectangle [
PenShape new shape: (GRectangle origin: 1 , 3 corner: 3 , 0); build.
]

{ #category : #'tests - build geometry' }
PenBlocShapeDresserTest >> testBuildTriangle [
PenShape new shape: (GTriangle with: 0 , 0 with: 2 , 0 with: 0 , 2); build.
]
6 changes: 6 additions & 0 deletions src/Penfeld-Bloc/GCircle.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Extension { #name : #GCircle }

{ #category : #'*Penfeld-Bloc' }
GCircle >> asBlElement [
^ (BlCircle new extent: self extent) asElement
]
6 changes: 6 additions & 0 deletions src/Penfeld-Bloc/GEllipse.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Extension { #name : #GEllipse }

{ #category : #'*Penfeld-Bloc' }
GEllipse >> asBlElement [
^ (BlEllipse extent: self extent) asElement
]
8 changes: 8 additions & 0 deletions src/Penfeld-Bloc/GPolygon.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Extension { #name : #GPolygon }

{ #category : #'*Penfeld-Bloc' }
GPolygon >> asBlElement [
^ (BlPolygon new
vertices: (self vertices collect: [ :gpoint | gpoint x @ gpoint y ]))
asElement
]
6 changes: 6 additions & 0 deletions src/Penfeld-Bloc/GRectangle.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Extension { #name : #GRectangle }

{ #category : #'*Penfeld-Bloc' }
GRectangle >> asBlElement [
^ (BlRectangle new extent: self extent) asElement
]
9 changes: 9 additions & 0 deletions src/Penfeld-Bloc/GTriangle.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Extension { #name : #GTriangle }

{ #category : #'*Penfeld-Bloc' }
GTriangle >> asBlElement [
^ (BlPolygon new vertices: {
self v1 x @ self v1 y.
self v2 x @ self v2 y.
self v3 x @ self v3 y. }) asElement
]
2 changes: 1 addition & 1 deletion src/Penfeld-Bloc/PenBlocButtonDresser.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ PenBlocButtonDresser >> initEngineElement [
self component engineElement preventChildrenMouseEvents.
]

{ #category : #accessing }
{ #category : #'accessing - font' }
PenBlocButtonDresser >> ropedText [
^ ropedText
]
Expand Down
2 changes: 1 addition & 1 deletion src/Penfeld-Bloc/PenBlocCheckBoxDresser.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ PenBlocCheckBoxDresser >> initEngineElement [
self component engineElement when: BlMouseLeaveEvent do: [ :e | self whenMouseLeaveEvent ].
]

{ #category : #accessing }
{ #category : #'accessing - font' }
PenBlocCheckBoxDresser >> ropedText [
^ ropedText
]
Expand Down
2 changes: 1 addition & 1 deletion src/Penfeld-Bloc/PenBlocDressersMap.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ PenBlocDressersMap >> initMap [
at: PenProgressBar put: PenBlocProgressBarDresser ;
at: PenSlider put: PenBlocSliderDresser;
at: PenImage put: PenBlocImageDresser;
at: PenShape put: PenBlocShapeExperimentalDresser
at: PenShape put: PenBlocShapeDresser
]
4 changes: 2 additions & 2 deletions src/Penfeld-Bloc/PenBlocLabelDresser.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ PenBlocLabelDresser >> doBeforeApplyStyle [
ropedText := self component text asRopedText
]

{ #category : #styling }
{ #category : #'styling - font' }
PenBlocLabelDresser >> fontSize: aValue [
self ropedText fontSize: aValue value.
self component engineElement constraintsDo: [ :c |
Expand All @@ -63,7 +63,7 @@ PenBlocLabelDresser >> initEngineElement [
element addChild: BlTextElement new as: #text.
]

{ #category : #accessing }
{ #category : #'accessing - font' }
PenBlocLabelDresser >> ropedText [
^ ropedText
]
Expand Down
2 changes: 1 addition & 1 deletion src/Penfeld-Bloc/PenBlocRadioButtonDresser.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ PenBlocRadioButtonDresser >> initEngineElement [
self component engineElement when: BlMouseLeaveEvent do: [ :e | self whenMouseLeaveEvent ].
]

{ #category : #accessing }
{ #category : #'accessing - font' }
PenBlocRadioButtonDresser >> ropedText [
^ ropedText
]
Expand Down
38 changes: 38 additions & 0 deletions src/Penfeld-Bloc/PenBlocShapeDresser.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
Class {
#name : #PenBlocShapeDresser,
#superclass : #PenBlocDresser,
#traits : 'TPenBlocSizeStyle + TPenBlocMarginStyle + TPenBlocBackgroundStyle + TPenBlocBorderStyle',
#classTraits : 'TPenBlocSizeStyle classTrait + TPenBlocMarginStyle classTrait + TPenBlocBackgroundStyle classTrait + TPenBlocBorderStyle classTrait',
#category : #'Penfeld-Bloc-Dressers'
}

{ #category : #dressing }
PenBlocShapeDresser >> doAfterApplyStyle [
| var element |
element := self component engineElement.

"Position"
var := self component position.
var ifNotNil: [ element relocate: var ].

"Width"
var := self component width.
var ifNotNil: [ element width: var pref ].

"Height"
var := self component height.
var ifNotNil: [ element height: var pref ].
]

{ #category : #dressing }
PenBlocShapeDresser >> initEngineElement [
| element |
element := self component shape asBlElement.
element
border: BlBorder empty;
background: BlBackground transparent.

self component hasEvents ifFalse: [ element preventMeAndChildrenMouseEvents ].

self component engineElement: element .
]
6 changes: 6 additions & 0 deletions src/Penfeld-Bloc/PenBlocShapeExperimentalDresser.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ Class {
#category : #'Penfeld-Bloc-Dressers'
}

{ #category : #testing }
PenBlocShapeExperimentalDresser class >> isDeprecated [
self flag: 'Use PenBlocShapeDresser and GShape instead'.
^ true
]

{ #category : #dressing }
PenBlocShapeExperimentalDresser >> doAfterApplyStyle [
| var element |
Expand Down
2 changes: 1 addition & 1 deletion src/Penfeld-Bloc/PenBlocTableItemDresser.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ PenBlocTableItemDresser >> doAfterApplyStyle [
].
]

{ #category : #'accessing structure variables' }
{ #category : #'styling - size' }
PenBlocTableItemDresser >> height: aValue [
self component engineElement constraintsDo: [ :c |
c vertical exact: aValue ].
Expand Down
4 changes: 2 additions & 2 deletions src/Penfeld-Bloc/TPenBlocBackgroundStyle.trait.st
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ Trait {
#category : #'Penfeld-Bloc-Styles'
}

{ #category : #styling }
{ #category : #'styling - background' }
TPenBlocBackgroundStyle >> backgroundColor: aValue [
self component engineElement background: aValue
]

{ #category : #styling }
{ #category : #'styling - background' }
TPenBlocBackgroundStyle >> backgroundImage: aValue [
self component engineElement background: aValue
]
Expand Down
4 changes: 2 additions & 2 deletions src/Penfeld-Bloc/TPenBlocBorderStyle.trait.st
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Trait {
#category : #'Penfeld-Bloc-Styles'
}

{ #category : #styling }
{ #category : #'styling - border' }
TPenBlocBorderStyle >> border: aValue [
| borderBuilder |
borderBuilder := BlBorderBuilder new.
Expand Down Expand Up @@ -44,7 +44,7 @@ TPenBlocBorderStyle >> border: aValue [
self component engineElement border: borderBuilder build.
]

{ #category : #styling }
{ #category : #'styling - border' }
TPenBlocBorderStyle >> borderRadius: aValue [
| radius |
aValue class = PssPercentValue
Expand Down
12 changes: 6 additions & 6 deletions src/Penfeld-Bloc/TPenBlocFontStyle.trait.st
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,38 @@ Trait {
#category : #'Penfeld-Bloc-Styles'
}

{ #category : #styling }
{ #category : #'styling - font' }
TPenBlocFontStyle >> color: aValue [
self ropedText foreground: aValue
]

{ #category : #styling }
{ #category : #'styling - font' }
TPenBlocFontStyle >> fontFamily: aValue [
self ropedText fontName: aValue value.
]

{ #category : #styling }
{ #category : #'styling - font' }
TPenBlocFontStyle >> fontSize: aValue [
self ropedText fontSize: aValue value
]

{ #category : #styling }
{ #category : #'styling - font' }
TPenBlocFontStyle >> fontStyle: aValue [
| symbol |
symbol := aValue value.
(self ropedText respondsTo: symbol)
ifTrue: [ self ropedText perform: symbol ]
]

{ #category : #styling }
{ #category : #'styling - font' }
TPenBlocFontStyle >> fontWeight: aValue [
| symbol |
symbol := aValue value.
(self ropedText respondsTo: symbol)
ifTrue: [ self ropedText perform: symbol ]
]

{ #category : #accessing }
{ #category : #'accessing - font' }
TPenBlocFontStyle >> ropedText [
self explicitRequirement
]
2 changes: 1 addition & 1 deletion src/Penfeld-Bloc/TPenBlocMarginStyle.trait.st
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Trait {
#category : #'Penfeld-Bloc-Styles'
}

{ #category : #accessing }
{ #category : #'styling - margin' }
TPenBlocMarginStyle >> margin: aValue [
| insets array |
aValue isArray
Expand Down
4 changes: 2 additions & 2 deletions src/Penfeld-Bloc/TPenBlocSizeStyle.trait.st
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ Trait {
#category : #'Penfeld-Bloc-Styles'
}

{ #category : #'accessing structure variables' }
{ #category : #'styling - size' }
TPenBlocSizeStyle >> height: aValue [
self component engineElement constraintsDo: [ :c |
c vertical exact: aValue ]
]

{ #category : #'accessing structure variables' }
{ #category : #'styling - size' }
TPenBlocSizeStyle >> width: aValue [
self component engineElement constraintsDo: [ :c |
c horizontal exact: aValue ]
Expand Down
2 changes: 1 addition & 1 deletion src/Penfeld-Brick-TextEditor/PenBlocInputDresser.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ PenBlocInputDresser >> initEngineElement [
do: [ :e | self component text: dataSource text copy ].
]

{ #category : #accessing }
{ #category : #'accessing - font' }
PenBlocInputDresser >> ropedText [
^ ropedText
]
Loading

0 comments on commit a83782d

Please sign in to comment.