Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 30 additions & 29 deletions Chapters/gettingStarted/buildingAWidget.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ We start by defining the shape of the main element. Notice that visual propertie


```
BlIntegerInputElement >> inputExtent
BlIntegerInputElement >> widgetExtent

^ 300@120
```
Expand All @@ -57,7 +57,7 @@ BlIntegerInputElement >> backgroundPaint
BlIntegerInputElement >> initialize

super initialize.
self size: self inputExtent.
self size: self widgetExtent.
self background: self backgroundPaint.
self geometry: (BlRoundedRectangleGeometry cornerRadius: 20).
self layout: BlFrameLayout new.
Expand Down Expand Up @@ -88,8 +88,9 @@ BlIntegerInputElement >> label: aString
inputLabel := BlTextElement new.
inputLabel text: (self configuredString: aString).
inputLabel text fontSize: 25.
inputLabel constraintsDo: [ :c | c frame horizontal alignCenter ].
inputLabel transformDo: [ :t | t translateBy: 0 @ 10 ].
inputLabel constraintsDo: [ :c |
c frame horizontal alignCenter.
c margin: (BlInsets all: 10) ].
self addChild: inputLabel
```

Expand All @@ -102,7 +103,7 @@ We modify the initialize method to invoke the `label` method.
BlIntegerInputElement >> initialize

super initialize.
self size: self inputExtent.
self size: self widgetExtent.
self background: self backgroundPaint.
self geometry: (BlRoundedRectangleGeometry cornerRadius: 20).
self layout: BlFrameLayout new.
Expand Down Expand Up @@ -146,7 +147,7 @@ Then we change the `initialize` method to invoke `initializeInputValue:`.
BlIntegerInputElement >> initialize

super initialize.
self size: self inputExtent.
self size: self widgetExtent.
self background: self backgroundPaint.
self geometry: (BlRoundedRectangleGeometry cornerRadius: 20).
self layout: BlFrameLayout new.
Expand Down Expand Up @@ -194,23 +195,23 @@ We create a new text element and place it inside the circle and then add the cir
```
BlIntegerInputElement >> initializePlusButton

| circle |
circle := self createCircle.
circle constraintsDo: [ :c |
| textElt |
plus := self createCircle.
plus constraintsDo: [ :c |
c frame horizontal alignRight.
c frame vertical alignCenter ].
circle transformDo: [ :t | t translateBy: -15 @ 0 ].
plus transformDo: [ :t | t translateBy: -15 @ 0 ].

plus := BlTextElement new text: (self configuredString: '+').
plus text fontSize: 55.
plus constraintsDo: [ :c |
textElt := BlTextElement new text: (self configuredString: '+').
textElt text fontSize: 55.
textElt constraintsDo: [ :c |
c frame horizontal alignCenter.
c frame vertical alignCenter ].
circle
plus
addEventHandlerOn: BlMouseDownEvent
do: [ :e | self increaseInput ].
circle addChild: plus.
self addChild: circle.
plus addChild: textElt.
self addChild: plus.
```

Note that in addition, we use the message `addEventHandlerOn:do:` to configure
Expand All @@ -220,7 +221,7 @@ the circle element to react to mouse-down events.
BlIntegerInputElement >> initialize

super initialize.
self size: self inputExtent.
self size: self widgetExtent.
self background: self backgroundPaint.
self geometry: (BlRoundedRectangleGeometry cornerRadius: 20).
self layout: BlFrameLayout new.
Expand Down Expand Up @@ -252,32 +253,32 @@ Here we adjusted the size of the minus character so that it has a similar shape
```
BlIntegerInputElement >> initializeMinusButton

| circle |
circle := self createCircle.
circle constraintsDo: [ :c |
| textElt |
minus := self createCircle.
minus constraintsDo: [ :c |
c frame horizontal alignLeft.
c frame vertical alignCenter ].
circle transformDo: [ :t | t translateBy: 15 @ 0 ].
c frame vertical alignCenter.
c margin: (BlInsets all: 10) ].

minus := BlTextElement new text: (self configuredString: '-').
minus text fontSize: 80.
minus constraintsDo: [ :c |
textElt := BlTextElement new text: (self configuredString: '-').
textElt text fontSize: 80.
textElt constraintsDo: [ :c |
c frame horizontal alignCenter.
c frame vertical alignCenter ].
circle
minus
addEventHandlerOn: BlMouseDownEvent
do: [ :e | self decreaseInput ].

circle addChild: minus.
self addChild: circle.
minus addChild: textElt.
self addChild: minus.
```

FInally we update the initialize method to call the minus creation.
```
BlIntegerInputElement >> initialize

super initialize.
self size: self inputExtent.
self size: self widgetExtent.
self background: self backgroundPaint.
self geometry: (BlRoundedRectangleGeometry cornerRadius: 20).
self layout: BlFrameLayout new.
Expand Down
Binary file added Chapters/toplo/figures/inputWithSkin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Chapters/toplo/figures/inputWithTheme.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading