I haven’t seen this asked or answered. Is it possible to nest FlexBoxes inside of Flexboxes? I saw this constructor for FlexItem: FlexItem (FlexBox& flexBoxToControl) noexcept; but I haven’t been able to get it to work properly.
The sequence I’m using is:
create Component that needs positioning and make it visible
Add component to FlexItem:
Add FlexItem to FlexBox subInterface
Add FlexBox to FlexItem mainInterfaceItem( subInterface)
add mainInterfaceItem to FlexBox:
in resized(), call mainInterface.performLayout(getLocalBounds().reduced(5));
however, nothing shows up.
As you can see, item 1 is never drawn, which is just odd. When I select 9 from the combobox, I get a crash in the juce::FlexBoxLayoutCalculation::alignItemsByJustifyContent(), being given an ‘EXC_BAD_ACCESS’ crash.
tried to do it myself but there are many surprises on the go.
anyway, i dont think that setting it all up in resized() method is the best idea to consider. it will be called several times during the startup and perhaps under some other activity. there are many crucial thing happening in conjunction to the state of your program. no ?
Creating and destroying all your child components in resized() isn’t going to work, and presumably somewhere you’re leaving a dangling pointer to a child component hanging around which a flexbox object is attempting to position.
No, you’re misunderstanding that. Sure, create your FlexBox objects in resized, that’s trivial, but you shouldn’t mess around creating/adding/removing child components in there.
ok. based on my debug statements, resized() was only being called twice. Once when the app loads, and then once again when setSelectedId() the comboBox in the MCC constructor. If i didn’t have resized() inside the comboBoxChanged() method, resized() would only be called once.
If it works like that, I’ve been doing wrong code for the past 5 years or so. (So no, doing a for loop like that will work, but of course it doesn’t affect performance in any way. Doing ++i instead of i++ is just to get in the habit of using ++i in case the i is not a trivial integer but rather some more heavy iterator object which might be slow if i++ is done on it.)
sure thing, but im not discussing luxury of getting into right habbit, just pointing that the i is already incremented while @matkatmusic is instantiating his placeholders. obvoiusly i should run the code myself, but its not possible at the moment. sorry i cant help now
yeah, i just tried. i blame myself. for my whole life ive been avoiding ++i in a simple for loop scenarios assuming that it will be already inremented while reaching the scope