From 4e54508e45ba3c99813a54c75df1e08d90db9f36 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Sun, 6 Nov 2022 21:34:03 +0100 Subject: [PATCH] Added a GridComponent skeleton. --- es-app/src/views/SystemView.h | 1 + es-core/CMakeLists.txt | 1 + .../src/components/primary/GridComponent.h | 70 +++++++++++++++++++ 3 files changed, 72 insertions(+) create mode 100644 es-core/src/components/primary/GridComponent.h diff --git a/es-app/src/views/SystemView.h b/es-app/src/views/SystemView.h index 462dd1c81..26a15442d 100644 --- a/es-app/src/views/SystemView.h +++ b/es-app/src/views/SystemView.h @@ -21,6 +21,7 @@ #include "components/TextComponent.h" #include "components/VideoFFmpegComponent.h" #include "components/primary/CarouselComponent.h" +#include "components/primary/GridComponent.h" #include "components/primary/TextListComponent.h" #include "resources/Font.h" diff --git a/es-core/CMakeLists.txt b/es-core/CMakeLists.txt index 40cc69038..59b07a8cf 100644 --- a/es-core/CMakeLists.txt +++ b/es-core/CMakeLists.txt @@ -33,6 +33,7 @@ set(CORE_HEADERS # Primary GUI components ${CMAKE_CURRENT_SOURCE_DIR}/src/components/primary/CarouselComponent.h + ${CMAKE_CURRENT_SOURCE_DIR}/src/components/primary/GridComponent.h ${CMAKE_CURRENT_SOURCE_DIR}/src/components/primary/PrimaryComponent.h ${CMAKE_CURRENT_SOURCE_DIR}/src/components/primary/TextListComponent.h diff --git a/es-core/src/components/primary/GridComponent.h b/es-core/src/components/primary/GridComponent.h new file mode 100644 index 000000000..770a86d9a --- /dev/null +++ b/es-core/src/components/primary/GridComponent.h @@ -0,0 +1,70 @@ +// SPDX-License-Identifier: MIT +// +// EmulationStation Desktop Edition +// GridComponent.h +// +// Grid, usable in both the system and gamelist views. +// + +#ifndef ES_CORE_COMPONENTS_GRID_COMPONENT_H +#define ES_CORE_COMPONENTS_GRID_COMPONENT_H + +#include "components/IList.h" +#include "components/primary/PrimaryComponent.h" + +struct GridEntry { + std::shared_ptr item; + std::string itemPath; + std::string defaultItemPath; +}; + +template +class GridComponent : public PrimaryComponent, protected IList +{ + using List = IList; + +protected: + using List::mCursor; + using List::mEntries; + +public: + GridComponent(); + + void setCancelTransitionsCallback(const std::function& func) override + { + mCancelTransitionsCallback = func; + } + void setCursorChangedCallback(const std::function& func) override + { + mCursorChangedCallback = func; + } + int getCursor() override { return mCursor; } + const size_t getNumEntries() override { return mEntries.size(); } + const bool getFadeAbovePrimary() const override { return mFadeAbovePrimary; } + const LetterCase getLetterCase() const override { return mLetterCase; } + virtual const LetterCase getLetterCaseCollections() const = 0; + virtual const LetterCase getLetterCaseGroupedCollections() const = 0; + +private: + Renderer* mRenderer; + std::function mCancelTransitionsCallback; + std::function mCursorChangedCallback; + + bool mFadeAbovePrimary; + LetterCase mLetterCase; + LetterCase mLetterCaseCollections; + LetterCase mLetterCaseGroupedCollections; +}; + +template +GridComponent::GridComponent() + : IList {} + , mRenderer {Renderer::getInstance()} + , mFadeAbovePrimary {false} + , mLetterCase {LetterCase::NONE} + , mLetterCaseCollections {LetterCase::NONE} + , mLetterCaseGroupedCollections {LetterCase::NONE} +{ +} + +#endif // ES_CORE_COMPONENTS_GRID_COMPONENT_H