Bogdanp / racket-gui-easy

Declarative GUIs in Racket.
https://docs.racket-lang.org/gui-easy/index.html
134 stars 18 forks source link

Containers which create internal panels are always stretchable #22

Open kengruven opened 2 years ago

kengruven commented 2 years ago

Hello! When I say something like this:

(cond-view
 [@foo? (text "foo is set!")]
 [else (text "no foo here!")])

then internally it will instantiate an if-view%, which in turn calls:

(new gui:panel%
             [parent parent]
             [min-width #f]
             [min-height #f]
             [stretchable-width #t]
             [stretchable-height #t]))

There's no way to inject your own arguments for this panel. That is, if you use a cond-view (or any of the similar containers), you can't have a non-stretchable containee. Even if you have a simple 1-line label (which isn't vertically stretchable), putting it in a cond-view causes it to become vertically stretchable, which is not what I want.

Whenever the library creates secret automatic panels, they should either mimic the layout arguments of their containees, or allow me to explicitly pass arguments for them.

Thanks!

Bogdanp commented 2 years ago

Thanks for the report! I think probably the best approach would be for these panels to inherit the stretch values of their children (and vary them when the children change), as you suggest. I'll try to do that soon. In the mean time, if you need a stopgap, it might work to wrap these views in other panels that don't stretch (though maybe that won't work right in every case).

kengruven commented 2 years ago

Your stopgap solution works for me. Thanks!