I’m building a layout with FlexBox and want to have a 2 x 2 grid of visible rows and columns, which stretch to fit the available space. I know I could use the Grid class, but I actually want the items, which are unknown in number, to spill outside the visible area if there are more than 4 (across the horizontal axis), at which point they will be in a viewport so the user can scroll across to see the hidden items.
If I know the main window size, I can set the flex-basis property to just under half the height, and I get the desired layout. However, this will be a full screen app which could run on different resolution monitors, so ideally I want to be able to set the flex-basis property in the resize()
method. However, setting it there seems to have no effect. I can see that its possible to set this at runtime from the FlexBox demo.
My resized method:
void resized() override
{
for (auto flexItem : flexBox.items)
{
flexItem.flexBasis = getHeight() / 2 - 20;
DBG ("flexBasis set to " << flexItem.flexBasis);
}
flexBox.performLayout (getLocalBounds().toFloat());
}
I can see the resized method getting called, but my layout doesn’t change. Is there something I’m missing here?