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
|
|
|
|
//
|
2021-01-05 14:57:50 +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 {
|
|
|
|
Vector2f mSize;
|
|
|
|
Vector2f mPadding;
|
|
|
|
unsigned int mImageColor;
|
|
|
|
std::string mBackgroundImage;
|
|
|
|
Vector2f mBackgroundCornerSize;
|
|
|
|
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
|
|
|
|
2020-06-28 16:39:18 +00:00
|
|
|
void render(const Transform4x4f& parentTrans) override;
|
2021-07-07 18:31:46 +00:00
|
|
|
virtual 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.
|
|
|
|
static Vector2f getDefaultTileSize();
|
|
|
|
Vector2f getSelectedTileSize() const;
|
|
|
|
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,
|
|
|
|
Vector3f* pPosition = nullptr,
|
|
|
|
bool force = false);
|
2020-06-28 16:39:18 +00:00
|
|
|
void setVisible(bool visible);
|
2018-04-07 19:23:10 +00:00
|
|
|
|
2020-06-28 16:39:18 +00:00
|
|
|
void forceSize(Vector2f size, float selectedZoom);
|
2019-07-06 14:50:50 +00:00
|
|
|
|
2020-06-28 16:39:18 +00:00
|
|
|
Vector3f getBackgroundPosition();
|
2019-07-06 14:50:50 +00:00
|
|
|
|
2020-06-28 16:39:18 +00:00
|
|
|
virtual 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
|
|
|
|
2020-06-28 16:39:18 +00:00
|
|
|
Vector3f mAnimPosition;
|
2018-04-07 19:23:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // ES_CORE_COMPONENTS_GRID_TILE_COMPONENT_H
|