Open koendehondt opened 2 months ago
@Ducasse Please try something for me.
The section "How do styles work?" states that the button would scale when using a stylesheet instead of using #add:withConstraints:
.
But, if you change the size of the fonts of the Pharo image using Settings/Ap- pearance/Standard Fonts/Huge, using fixed constraints, you will obtain the following result shown in Figure 14-3. You will for example not be able to see the icons because the size is not recomputed correctly. When using styles, the size of the button will also scale as shown in Figure 14-4.
I cannot reproduce that. I see no scaling of the button when using a stylesheet. Here is the code that I used, which is not part of the book (and maybe it should).
presenter := SpPresenter new.
presenter
layout: (SpBoxLayout newLeftToRight
vAlignCenter;
hAlignCenter;
add: (presenter newButton icon: (presenter iconNamed: #smallLoadProject)) withConstraints: [ :constraints | constraints height: 20; width: 20 ];
yourself);
open
application := SpApplication new.
application addStyleSheetFromString: '.application [
.button [ Geometry { #height: 20, #width: 20 } ]
]'.
presenter := SpPresenter newApplication: application.
button := presenter newButton icon: (presenter iconNamed: #smallLoadProject).
button addStyle: 'button'.
presenter
layout: (SpBoxLayout newLeftToRight
vAlignCenter;
hAlignCenter;
add: button expand: false;
yourself);
open
So in that case we should remove this from the book
Open issues from https://github.com/SquareBracketAssociates/BuildingApplicationWithSpec2/pull/60:
stonName
s withSpStyle
subclasses, but the classes are introduced in the next section ("Anatomy of a style"). I think that both sections have to be rewritten to avoid forward references and to make the text easier to understand. There are still some questions in the sections that indicate this. "Anatomy of a style" should do just that: what is the syntax of a style? I would not mix it with code. The anatomy of a style is part of the STON notation. How thestonName
s are mapped on classes should move to a separate (new) section.SpStyle class>>#defaultStyleSheetData
), but as flagged inSpStyle class>>#defaultStyleSheet
, the default stylesheet should reside in the Pharo application, not inSpStyle class
.Other: