From b9a2031cf6d35e93cd43aee5e2b0a73c1bed1096 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Sun, 4 Sep 2022 22:36:50 +0200 Subject: [PATCH] Increased the maximum allowed size for the carousel for legacy themes only. --- es-core/src/components/primary/CarouselComponent.h | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/es-core/src/components/primary/CarouselComponent.h b/es-core/src/components/primary/CarouselComponent.h index 46e4e1362..08b2b0c28 100644 --- a/es-core/src/components/primary/CarouselComponent.h +++ b/es-core/src/components/primary/CarouselComponent.h @@ -569,7 +569,7 @@ template void CarouselComponent::render(const glm::mat4& parentT } } else if (mType == CarouselType::VERTICAL) { - itemSpacing.y = ((mSize.y - (mItemSize.y * mMaxItemCount)) / (mMaxItemCount)) + mItemSize.y; + itemSpacing.y = ((mSize.y - (mItemSize.y * mMaxItemCount)) / mMaxItemCount) + mItemSize.y; yOff = (mSize.y - mItemSize.y) / 2.0f - (mEntryCamOffset * itemSpacing.y); if (mItemHorizontalAlignment == ALIGN_LEFT) { if (mLegacyMode) @@ -588,7 +588,7 @@ template void CarouselComponent::render(const glm::mat4& parentT } } else { // HORIZONTAL. - itemSpacing.x = ((mSize.x - (mItemSize.x * mMaxItemCount)) / (mMaxItemCount)) + mItemSize.x; + itemSpacing.x = ((mSize.x - (mItemSize.x * mMaxItemCount)) / mMaxItemCount) + mItemSize.x; xOff = (mSize.x - mItemSize.x) / 2.0f - (mEntryCamOffset * itemSpacing.x); if (mItemVerticalAlignment == ALIGN_TOP) { if (mLegacyMode) @@ -1040,10 +1040,16 @@ void CarouselComponent::applyTheme(const std::shared_ptr& theme, GuiComponent::applyTheme(theme, view, element, ALL); + // Some legacy themes use an excessively large carousel and although this is clearly an + // error we need to allow it so these themes render correctly. + float maxSize {1.5f}; + if (mLegacyMode) + maxSize = 2.0f; + mSize.x = glm::clamp(mSize.x, mRenderer->getScreenWidth() * 0.05f, - mRenderer->getScreenWidth() * 1.5f); + mRenderer->getScreenWidth() * maxSize); mSize.y = glm::clamp(mSize.y, mRenderer->getScreenHeight() * 0.05f, - mRenderer->getScreenHeight() * 1.5f); + mRenderer->getScreenHeight() * maxSize); } template void CarouselComponent::onCursorChanged(const CursorState& state)