Variable height child components


#1

Does anyone have a good strategy for these situations?

  • A component whose height is variable and that needs to notify the parent to resize it accordingly.

My current solution is to have the component call setSize(getWidth(), newHeight) on itself when it needs to change height. The parent listens for the resize, and then taking care to avoid reentrancy and infinite loops runs its own resized routine with something like variableHeightChild.setBounds(someSpace.withHeight(variableHeightChild.getHeight()));

And the more complicated:

  • A component whose height varies, as the available width changes, to auto-fit the content.

Any strong thoughts on the best way of dealing with this? Is there a nice tidy way? Maybe there’s a robust example somewhere in JUCE.


#2

FlexBox??


#3

Oh - maybe - let me have another look at it.