pharo-spec / Spec

Spec is a framework in Pharo for describing user interfaces.
MIT License
62 stars 65 forks source link

Alignment problem when using image in box layout #1554

Open koendehondt opened 5 months ago

koendehondt commented 5 months ago

Consider this code:

presenter := SpPresenter new.
presenter layout: (SpBoxLayout newLeftToRight
    add: (presenter newLabel label: 'One'; yourself);
    add: (presenter newLabel label: 'Two'; yourself);
    yourself);
    open

The result is:

Screenshot 2024-06-09 at 15 50 38

That is what I expect.

Consider this code:

presenter := SpPresenter new.
presenter layout: (SpBoxLayout newLeftToRight
    add: presenter newList;
    add: (presenter newLabel label: 'Two'; yourself);
    yourself);
    open

The result is:

Screenshot 2024-06-09 at 15 50 56

That is also what I expect.

Now consider this code:

presenter := SpPresenter new.
presenter layout: (SpBoxLayout newLeftToRight
    add: (presenter newImage image: (presenter iconNamed: #smallError); yourself);
    add: (presenter newLabel label: 'Label'; yourself);
    yourself);
    open

The result is:

Screenshot 2024-06-09 at 15 50 25

That is not what I expect. Why doesn't the image align to the top of the box layout (i.e. the top of the window), just like a label or a list? That seems to be inconsistent behaviour.

We see the same issue when using a vertical box layout:

presenter := SpPresenter new.
presenter layout: (SpBoxLayout newTopToBottom
    add: (presenter newImage image: (presenter iconNamed: #smallError); yourself);
    add: (presenter newLabel label: 'Label'; yourself);
    yourself);
    open.
Screenshot 2024-06-09 at 16 03 49

While the label is aligned with the left side of the box layout (i.e. the left side of the window), the image is not aligned the same way.