diff --git a/es-core/src/ThemeData.cpp b/es-core/src/ThemeData.cpp index 6b591d339..a7594d4f1 100644 --- a/es-core/src/ThemeData.cpp +++ b/es-core/src/ThemeData.cpp @@ -267,6 +267,7 @@ std::map> {"maxLogoCount", FLOAT}, // For backward compatibility with legacy themes. {"itemSize", NORMALIZED_PAIR}, {"itemScale", FLOAT}, + {"itemTransitions", STRING}, {"itemInterpolation", STRING}, {"itemRotation", FLOAT}, {"itemRotationOrigin", NORMALIZED_PAIR}, diff --git a/es-core/src/components/primary/CarouselComponent.h b/es-core/src/components/primary/CarouselComponent.h index d81af7399..6224aee7f 100644 --- a/es-core/src/components/primary/CarouselComponent.h +++ b/es-core/src/components/primary/CarouselComponent.h @@ -139,6 +139,7 @@ private: float mItemScale; float mItemRotation; glm::vec2 mItemRotationOrigin; + int mTransitionsAnimTime; unsigned int mCarouselColor; unsigned int mCarouselColorEnd; bool mColorGradientHorizontal; @@ -180,6 +181,7 @@ CarouselComponent::CarouselComponent() , mItemScale {1.2f} , mItemRotation {7.5f} , mItemRotationOrigin {-3.0f, 0.5f} + , mTransitionsAnimTime {500} , mCarouselColor {0} , mCarouselColorEnd {0} , mColorGradientHorizontal {true} @@ -837,6 +839,23 @@ void CarouselComponent::applyTheme(const std::shared_ptr& theme, } } + if (elem->has("itemTransitions")) { + const std::string itemTransitions {elem->get("itemTransitions")}; + if (itemTransitions == "slide") { + mTransitionsAnimTime = 500; + } + else if (itemTransitions == "instant") { + mTransitionsAnimTime = 0; + } + else { + mTransitionsAnimTime = 500; + LOG(LogWarning) << "CarouselComponent: Invalid theme configuration, property " + "\"itemTransitions\" for element \"" + << element.substr(9) << "\" defined as \"" << itemTransitions + << "\""; + } + } + if (elem->has("itemSize")) { // Keep size within a 0.05 and 1.0 multiple of the screen size. glm::vec2 itemSize {elem->get("itemSize")}; @@ -1124,7 +1143,7 @@ template void CarouselComponent::onCursorChanged(const CursorSta mEntryCamOffset = f; }, - 500)}; + mTransitionsAnimTime)}; GuiComponent::setAnimation(anim, 0, nullptr, false, 0);