mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-25 15:45:38 +00:00
Fixed an issue where setting the carousel itemSize property to zero could crash the application.
Also fixed a small carousel glitch.
This commit is contained in:
parent
74a2256037
commit
db46180024
|
@ -640,7 +640,7 @@ template <typename T> void CarouselComponent<T>::render(const glm::mat4& parentT
|
||||||
int itemInclusionAfter {0};
|
int itemInclusionAfter {0};
|
||||||
|
|
||||||
if (mLegacyMode || mType == CarouselType::HORIZONTAL || mType == CarouselType::VERTICAL) {
|
if (mLegacyMode || mType == CarouselType::HORIZONTAL || mType == CarouselType::VERTICAL) {
|
||||||
itemInclusion = static_cast<int>(std::ceil(mMaxItemCount / 2.0f));
|
itemInclusion = static_cast<int>(std::ceil(mMaxItemCount / 2.0f)) + 1;
|
||||||
itemInclusionAfter = 2;
|
itemInclusionAfter = 2;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -880,18 +880,7 @@ void CarouselComponent<T>::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (elem->has("itemSize")) {
|
if (elem->has("itemSize")) {
|
||||||
// Keep size within a 0.05 and 1.0 multiple of the screen size.
|
const glm::vec2 itemSize {glm::clamp(elem->get<glm::vec2>("itemSize"), 0.05f, 1.0f)};
|
||||||
glm::vec2 itemSize {elem->get<glm::vec2>("itemSize")};
|
|
||||||
if (std::max(itemSize.x, itemSize.y) > 1.0f) {
|
|
||||||
itemSize /= std::max(itemSize.x, itemSize.y);
|
|
||||||
}
|
|
||||||
else if (std::min(itemSize.x, itemSize.y) < 0.005f) {
|
|
||||||
float ratio {std::min(itemSize.x, itemSize.y) / 0.005f};
|
|
||||||
itemSize /= ratio;
|
|
||||||
// Just an extra precaution if a crazy ratio was used.
|
|
||||||
itemSize.x = glm::clamp(itemSize.x, 0.005f, 1.0f);
|
|
||||||
itemSize.y = glm::clamp(itemSize.y, 0.005f, 1.0f);
|
|
||||||
}
|
|
||||||
mItemSize =
|
mItemSize =
|
||||||
itemSize * glm::vec2(Renderer::getScreenWidth(), Renderer::getScreenHeight());
|
itemSize * glm::vec2(Renderer::getScreenWidth(), Renderer::getScreenHeight());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue