We regularly seem to have components that specify their own width which need to be layed out. and I end up with a function something like this:
int getIdealWidth(int height) override
{
Font f;
f.setHeight(height - 4.0f);
return f.getStringWidth(name) + 8;
}
The JUCE pattern I’m used to is one where the parent component mainly tells the child how big it’s going to be, or the child specifies a size.
In my app we always seem to have the parent specifying one dimension and the child component figuring out the size in the other dimension …
Is there a tidier way of doing this? Sometimes it’s way more complicated, like when we have something whose height depends on it’s width, and then discover that we need to inject a scrollbar with the total height, then have to iterate over all the components again…

