2021-09-07 15:21:54 +00:00
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
//
|
|
|
|
// EmulationStation Desktop Edition
|
|
|
|
// FlexboxComponent.h
|
|
|
|
//
|
|
|
|
// Flexbox layout component.
|
|
|
|
// Used by gamelist views.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef ES_APP_COMPONENTS_FLEXBOX_COMPONENT_H
|
|
|
|
#define ES_APP_COMPONENTS_FLEXBOX_COMPONENT_H
|
|
|
|
|
|
|
|
#include "GuiComponent.h"
|
|
|
|
#include "renderers/Renderer.h"
|
|
|
|
|
2021-09-13 23:01:46 +00:00
|
|
|
// Definitions for the option values.
|
2021-09-07 15:21:54 +00:00
|
|
|
#define DIRECTION_ROW "row"
|
|
|
|
#define DIRECTION_COLUMN "column"
|
|
|
|
#define ITEM_ALIGN_START "start"
|
|
|
|
#define ITEM_ALIGN_END "end"
|
|
|
|
#define ITEM_ALIGN_CENTER "center"
|
|
|
|
#define ITEM_ALIGN_STRETCH "stretch"
|
2021-09-13 23:01:46 +00:00
|
|
|
|
|
|
|
// Default values.
|
2021-09-07 15:21:54 +00:00
|
|
|
#define DEFAULT_DIRECTION DIRECTION_ROW
|
|
|
|
#define DEFAULT_ALIGN ITEM_ALIGN_CENTER
|
2021-09-13 23:01:46 +00:00
|
|
|
#define DEFAULT_ITEMS_PER_LINE 4
|
|
|
|
#define DEFAULT_MARGIN_X 10.0f
|
|
|
|
#define DEFAULT_MARGIN_Y 10.0f
|
|
|
|
#define DEFAULT_ITEM_SIZE_X 64.0f
|
2021-09-07 15:21:54 +00:00
|
|
|
|
|
|
|
class TextureResource;
|
|
|
|
|
|
|
|
class FlexboxComponent : public GuiComponent
|
|
|
|
{
|
|
|
|
public:
|
2021-09-13 23:01:46 +00:00
|
|
|
FlexboxComponent(Window* window);
|
|
|
|
|
|
|
|
// Getters/Setters for rendering options.
|
|
|
|
void setDirection(std::string value);
|
|
|
|
std::string getDirection();
|
|
|
|
void setAlign(std::string value);
|
|
|
|
std::string getAlign();
|
|
|
|
void setItemsPerLine(unsigned int value);
|
|
|
|
unsigned int getItemsPerLine();
|
|
|
|
void setItemMargin(glm::vec2 value);
|
|
|
|
glm::vec2 getItemMargin();
|
|
|
|
void setItemWidth(float value);
|
|
|
|
float getItemWidth();
|
2021-09-07 15:21:54 +00:00
|
|
|
|
|
|
|
void onSizeChanged() override;
|
2021-09-13 23:01:46 +00:00
|
|
|
void render(const glm::mat4& parentTrans) override;
|
2021-09-07 15:21:54 +00:00
|
|
|
virtual void applyTheme(const std::shared_ptr<ThemeData>& theme,
|
|
|
|
const std::string& view,
|
|
|
|
const std::string& element,
|
|
|
|
unsigned int properties) override;
|
|
|
|
virtual std::vector<HelpPrompt> getHelpPrompts() override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
// Calculate flexbox layout.
|
2021-09-13 23:01:46 +00:00
|
|
|
void computeLayout();
|
2021-09-07 15:21:54 +00:00
|
|
|
|
2021-09-13 23:01:46 +00:00
|
|
|
// Rendering options.
|
2021-09-07 15:21:54 +00:00
|
|
|
std::string mDirection;
|
|
|
|
std::string mAlign;
|
2021-09-13 23:01:46 +00:00
|
|
|
unsigned int mItemsPerLine;
|
|
|
|
glm::vec2 mItemMargin;
|
|
|
|
float mItemWidth;
|
2021-09-07 15:21:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // ES_APP_COMPONENTS_FLEXBOX_COMPONENT_H
|