1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-24 01:54:22 +00:00

Respect GridItem min/max width/height

This commit is contained in:
Tom Maisey 2019-08-30 09:22:16 +01:00 committed by ed
parent ab2adfb6a8
commit 1a8d676f5b

View file

@ -918,26 +918,20 @@ struct Grid::BoxAlignment
// align and justify
auto r = area;
if (item.width != (float) GridItem::notAssigned)
r.setWidth (item.width);
if (item.height != (float) GridItem::notAssigned)
r.setHeight (item.height);
if (item.width != (float) GridItem::notAssigned) r.setWidth (item.width);
if (item.height != (float) GridItem::notAssigned) r.setHeight (item.height);
if (item.maxWidth != GridItem::notAssigned) r.setWidth (jmin (item.maxWidth, r.getWidth()));
if (item.minWidth != GridItem::notAssigned) r.setWidth (jmax (item.minWidth, r.getWidth()));
if (item.maxHeight != GridItem::notAssigned) r.setHeight (jmin (item.maxHeight, r.getHeight()));
if (item.minHeight != GridItem::notAssigned) r.setHeight (jmax (item.minHeight, r.getHeight()));
if (alignType == Grid::AlignItems::start && justifyType == Grid::JustifyItems::start)
return r;
if (alignType == Grid::AlignItems::end)
r.setY (r.getY() + (area.getHeight() - r.getHeight()));
if (justifyType == Grid::JustifyItems::end)
r.setX (r.getX() + (area.getWidth() - r.getWidth()));
if (alignType == Grid::AlignItems::center)
r.setCentre (r.getCentreX(), area.getCentreY());
if (justifyType == Grid::JustifyItems::center)
r.setCentre (area.getCentreX(), r.getCentreY());
if (alignType == Grid::AlignItems::end) r.setY (r.getY() + (area.getHeight() - r.getHeight()));
if (justifyType == Grid::JustifyItems::end) r.setX (r.getX() + (area.getWidth() - r.getWidth()));
if (alignType == Grid::AlignItems::center) r.setCentre (r.getCentreX(), area.getCentreY());
if (justifyType == Grid::JustifyItems::center) r.setCentre (area.getCentreX(), r.getCentreY());
return r;
}