ES-DE/src/components/NinePatchComponent.h

43 lines
1.1 KiB
C
Raw Normal View History

#pragma once
#include "../GuiComponent.h"
#include "../resources/TextureResource.h"
class NinePatchComponent : public GuiComponent
{
public:
2013-11-23 20:04:11 +00:00
NinePatchComponent(Window* window, const std::string& path = "", unsigned int edgeColor = 0xFFFFFFFF, unsigned int centerColor = 0xFFFFFFFF);
void render(const Eigen::Affine3f& parentTrans) override;
void onSizeChanged() override;
2013-09-14 16:14:21 +00:00
void fitTo(Eigen::Vector2f size, Eigen::Vector3f position = Eigen::Vector3f::Zero(), Eigen::Vector2f padding = Eigen::Vector2f::Zero());
void setImagePath(const std::string& path);
void setEdgeColor(unsigned int edgeColor);
void setCenterColor(unsigned int centerColor);
virtual void applyTheme(const std::shared_ptr<ThemeData>& theme, const std::string& view, const std::string& element, unsigned int properties) override;
private:
Eigen::Vector2f getCornerSize() const;
void buildVertices();
void updateColors();
struct Vertex
{
Eigen::Vector2f pos;
Eigen::Vector2f tex;
};
Vertex* mVertices;
GLubyte* mColors;
std::string mPath;
unsigned int mEdgeColor;
unsigned int mCenterColor;
std::shared_ptr<TextureResource> mTexture;
};