mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-01-18 15:15:37 +00:00
Merge branch '655-fix-the-left-and-right-alignment-in-badgescomponent'
This commit is contained in:
commit
62d327b071
|
@ -122,7 +122,7 @@ void FlexboxComponent::computeLayout()
|
||||||
newSize = sizeMaxX.x * sizeMaxX.y >= sizeMaxY.x * sizeMaxY.y ? sizeMaxX : sizeMaxY;
|
newSize = sizeMaxX.x * sizeMaxX.y >= sizeMaxY.x * sizeMaxY.y ? sizeMaxX : sizeMaxY;
|
||||||
|
|
||||||
if (image.second.getSize() != newSize)
|
if (image.second.getSize() != newSize)
|
||||||
image.second.setResize(newSize.x, newSize.y);
|
image.second.setResize(std::round(newSize.x), std::round(newSize.y));
|
||||||
|
|
||||||
// In case maxItemSize needs to be updated.
|
// In case maxItemSize needs to be updated.
|
||||||
if (newSize.x != sizeChange.x)
|
if (newSize.x != sizeChange.x)
|
||||||
|
@ -132,9 +132,9 @@ void FlexboxComponent::computeLayout()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (maxItemSize.x != sizeChange.x)
|
if (maxItemSize.x != sizeChange.x)
|
||||||
maxItemSize.x = sizeChange.x;
|
maxItemSize.x = std::round(sizeChange.x);
|
||||||
if (maxItemSize.y != sizeChange.y)
|
if (maxItemSize.y != sizeChange.y)
|
||||||
maxItemSize.y = sizeChange.y;
|
maxItemSize.y = std::round(sizeChange.y);
|
||||||
|
|
||||||
// Pre-compute layout parameters.
|
// Pre-compute layout parameters.
|
||||||
float anchorXStart{anchorX};
|
float anchorXStart{anchorX};
|
||||||
|
@ -166,10 +166,9 @@ void FlexboxComponent::computeLayout()
|
||||||
image.second.setSize(image.second.getSize().x, maxItemSize.y);
|
image.second.setSize(image.second.getSize().x, maxItemSize.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Doesn't work correctly.
|
|
||||||
// Apply overall container alignment.
|
// Apply overall container alignment.
|
||||||
if (mAlignment == "right")
|
if (mAlignment == "right")
|
||||||
x += (mSize.x - size.x * grid.x) - mItemMargin.x;
|
x += (mSize.x - maxItemSize.x * grid.x - (grid.x - 1) * mItemMargin.x);
|
||||||
|
|
||||||
// Store final item position.
|
// Store final item position.
|
||||||
image.second.setPosition(x, y);
|
image.second.setPosition(x, y);
|
||||||
|
@ -193,5 +192,21 @@ void FlexboxComponent::computeLayout()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Apply right-align to the images on the last row, if needed.
|
||||||
|
if (mAlignment == "right") {
|
||||||
|
std::vector<ImageComponent*> imagesToAlign;
|
||||||
|
for (auto& image : mImages) {
|
||||||
|
if (!image.second.isVisible())
|
||||||
|
continue;
|
||||||
|
// Only include images on the last row.
|
||||||
|
if (image.second.getPosition().y == anchorY)
|
||||||
|
imagesToAlign.push_back(&image.second);
|
||||||
|
}
|
||||||
|
for (auto& moveImage : imagesToAlign) {
|
||||||
|
float offset = (maxItemSize.x + mItemMargin.x) * (grid.x - imagesToAlign.size());
|
||||||
|
moveImage->setPosition(moveImage->getPosition().x + offset, moveImage->getPosition().y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
mLayoutValid = true;
|
mLayoutValid = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue