You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Chapters/gettingStarted/buildingAWidget.md
+42-64Lines changed: 42 additions & 64 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,10 +20,9 @@ space root addChild: anInput.
20
20
space show.
21
21
```
22
22
23
-
The main widget is composed of four elements: two buttons, a label, and a value.
24
-
Let us detail these elements:
23
+
The main widget is composed of four elements: two buttons (the circle with a "+" and the circle with the "-"), a label (that displays "input"), and a value (that displays "20"). Let us detail these elements:
25
24
- the label and the value are text elements,
26
-
- the two buttons are, in fact, a composite element composed of a circle element with a text element inside.
25
+
- the two buttons are, in fact, a composite element composed of an element with a circle geometry, holding a text element inside.
We start by defining the shape of the main element. Notice that visual properties such the background, the border could be stored differently to be customized afterwards.This is what we will show in a following chapter using stylesheet and skins as done in Toplo.
41
-
42
-
43
-
```
44
-
BlIntegerInputElement >> widgetExtent
45
-
46
-
^ 300@120
47
-
```
48
-
49
-
```
50
-
BlIntegerInputElement >> backgroundPaint
51
-
52
-
^ Color black
53
-
```
39
+
We start by defining the shape of the main element. Notice that visual properties such as the background or the border could be stored differently to be customized afterwards. This is what we will show in a following chapter using stylesheet and skins as done in Toplo.
Copy file name to clipboardExpand all lines: Chapters/toplo/skinningAWidget.md
+11-25Lines changed: 11 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,12 +2,11 @@
2
2
3
3
In this chapter we show how we can take the simple input widget developed in a previous chapter and make it skinnable.
4
4
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.
7
6
8
7
The outline of this chapter is then: first we show that we can extend a theme and define a skin.
9
8
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.
11
10
12
11
Remember that we want to create a widget as shown in Figure *@inputFinalSkin@*.
13
12
@@ -16,13 +15,12 @@ Remember that we want to create a widget as shown in Figure *@inputFinalSkin@*.
16
15
### Getting started
17
16
18
17
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.
20
18
21
19
The first thing that we should do is to make `ToIntegerInputElement` inherit from `ToElement` as follows:
@@ -32,7 +30,7 @@ Our widget will then inherit the behavior to install a skin when instantiated, w
32
30
### Define a skin
33
31
34
32
We define a skin by inheriting from `ToRawSkin`, this class defines methods reacting to some events.
35
-
The class `ToRawSkin` is th default skin class when using the `ToRawTheme` which is the default theme but themes are detailed later.
33
+
The class `ToRawSkin` is the default skin class when using the `ToRawTheme` which is the default theme but themes are detailed later.
36
34
In fact, skins in Toplo are EventHandlers we simply add to our elements, changing their visual properties according to incoming events
37
35
38
36
```
@@ -50,7 +48,7 @@ can simply use values specific to this skin.
50
48
51
49
```
52
50
ToInputElementSkin >> installSkinEvent: anEvent
53
-
"when installing the skin, changes the properties of widget mentionned down here"
51
+
"when installing the skin, changes the properties of widget mentioned down here"
54
52
55
53
super installSkinEvent: anEvent.
56
54
anEvent elementDo: [ :e |
@@ -84,11 +82,6 @@ ToIntegerInputElement >> minus
84
82
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.
85
83
We accessed our element through the event received, this can be done in both following ways
86
84
87
-
88
-
##### Remark
89
-
Notice that the two following forms are equivalent.
90
-
This is important if you want to maximize
91
-
92
85
```
93
86
anEvent elementDo: [ :e |
94
87
e border: (e valueOfTokenNamed: #'color-border-checkable’).
0 commit comments