Idea for debugging flexbox and flexitem



Attempting to debug what I initially thought was a simple use of flexbox and flexitem. But window shows up empty after an evening of trying different things.

Which got me thinking – would be nice if there was some sort of recursive method to call in FlexBox which would generate strings or a string explaining what it is resizing, and the reason why it is doing it.

So the same way we call flexbox.performLayout® in resized(), maybe we could also have one that passes in a String, or…?


@daniel came up with this little gem when I was learning how to use FlexBox:

void FlexBox::performLayout (Rectangle<float> targetArea)
for (auto& item : items)
            item.currentBounds += targetArea.getPosition();

            if (auto comp = item.associatedComponent)
                //comp->setBounds (item.currentBounds.getSmallestIntegerContainer());
                auto position = item.currentBounds.getPosition().roundToInt();
                                roundToInt(item.currentBounds.getRight()) - position.getX(),
                                roundToInt(item.currentBounds.getBottom()) - position.getY() );

                DBG ("placed: " + comp->getName() + ": " + item.currentBounds.getSmallestIntegerContainer().toString());

            if (auto box = item.associatedFlexBox)
                box->performLayout (item.currentBounds);


wow, I don’t remember at all, so maybe I don’t deserve that credits… but thanks, if I do :wink:


lol you just added the DBG statement, but it was clutch placement!