diff --git a/es-core/src/ThemeData.cpp b/es-core/src/ThemeData.cpp index bab18dec6..896ff8f6f 100644 --- a/es-core/src/ThemeData.cpp +++ b/es-core/src/ThemeData.cpp @@ -169,6 +169,7 @@ std::map> {"reflectionsOpacity", FLOAT}, {"reflectionsFalloff", FLOAT}, {"unfocusedItemOpacity", FLOAT}, + {"fastScrolling", BOOLEAN}, {"defaultLogo", PATH}, // For backward compatibility with legacy themes. {"logoSize", NORMALIZED_PAIR}, // For backward compatibility with legacy themes. {"logoScale", FLOAT}, // For backward compatibility with legacy themes. diff --git a/es-core/src/components/IList.h b/es-core/src/components/IList.h index b80008805..d79ce07a4 100644 --- a/es-core/src/components/IList.h +++ b/es-core/src/components/IList.h @@ -25,39 +25,6 @@ enum class ListLoopType { LIST_NEVER_LOOP }; -struct ScrollTier { - int length; // How long we stay on this tier before going to the next. - int scrollDelay; // How long between scrolls. -}; - -struct ScrollTierList { - const int count; - const ScrollTier* tiers; -}; - -// Default scroll tiers. -// clang-format off -const ScrollTier QUICK_SCROLL_TIERS[] = { - {500, 500}, - {1200, 114}, - {0, 16} -}; -const ScrollTierList LIST_SCROLL_STYLE_QUICK = { - 3, - QUICK_SCROLL_TIERS -}; - -const ScrollTier SLOW_SCROLL_TIERS[] = { - {500, 500}, - {0, 200} -}; - -const ScrollTierList LIST_SCROLL_STYLE_SLOW = { - 2, - SLOW_SCROLL_TIERS -}; -// clang-format on - template class IList : public virtual GuiComponent { public: @@ -68,9 +35,54 @@ public: }; protected: + struct ScrollTier { + int length; // How long we stay on this tier before going to the next. + int scrollDelay; // How long between scrolls. + }; + + struct ScrollTierList { + int count; + const ScrollTier* tiers; + }; + + // Default scroll tiers. + // clang-format off + static inline const ScrollTier QUICK_SCROLL_TIERS[3] { + {500, 500}, + {1200, 114}, + {0, 16} + }; + + static inline const ScrollTierList LIST_SCROLL_STYLE_QUICK { + 3, + QUICK_SCROLL_TIERS + }; + + static inline const ScrollTier MEDIUM_SCROLL_TIERS[3] { + {500, 500}, + {1100, 180}, + {0, 80} + }; + + static inline const ScrollTierList LIST_SCROLL_STYLE_MEDIUM { + 3, + MEDIUM_SCROLL_TIERS + }; + + static inline const ScrollTier SLOW_SCROLL_TIERS[2] { + {500, 500}, + {0, 200} + }; + + static inline const ScrollTierList LIST_SCROLL_STYLE_SLOW { + 2, + SLOW_SCROLL_TIERS + }; + // clang-format on + Window* mWindow; std::vector mEntries; - const ScrollTierList& mTierList; + ScrollTierList mTierList; const ListLoopType mLoopType; int mCursor; int mLastCursor; diff --git a/es-core/src/components/primary/CarouselComponent.h b/es-core/src/components/primary/CarouselComponent.h index 271518365..00a81eed9 100644 --- a/es-core/src/components/primary/CarouselComponent.h +++ b/es-core/src/components/primary/CarouselComponent.h @@ -199,7 +199,7 @@ private: template CarouselComponent::CarouselComponent() - : IList {LIST_SCROLL_STYLE_SLOW, + : IList {IList::LIST_SCROLL_STYLE_SLOW, (std::is_same_v ? ListLoopType::LIST_ALWAYS_LOOP : ListLoopType::LIST_PAUSE_AT_END_ON_JUMP)} @@ -1614,6 +1614,9 @@ void CarouselComponent::applyTheme(const std::shared_ptr& theme, if (elem->has("unfocusedItemOpacity")) mUnfocusedItemOpacity = glm::clamp(elem->get("unfocusedItemOpacity"), 0.1f, 1.0f); + + if (elem->has("fastScrolling") && elem->get("fastScrolling")) + List::mTierList = IList::LIST_SCROLL_STYLE_MEDIUM; } // Legacy themes. diff --git a/es-core/src/components/primary/GridComponent.h b/es-core/src/components/primary/GridComponent.h index e21e12e48..0fe3b2302 100644 --- a/es-core/src/components/primary/GridComponent.h +++ b/es-core/src/components/primary/GridComponent.h @@ -198,7 +198,8 @@ private: template GridComponent::GridComponent() - : IList {LIST_SCROLL_STYLE_SLOW, ListLoopType::LIST_PAUSE_AT_END} + : IList {IList::LIST_SCROLL_STYLE_SLOW, + ListLoopType::LIST_PAUSE_AT_END} , mRenderer {Renderer::getInstance()} , mEntryOffset {0.0f} , mScrollPos {0.0f} diff --git a/es-core/src/components/primary/TextListComponent.h b/es-core/src/components/primary/TextListComponent.h index c1a8fb240..38b50eb52 100644 --- a/es-core/src/components/primary/TextListComponent.h +++ b/es-core/src/components/primary/TextListComponent.h @@ -159,8 +159,9 @@ private: template TextListComponent::TextListComponent() - : IList {(std::is_same_v ? LIST_SCROLL_STYLE_SLOW : - LIST_SCROLL_STYLE_QUICK), + : IList {(std::is_same_v ? + IList::LIST_SCROLL_STYLE_SLOW : + IList::LIST_SCROLL_STYLE_QUICK), ListLoopType::LIST_PAUSE_AT_END} , mRenderer {Renderer::getInstance()} , mCamOffset {0.0f}