ES-DE/src/components/NinePatchComponent.h
Aloshi e6d0da998b Theme applicators have become the virtual method
GuiComponent::applyTheme(theme, view, element, properties).
Applying fonts works now.
2013-12-31 23:39:22 -06:00

43 lines
1.1 KiB
C++

#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;
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;
};