-
Notifications
You must be signed in to change notification settings - Fork 71
Open
Description
Sending add: ... expand: false to add buttons
Consider this code:
mainPresenter := SpPresenter new.
button1 := mainPresenter newButton label: 'Button 1'; yourself.
button2 := mainPresenter newButton label: 'Button 2'; yourself.
button3 := mainPresenter newButton label: 'Button 3'; yourself.
mainLayout := SpBoxLayout newLeftToRight
add: button1 expand: false;
add: button2 expand: false;
add: button3 expand: false;
yourself.
mainPresenter layout: mainLayout.
mainPresenter open.
mainPresenter window extent: 500@50The last line is included to reduce the size of the screenshots.
The snippet opens this window:
All good. The default alignment is hAlignStart. Indeed, the buttons are aligned like that. expand: false is in effect, because the buttons take their natural width.
Let's add hAlignEnd:
mainPresenter := SpPresenter new.
button1 := mainPresenter newButton label: 'Button 1'; yourself.
button2 := mainPresenter newButton label: 'Button 2'; yourself.
button3 := mainPresenter newButton label: 'Button 3'; yourself.
mainLayout := SpBoxLayout newLeftToRight
hAlignEnd;
add: button1 expand: false;
add: button2 expand: false;
add: button3 expand: false;
yourself.
mainPresenter layout: mainLayout.
mainPresenter open.
mainPresenter window extent: 500@50We see:
All good.
Let's use hAlignCenter:
mainPresenter := SpPresenter new.
button1 := mainPresenter newButton label: 'Button 1'; yourself.
button2 := mainPresenter newButton label: 'Button 2'; yourself.
button3 := mainPresenter newButton label: 'Button 3'; yourself.
mainLayout := SpBoxLayout newLeftToRight
hAlignCenter;
add: button1 expand: false;
add: button2 expand: false;
add: button3 expand: false;
yourself.
mainPresenter layout: mainLayout.
mainPresenter open.
mainPresenter window extent: 500@50
All good.
Sending add: ... expand: false to add checkboxes
mainPresenter := SpPresenter new.
checkbox1 := mainPresenter newCheckBox label: 'Choice 1'; yourself.
checkbox2 := mainPresenter newCheckBox label: 'Choice 2'; yourself.
checkbox3 := mainPresenter newCheckBox label: 'Choice 3'; yourself.
mainLayout := SpBoxLayout newLeftToRight
add: checkbox1 expand: false;
add: checkbox2 expand: false;
add: checkbox3 expand: false;
yourself.
mainPresenter layout: mainLayout.
mainPresenter open.
mainPresenter window extent: 500@50
expand: false has no effect. The window's width is divided among the checkboxes.
Let's add hAlignEnd:
mainPresenter := SpPresenter new.
checkbox1 := mainPresenter newCheckBox label: 'Choice 1'; yourself.
checkbox2 := mainPresenter newCheckBox label: 'Choice 2'; yourself.
checkbox3 := mainPresenter newCheckBox label: 'Choice 3'; yourself.
mainLayout := SpBoxLayout newLeftToRight
hAlignEnd;
add: checkbox1 expand: false;
add: checkbox2 expand: false;
add: checkbox3 expand: false;
yourself.
mainPresenter layout: mainLayout.
mainPresenter open.
mainPresenter window extent: 500@50We see:
The screenshot is the same as before. Using hAlignEnd has no effect.
Let's use hAlignCenter:
mainPresenter := SpPresenter new.
checkbox1 := mainPresenter newCheckBox label: 'Choice 1'; yourself.
checkbox2 := mainPresenter newCheckBox label: 'Choice 2'; yourself.
checkbox3 := mainPresenter newCheckBox label: 'Choice 3'; yourself.
mainLayout := SpBoxLayout newLeftToRight
hAlignCenter;
add: checkbox1 expand: false;
add: checkbox2 expand: false;
add: checkbox3 expand: false;
yourself.
mainPresenter layout: mainLayout.
mainPresenter open.
mainPresenter window extent: 500@50We see:
Again, no change.
Sending add:width:
For completeness, let's use a fixed width for the checkboxes:
mainPresenter := SpPresenter new.
checkbox1 := mainPresenter newCheckBox label: 'Choice 1'; yourself.
checkbox2 := mainPresenter newCheckBox label: 'Choice 2'; yourself.
checkbox3 := mainPresenter newCheckBox label: 'Choice 3'; yourself.
mainLayout := SpBoxLayout newLeftToRight
add: checkbox1 width: 80;
add: checkbox2 width: 80;
add: checkbox3 width: 80;
yourself.
mainPresenter layout: mainLayout.
mainPresenter open.
mainPresenter window extent: 500@50Then we see:
All good.
Conclusion
expand: false does not affect checkboxes when adding them to a SpBoxlayout. That is a bug.
Metadata
Metadata
Assignees
Labels
No labels