Displaying images in bottom bars

Hi!
As elaborated in Bottom sheet bottom bar with GtkPicture is broken (#995) · Issues · GNOME / libadwaita · GitLab I would like to display images with unknown sizes and aspect ratios (namely album covers) inside the bottom bar of a libadwaita bottom sheet. Previously this was possible by using a GtkPicture which automatically filled all the space available in the bottom bar. Unfortunately GtkPicture is now increasing the height of the bottom bar further. I’d like the height of the bottom bar to be automatically determined by the labels and the buttons in it and the image should then just take the available space and not request more.
In the issue mentioned above it was suggested to use a GtkImage at a fixed size. I’m not a fan of this idea as I think GTK generally does a great job at dynamically sizing the widgets and I really don’t want do use some magic fixed pixel sizes which could lead to unreadable text if someone changes the font size either through the large text option or manually.

Hi,

In the past I used to pack my GtkPictures as single child of a horizontal GtkBox. That breaks the weird width-for-height size ratio computation, allowing it to follow the height request of the other adjacent widgets.

Note that I don’t know if that still works with the latest allocation changes in gtk.

Thank you for the hint! Unfortunately it doesn’t work with the new GTK version.

This indeed was one of the things that got fixed.

1 Like

I played around with custom a WIDTH_FOR_HEIGHT widget. It seems like the problem could be solved with this but it’s very tedious to get this working with variable aspect ratios.

Oh… so that was relying on an unexpected corner-case behavior? :slight_smile:
I’ll have to recheck for a proper solution then. Thanks for the info!