From 15bed81f8758825a108d4b9d82b5d1357ff83385 Mon Sep 17 00:00:00 2001 From: hogliux Date: Thu, 27 Oct 2016 18:36:47 +0100 Subject: [PATCH] Fixed a flex box bug where the first item in a list of too large items would not be layouted properly --- modules/juce_gui_basics/layout/juce_FlexBox.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/juce_gui_basics/layout/juce_FlexBox.cpp b/modules/juce_gui_basics/layout/juce_FlexBox.cpp index 31ab92de29..6d53a1832d 100644 --- a/modules/juce_gui_basics/layout/juce_FlexBox.cpp +++ b/modules/juce_gui_basics/layout/juce_FlexBox.cpp @@ -132,6 +132,7 @@ struct FlexBoxLayoutCalculation { auto currentLength = containerLineLength; int column = 0, row = 0; + bool firstRow = true; for (auto& item : itemStates) { @@ -141,7 +142,10 @@ struct FlexBoxLayoutCalculation if (flexitemLength > currentLength) { - if (++row >= numItems) + if (! firstRow) + row++; + + if (row >= numItems) break; column = 0; @@ -153,6 +157,7 @@ struct FlexBoxLayoutCalculation lineItems[row * numItems + column] = &item; ++column; lineInfo[row].numItems = jmax (lineInfo[row].numItems, column); + firstRow = false; } } }