2013-08-23 02:41:40 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "../GuiComponent.h"
|
|
|
|
#include "../resources/TextureResource.h"
|
|
|
|
|
|
|
|
class NinePatchComponent : public GuiComponent
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
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());
|
2013-08-23 02:41:40 +00:00
|
|
|
|
2013-09-14 15:58:34 +00:00
|
|
|
void setImagePath(const std::string& path);
|
|
|
|
void setEdgeColor(unsigned int edgeColor);
|
|
|
|
void setCenterColor(unsigned int centerColor);
|
|
|
|
|
2013-08-23 02:41:40 +00:00
|
|
|
private:
|
|
|
|
Eigen::Vector2f getCornerSize() const;
|
|
|
|
|
|
|
|
void buildVertices();
|
2013-09-14 15:58:34 +00:00
|
|
|
void updateColors();
|
2013-08-23 02:41:40 +00:00
|
|
|
|
|
|
|
struct Vertex
|
|
|
|
{
|
|
|
|
Eigen::Vector2f pos;
|
|
|
|
Eigen::Vector2f tex;
|
|
|
|
};
|
|
|
|
|
|
|
|
Vertex* mVertices;
|
|
|
|
GLubyte* mColors;
|
|
|
|
|
2013-09-14 15:58:34 +00:00
|
|
|
std::string mPath;
|
2013-08-23 02:41:40 +00:00
|
|
|
unsigned int mEdgeColor;
|
|
|
|
unsigned int mCenterColor;
|
|
|
|
std::shared_ptr<TextureResource> mTexture;
|
|
|
|
};
|