2020-09-21 17:17:34 +00:00
|
|
|
// SPDX-License-Identifier: MIT
|
2020-06-28 16:39:18 +00:00
|
|
|
//
|
2020-09-21 17:17:34 +00:00
|
|
|
// EmulationStation Desktop Edition
|
2020-06-28 16:39:18 +00:00
|
|
|
// GridTileComponent.h
|
|
|
|
//
|
2022-01-15 12:38:09 +00:00
|
|
|
// X*Y tile grid, used indirectly by GridGamelistView via ImageGridComponent.
|
2020-06-28 16:39:18 +00:00
|
|
|
//
|
|
|
|
|
2018-04-07 19:23:10 +00:00
|
|
|
#ifndef ES_CORE_COMPONENTS_GRID_TILE_COMPONENT_H
|
|
|
|
#define ES_CORE_COMPONENTS_GRID_TILE_COMPONENT_H
|
|
|
|
|
|
|
|
#include "ImageComponent.h"
|
2020-09-21 17:17:34 +00:00
|
|
|
#include "NinePatchComponent.h"
|
2018-04-07 19:23:10 +00:00
|
|
|
|
2020-06-28 16:39:18 +00:00
|
|
|
struct GridTileProperties {
|
2021-08-16 16:25:01 +00:00
|
|
|
glm::vec2 mSize;
|
|
|
|
glm::vec2 mPadding;
|
2020-06-28 16:39:18 +00:00
|
|
|
unsigned int mImageColor;
|
|
|
|
std::string mBackgroundImage;
|
2021-08-16 16:25:01 +00:00
|
|
|
glm::vec2 mBackgroundCornerSize;
|
2020-06-28 16:39:18 +00:00
|
|
|
unsigned int mBackgroundCenterColor;
|
|
|
|
unsigned int mBackgroundEdgeColor;
|
2018-04-07 19:23:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class GridTileComponent : public GuiComponent
|
|
|
|
{
|
|
|
|
public:
|
2020-06-28 16:39:18 +00:00
|
|
|
GridTileComponent(Window* window);
|
2018-04-07 19:23:10 +00:00
|
|
|
|
2021-08-15 17:30:31 +00:00
|
|
|
void render(const glm::mat4& parentTrans) override;
|
2022-01-18 16:40:47 +00:00
|
|
|
void applyTheme(const std::shared_ptr<ThemeData>& theme,
|
|
|
|
const std::string& view,
|
|
|
|
const std::string& element,
|
|
|
|
unsigned int properties) override;
|
2018-04-07 19:23:10 +00:00
|
|
|
|
2020-06-28 16:39:18 +00:00
|
|
|
// Made this a static function because the ImageGridComponent needs to know the default tile
|
|
|
|
// max size to calculate the grid dimension before it instantiates the GridTileComponents.
|
2021-08-16 16:25:01 +00:00
|
|
|
static glm::vec2 getDefaultTileSize();
|
|
|
|
glm::vec2 getSelectedTileSize() const;
|
2020-06-28 16:39:18 +00:00
|
|
|
bool isSelected() const;
|
2018-04-07 19:23:10 +00:00
|
|
|
|
2021-07-07 18:31:46 +00:00
|
|
|
void reset() { setImage(""); }
|
2019-07-06 14:50:50 +00:00
|
|
|
|
2020-06-28 16:39:18 +00:00
|
|
|
void setImage(const std::string& path);
|
|
|
|
void setImage(const std::shared_ptr<TextureResource>& texture);
|
2021-07-07 18:31:46 +00:00
|
|
|
void setSelected(bool selected,
|
|
|
|
bool allowAnimation = true,
|
2021-08-15 17:30:31 +00:00
|
|
|
glm::vec3* pPosition = nullptr,
|
2021-07-07 18:31:46 +00:00
|
|
|
bool force = false);
|
2020-06-28 16:39:18 +00:00
|
|
|
void setVisible(bool visible);
|
2018-04-07 19:23:10 +00:00
|
|
|
|
2021-08-16 16:25:01 +00:00
|
|
|
void forceSize(glm::vec2 size, float selectedZoom);
|
2019-07-06 14:50:50 +00:00
|
|
|
|
2021-08-15 17:30:31 +00:00
|
|
|
glm::vec3 getBackgroundPosition();
|
2019-07-06 14:50:50 +00:00
|
|
|
|
2022-01-18 16:40:47 +00:00
|
|
|
void update(int deltaTime) override;
|
2019-07-06 14:50:50 +00:00
|
|
|
|
2020-06-28 16:39:18 +00:00
|
|
|
std::shared_ptr<TextureResource> getTexture();
|
2019-07-06 14:50:50 +00:00
|
|
|
|
2018-04-07 19:23:10 +00:00
|
|
|
private:
|
2020-06-28 16:39:18 +00:00
|
|
|
void resize();
|
|
|
|
void calcCurrentProperties();
|
|
|
|
void setSelectedZoom(float percent);
|
2018-04-07 19:23:10 +00:00
|
|
|
|
2020-06-28 16:39:18 +00:00
|
|
|
std::shared_ptr<ImageComponent> mImage;
|
|
|
|
NinePatchComponent mBackground;
|
2018-04-07 19:23:10 +00:00
|
|
|
|
2020-06-28 16:39:18 +00:00
|
|
|
GridTileProperties mDefaultProperties;
|
|
|
|
GridTileProperties mSelectedProperties;
|
|
|
|
GridTileProperties mCurrentProperties;
|
2018-04-07 19:23:10 +00:00
|
|
|
|
2020-06-28 16:39:18 +00:00
|
|
|
float mSelectedZoomPercent;
|
|
|
|
bool mSelected;
|
|
|
|
bool mVisible;
|
2019-07-06 14:50:50 +00:00
|
|
|
|
2021-08-15 20:03:17 +00:00
|
|
|
glm::vec3 mAnimPosition;
|
2018-04-07 19:23:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // ES_CORE_COMPONENTS_GRID_TILE_COMPONENT_H
|