Trying to understand the FlexBox demo code in Juce 5. I think we need a simpler demo to get us old dogs started.
Things I think I figured out but may be wrong:
- Still need to call
addAndMakeVisible( myComponent );to ensure the parent component knows about the children
- Parent component does not know to use FlexBox. You will likely want to use
ComponentListener::componentMovedOrResized()to make an explicit call to
In my parent component, I have added several FlexBox members, and in my component constructor I setup all the boxes and items. But…should I instead instantiate the FlexBox I need on the stack within
resized() and let it go out of scope at the end of the method? Does the flexbox and items need to persist beyond the scope of where I call
When I first started playing with this code I thought perhaps FlexBox and FlexItem might take ownership of the controls being passed in. Either way, please add a comment in
FlexItem::FlexItem(Component &component) and
FlexItem::associatedComponent that the lifetime of the FlexItem need not be the same as the component that it is adjusting.
If I want some components to be stacked horizontal, and others vertical, am I correct in thinking I need 3 flexboxes: one vertical, one horizontal, and one “master” to contain the first two flexboxes? Then within
MyComponent::resized() I’d call
master_flexbox.performLayout(), and it recursively does the layout?