In the following MWE, we can resize the window and the contained image fills out the space accordingly (while retaining the aspect ratio):
using Gtk4, GtkObservables
using Colors
win = GtkWindow("Example")
h = 100
c = canvas(h, h)
f = GtkAspectFrame(h, h, 1, false)
f[] = c.widget
push!(win, f)
img = Observable(rand(RGB, h, h))
redraw = Gtk4.draw(c, img) do cnvs, img
copy!(cnvs, img)
end
But if I want to add more components (e.g. dropdown
), and to that end I put the image in a GtkBox
:
win = GtkWindow("Example")
win[] = bx = GtkBox(:v) # this will contain my image AND my dropdown
h = 100
c = canvas(h, h)
f = GtkAspectFrame(h, h, 1, false)
f[] = c.widget
push!(bx, f) # let's put that image in that container
img = Observable(rand(RGB, h, h))
redraw = Gtk4.draw(c, img) do cnvs, img
copy!(cnvs, img)
end
This breaks. The image is static and does not expand to the resized window.
How can I get this to work?