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
|
|
|
|
//
|
|
|
|
// X*Y grid.
|
|
|
|
//
|
|
|
|
|
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;
|
|
|
|
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
|
|
|
|
2020-06-28 16:39:18 +00:00
|
|
|
void reset();
|
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);
|
|
|
|
void setSelected(bool selected, bool allowAnimation = true,
|
|
|
|
Vector3f* pPosition = nullptr, bool force=false);
|
|
|
|
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
|