I'd like some advice on the best way to get the sizing for a Widget inside a DialogLayout. I've got a way that works, but I'm hesitating because it's seems like I'm taking advantage of the ways certain things work internally in TWL, and if for any reason that changes, my code might not work as expected anymore.
Here's the situation so far: I have a Widget that I am using like a drawing canvas, just a blank space where I draw my game elements. The size of this space is dependent on the layout of a group of Widgets within its parent, essentially it grabs the biggest space available to it. At first I made this Widget a sub class of Container and it worked perfectly because I overrode getPreferred..() and requested a space that was as big as its parent, as a result DialogLayout trimmed it down... the getMinWidth/Height() methods both returned 0 by default from Container.
I needed to introduce some drag and drop elements within my game elements, and because Container doesn't get all the mouse events (such as dragging events), I changed the super class of the drawing canvas to Button. So now I'm drawing onto the front of a big button essentially, and everything works great drag and drop wise, but the layout is different. My assumption is that Button differs to Container in that Button takes getMinWidth/Height() from getPreferred..(). So I override getMinWidth/Height() to return 0 instead, and now it lays out perfectly again.
My main question is, is it ok that I've done it this way, or should I be doing it another way? Perhaps even there's a way to query the DialogLayout to the dimensions that are available for a Widget or Group item? The assumptions I'm making about TWL layouts for this essentially are, if I return a big dimension from getPreferred and a small one from getMin then DialogLayout will first honour getMin and then return the max it can to honour getPreffered. This works for me, but can I depend on this assumption?
Thanks for any advice/help!
In case my description is confusing, here's the details of what each type of Widget returns from sizing methods:
NB. Both of these layouts override getPreferred..() to return the size of the parent Widget, without this they don't "grow" to fill the available space.
getWidth()/getHeight()=780/135 [THIS is the correct size that I am planning for]
Button variant.layout: [if I don't override getMin..() this results in widget too big]
getWidth()/getHeight()=780/180 [THIS is the size of the parent widget, too big]