In order to not get results like
the extent and width should be calculated values.
That would change the example code to something like
LoginModel class>>defaultSpec
<spec: #default>
^SpecLayout composed
newColumn: [ :col |
col
newRow: [ :row |
row
add: #usernameLabel width: self labelWidth;
add: #usernameField ]
height: self inputTextHeight;
newRow: [ :row |
row
add: #passwordLabel width: self labelWidth;
add: #passwordField ]
height: self inputTextHeight ];
yourself
LoginModel class>>labelWidth
^((StandardFonts defaultFont widthOfString: 'Password') max:
(StandardFonts defaultFont widthOfString: 'Username'))+12
Please note that there are still several places in Spec where
hardcoded values like 12 are used instead of semantic values.
This value should actually be dependent on font size.
Having the label texts twice in the code should also be avoided.
LoginModel>>initialExtent
^(3*12+self class labelWidth+ self class textFieldWidth) @ (5*self class buttonHeight)
There are several calculated values missing:
width = outside border + labelWidth + label field separator+fieldWidth+outside border
height = dialog title + textInput height + separator + textInput height+ separator+button height + outside border
Stephan