mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-25 23:55:38 +00:00
Added support for setting one of the itemSize property axes to -1 to get square GridComponent items.
This commit is contained in:
parent
4e56dafc59
commit
f0e3addee6
|
@ -722,8 +722,21 @@ void GridComponent<T>::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
|||
mFractionalRows = (elem->has("fractionalRows") && elem->get<bool>("fractionalRows"));
|
||||
|
||||
if (elem->has("itemSize")) {
|
||||
const glm::vec2& itemSize {glm::clamp(elem->get<glm::vec2>("itemSize"), 0.05f, 1.0f)};
|
||||
mItemSize = itemSize * glm::vec2(Renderer::getScreenWidth(), Renderer::getScreenHeight());
|
||||
const glm::vec2& itemSize {elem->get<glm::vec2>("itemSize")};
|
||||
if (!(itemSize.x == -1 && itemSize.y == -1)) {
|
||||
if (itemSize.x == -1) {
|
||||
mItemSize.y = glm::clamp(itemSize.y, 0.05f, 1.0f) * mRenderer->getScreenHeight();
|
||||
mItemSize.x = mItemSize.y;
|
||||
}
|
||||
else if (itemSize.y == -1) {
|
||||
mItemSize.x = glm::clamp(itemSize.x, 0.05f, 1.0f) * mRenderer->getScreenWidth();
|
||||
mItemSize.y = mItemSize.x;
|
||||
}
|
||||
else {
|
||||
mItemSize = glm::clamp(itemSize, 0.05f, 1.0f) *
|
||||
glm::vec2(mRenderer->getScreenWidth(), mRenderer->getScreenHeight());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (elem->has("itemScale"))
|
||||
|
|
Loading…
Reference in a new issue