Skip to content

Commit

Permalink
- add example of drawing with Bloc AeCanvas
Browse files Browse the repository at this point in the history
  • Loading branch information
rvillemeur committed May 13, 2024
1 parent b26230f commit b5f30c4
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
41 changes: 41 additions & 0 deletions Chapters/bloc/element.md
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,47 @@ Drawing is done through method 'xxx', which receives an Alexandrie
2. `aeDrawOn:`
3. `aeDrawGeometryOn:`
Drawing example - draw hour tick around a circle
```
aeDrawOn: aeCanvas
"draw clock tick on frame"

super aeDrawOn: aeCanvas.

aeCanvas setOutskirtsCentered.

0 to: 11 do: [ :items |
| target |
target := (items * Float pi / 6) cos @ (items * Float pi / 6) sin.

items % 3 == 0
ifTrue: [
aeCanvas pathFactory: [ :cairoContext |
cairoContext
moveTo: center;
relativeMoveTo: target * 115;
relativeLineTo: target * 35;
closePath ].

aeCanvas setBorderBlock: [
aeCanvas
setSourceColor: Color black;
setBorderWidth: 8 ] ]
ifFalse: [
aeCanvas pathFactory: [ :cairoContext |
cairoContext
moveTo: center;
relativeMoveTo: target * 125;
relativeLineTo: target * 25;
closePath ].

aeCanvas setBorderBlock: [
aeCanvas
setSourceColor: Color black;
setBorderWidth: 6 ] ].
aeCanvas drawFigure ]
```
### Conclusion
`BlElement` is defining a large spectrum of element functionalities.
Expand Down
18 changes: 18 additions & 0 deletions Chapters/toplo/widget_creation.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,27 @@ space toTheme: (name of your theme) new.



## Notes in bulk
Your element needs to be a Toplo Element.

* If e minutesNeedle return a BlElement, and not a ToElement, then you need to send it #ensureCanManageSkin `e ensureCanManageSkin.`

* One can send #withNullSkin to an element to set a NullSkin.

* stylesheet can be useful because of the selection mechanism that allow the skin selection/building in one pass.
*
I’ve no particular solution for this kind of issue.

An example of this kind of sub-element skin is the ToLabelInListElementSkin that can be used when a node is selected in a ListElement.
It is typically set from a ToListElement nodeBuilder (not in a #installLookEvent: in my examples).


A theme is to manage common token values for the set of widgets it is supposed to be designed for. So I’ve added the ToThemePreInstallEvent that you can use ton add new token values in the current theme.
(Have a look at #example_WithLateBoundPropertyWriter).
But the implementation of token values storage have to be revised to nicely fulfill this need.

First if you only need a ToInstallLookEvent handling, note that adding a skin class is not mandatory. You can simply redefine the #installRawStyle method instead.

In your #installLookEvent:, I see a lot of code that, I think, should stay in the initialize method because changing the theme Would not lead to the change of your element appearance.


0 comments on commit b5f30c4

Please sign in to comment.