Skip to content

Commit 6ac19d9

Browse files
Update skinningAWidget.md according to Yann feedback
1 parent 1172b37 commit 6ac19d9

File tree

1 file changed

+8
-22
lines changed

1 file changed

+8
-22
lines changed

Chapters/toplo/skinningAWidget.md

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22

33
In this chapter we show how we can take the simple input widget developed in a previous chapter and make it skinnable.
44

5-
In a first period, we will focus on what is called raw skins. The idea behind raw skins are that we define classes with states and methods to define the behavior of a skin in a given theme. At the end of this chapter we will see that we can also skin widgets
6-
using stylesheets following the spirit of CSS.
5+
In a first period, we will focus on what is called raw skins. The idea behind raw skins are that we define classes with states and methods to define the behavior of a skin in a given theme. At the end of this chapter we will see that we can also skin widgets using stylesheets following the spirit of CSS.
76

87
The outline of this chapter is then: first we show that we can extend a theme and define a skin.
98
Then in a second time we show that we can define an autonomous theme.
10-
Finally we will show that we can use stylesheet
9+
Finally we will show that we can use stylesheet.
1110

1211
Remember that we want to create a widget as shown in Figure *@inputFinalSkin@*.
1312

@@ -16,13 +15,12 @@ Remember that we want to create a widget as shown in Figure *@inputFinalSkin@*.
1615
### Getting started
1716

1817
If you implemented the widget as presented earlier, just copy the class giving it a new name for example `ToIntegerInputElement`.
19-
The definition of the `BlIntegerInputElement` is available SD:DefineAPlace.
2018

2119
The first thing that we should do is to make `ToIntegerInputElement` inherit from `ToElement` as follows:
2220

2321
```
2422
ToElement << #ToIntegerInputElement
25-
slots: { #plus . #minus . #inputValue . #value . #inputLabel };
23+
slots: { #plus . #minus . #inputValue . #value . #inputLabel. #callbackBlock };
2624
tag: 'Input';
2725
package: 'Bloc-Book'
2826
```
@@ -84,11 +82,6 @@ ToIntegerInputElement >> minus
8482
Here we redefine the background of the element and its 'plus' and 'minus' sub-elements, but we also define a border to our element using tokens from our theme.
8583
We accessed our element through the event received, this can be done in both following ways
8684

87-
88-
##### Remark
89-
Notice that the two following forms are equivalent.
90-
This is important if you want to maximize
91-
9285
```
9386
anEvent elementDo: [ :e |
9487
e border: (e valueOfTokenNamed: #'color-border-checkable’).
@@ -98,6 +91,9 @@ target := anEvent currentTarget.
9891
target border: target valueOfTokenNamed: #'color-border-checkable’)
9992
```
10093

94+
##### Remark
95+
Notice that the two following forms are equivalent.
96+
10197

10298
Now that we defined our skin, we only need to tell our element to install this skin during initialization
10399
In the `ToNumberInputElement` we define the method
@@ -133,7 +129,7 @@ ToIntegerInputElement >> initialize
133129

134130
We can now open our element and see our new skin installed.
135131

136-
![An integer input widget with a new skin installed. % anchor=inputFinalSkin&width=50](figures/inputWithSkin.png )
132+
![An integer input widget with a new skin installed. %width=50](figures/inputWithSkin.png )
137133

138134

139135
### Define a theme that extends an existing one
@@ -190,7 +186,7 @@ space root addChild: anInput.
190186
space show.
191187
```
192188

193-
![An integer input widget with a new skin and new theme installed. % anchor=inputFinalSkin&width=50](figures/inputWithTheme.png )
189+
![An integer input widget with a new skin and new theme installed. %width=50](figures/inputWithTheme.png )
194190

195191

196192
### Decorating a BlElement to get a ToElement
@@ -216,16 +212,6 @@ ToNumberInputElement >> initialize
216212
self initializeForToplo
217213
```
218214

219-
220-
SD: we should check if the following is necessary
221-
```
222-
ToNumberInputElement >> onAddedToSceneGraph
223-
224-
super onAddedToSceneGraph.
225-
self ensuredSkinManager requestInstallSkinIn: self.
226-
self addEventHandler: ToSkinStateGenerator new
227-
```
228-
229215
### Autonome theme
230216

231217
We should now how we can define a full new theme.

0 commit comments

Comments
 (0)