Added a GridComponent skeleton.

This commit is contained in:
Leon Styhre 2022-11-06 21:34:03 +01:00
parent 5bedb7a8fa
commit 4e54508e45
3 changed files with 72 additions and 0 deletions

View file

@ -21,6 +21,7 @@
#include "components/TextComponent.h" #include "components/TextComponent.h"
#include "components/VideoFFmpegComponent.h" #include "components/VideoFFmpegComponent.h"
#include "components/primary/CarouselComponent.h" #include "components/primary/CarouselComponent.h"
#include "components/primary/GridComponent.h"
#include "components/primary/TextListComponent.h" #include "components/primary/TextListComponent.h"
#include "resources/Font.h" #include "resources/Font.h"

View file

@ -33,6 +33,7 @@ set(CORE_HEADERS
# Primary GUI components # Primary GUI components
${CMAKE_CURRENT_SOURCE_DIR}/src/components/primary/CarouselComponent.h ${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/PrimaryComponent.h
${CMAKE_CURRENT_SOURCE_DIR}/src/components/primary/TextListComponent.h ${CMAKE_CURRENT_SOURCE_DIR}/src/components/primary/TextListComponent.h

View file

@ -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<GuiComponent> item;
std::string itemPath;
std::string defaultItemPath;
};
template <typename T>
class GridComponent : public PrimaryComponent<T>, protected IList<GridEntry, T>
{
using List = IList<GridEntry, T>;
protected:
using List::mCursor;
using List::mEntries;
public:
GridComponent();
void setCancelTransitionsCallback(const std::function<void()>& func) override
{
mCancelTransitionsCallback = func;
}
void setCursorChangedCallback(const std::function<void(CursorState state)>& 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<void()> mCancelTransitionsCallback;
std::function<void(CursorState state)> mCursorChangedCallback;
bool mFadeAbovePrimary;
LetterCase mLetterCase;
LetterCase mLetterCaseCollections;
LetterCase mLetterCaseGroupedCollections;
};
template <typename T>
GridComponent<T>::GridComponent()
: IList<GridEntry, T> {}
, mRenderer {Renderer::getInstance()}
, mFadeAbovePrimary {false}
, mLetterCase {LetterCase::NONE}
, mLetterCaseCollections {LetterCase::NONE}
, mLetterCaseGroupedCollections {LetterCase::NONE}
{
}
#endif // ES_CORE_COMPONENTS_GRID_COMPONENT_H