Skip to content

Commit 4f923db

Browse files
authored
Merge pull request #27 from Enzo-Demeulenaere/main
enzo pass
2 parents 53e1de2 + 84b3838 commit 4f923db

File tree

5 files changed

+141
-145
lines changed

5 files changed

+141
-145
lines changed

Chapters/gettingStarted/buildingAWidget.md

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ We start by defining the shape of the main element. Notice that visual propertie
4141

4242

4343
```
44-
BlIntegerInputElement >> inputExtent
44+
BlIntegerInputElement >> widgetExtent
4545
4646
^ 300@120
4747
```
@@ -57,7 +57,7 @@ BlIntegerInputElement >> backgroundPaint
5757
BlIntegerInputElement >> initialize
5858
5959
super initialize.
60-
self size: self inputExtent.
60+
self size: self widgetExtent.
6161
self background: self backgroundPaint.
6262
self geometry: (BlRoundedRectangleGeometry cornerRadius: 20).
6363
self layout: BlFrameLayout new.
@@ -88,8 +88,9 @@ BlIntegerInputElement >> label: aString
8888
inputLabel := BlTextElement new.
8989
inputLabel text: (self configuredString: aString).
9090
inputLabel text fontSize: 25.
91-
inputLabel constraintsDo: [ :c | c frame horizontal alignCenter ].
92-
inputLabel transformDo: [ :t | t translateBy: 0 @ 10 ].
91+
inputLabel constraintsDo: [ :c |
92+
c frame horizontal alignCenter.
93+
c margin: (BlInsets all: 10) ].
9394
self addChild: inputLabel
9495
```
9596

@@ -102,7 +103,7 @@ We modify the initialize method to invoke the `label` method.
102103
BlIntegerInputElement >> initialize
103104
104105
super initialize.
105-
self size: self inputExtent.
106+
self size: self widgetExtent.
106107
self background: self backgroundPaint.
107108
self geometry: (BlRoundedRectangleGeometry cornerRadius: 20).
108109
self layout: BlFrameLayout new.
@@ -146,7 +147,7 @@ Then we change the `initialize` method to invoke `initializeInputValue:`.
146147
BlIntegerInputElement >> initialize
147148
148149
super initialize.
149-
self size: self inputExtent.
150+
self size: self widgetExtent.
150151
self background: self backgroundPaint.
151152
self geometry: (BlRoundedRectangleGeometry cornerRadius: 20).
152153
self layout: BlFrameLayout new.
@@ -194,23 +195,23 @@ We create a new text element and place it inside the circle and then add the cir
194195
```
195196
BlIntegerInputElement >> initializePlusButton
196197
197-
| circle |
198-
circle := self createCircle.
199-
circle constraintsDo: [ :c |
198+
| textElt |
199+
plus := self createCircle.
200+
plus constraintsDo: [ :c |
200201
c frame horizontal alignRight.
201202
c frame vertical alignCenter ].
202-
circle transformDo: [ :t | t translateBy: -15 @ 0 ].
203+
plus transformDo: [ :t | t translateBy: -15 @ 0 ].
203204
204-
plus := BlTextElement new text: (self configuredString: '+').
205-
plus text fontSize: 55.
206-
plus constraintsDo: [ :c |
205+
textElt := BlTextElement new text: (self configuredString: '+').
206+
textElt text fontSize: 55.
207+
textElt constraintsDo: [ :c |
207208
c frame horizontal alignCenter.
208209
c frame vertical alignCenter ].
209-
circle
210+
plus
210211
addEventHandlerOn: BlMouseDownEvent
211212
do: [ :e | self increaseInput ].
212-
circle addChild: plus.
213-
self addChild: circle.
213+
plus addChild: textElt.
214+
self addChild: plus.
214215
```
215216

216217
Note that in addition, we use the message `addEventHandlerOn:do:` to configure
@@ -220,7 +221,7 @@ the circle element to react to mouse-down events.
220221
BlIntegerInputElement >> initialize
221222
222223
super initialize.
223-
self size: self inputExtent.
224+
self size: self widgetExtent.
224225
self background: self backgroundPaint.
225226
self geometry: (BlRoundedRectangleGeometry cornerRadius: 20).
226227
self layout: BlFrameLayout new.
@@ -252,32 +253,32 @@ Here we adjusted the size of the minus character so that it has a similar shape
252253
```
253254
BlIntegerInputElement >> initializeMinusButton
254255
255-
| circle |
256-
circle := self createCircle.
257-
circle constraintsDo: [ :c |
256+
| textElt |
257+
minus := self createCircle.
258+
minus constraintsDo: [ :c |
258259
c frame horizontal alignLeft.
259-
c frame vertical alignCenter ].
260-
circle transformDo: [ :t | t translateBy: 15 @ 0 ].
260+
c frame vertical alignCenter.
261+
c margin: (BlInsets all: 10) ].
261262
262-
minus := BlTextElement new text: (self configuredString: '-').
263-
minus text fontSize: 80.
264-
minus constraintsDo: [ :c |
263+
textElt := BlTextElement new text: (self configuredString: '-').
264+
textElt text fontSize: 80.
265+
textElt constraintsDo: [ :c |
265266
c frame horizontal alignCenter.
266267
c frame vertical alignCenter ].
267-
circle
268+
minus
268269
addEventHandlerOn: BlMouseDownEvent
269270
do: [ :e | self decreaseInput ].
270271
271-
circle addChild: minus.
272-
self addChild: circle.
272+
minus addChild: textElt.
273+
self addChild: minus.
273274
```
274275

275276
FInally we update the initialize method to call the minus creation.
276277
```
277278
BlIntegerInputElement >> initialize
278279
279280
super initialize.
280-
self size: self inputExtent.
281+
self size: self widgetExtent.
281282
self background: self backgroundPaint.
282283
self geometry: (BlRoundedRectangleGeometry cornerRadius: 20).
283284
self layout: BlFrameLayout new.
12.6 KB
Loading
12.2 KB
Loading

0 commit comments

Comments
 (0)