I’m using juce::Grid to layout some sliders with separators between them.
The separators have a width of 1, specified like so:
grid.templateColumns.add (juce::Grid::TrackInfo{ juce::Grid::Px{ 1 } });
Problem:
With certain window sizes, some of these separators disappear as their widths are being set to 0 by the grid.
I’ve narrowed the issue down to the following line:
alignContent,
justifyContent,
columnGap,
rowGap);
auto* item = itemAndArea.first;
item->currentBounds = Grid::BoxAlignment::alignItem (*item, *this, areaBounds)
+ targetArea.toFloat().getPosition();
if (auto* c = item->associatedComponent)
c->setBounds (item->currentBounds.toNearestIntEdges());
}
}
//==============================================================================
#if JUCE_UNIT_TESTS
struct GridTests : public UnitTest
{
GridTests()
: UnitTest ("Grid", UnitTestCategories::gui)
In cases where the separators have a non-integer position, the roundToIntEdges() call is rounding the left of the area up, and the right of the area down causing the separators to have a final width of 0.
Suggested Solution:
Replace roundToIntEdges() with roundToInt().
1 Like
attila
September 23, 2022, 10:33am
2
Thank you for reporting this. A fix is now out on develop
committed 04:18PM - 22 Sep 22 UTC
Until this commit Items with a size of 1 could be rounded to
bounds with a size … of 0 or 2 due to floating point errors, leading
to slightly too large or disappearing items. The new approach
preserves the size of items.
1 Like