2013-08-22 20:29:50 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "../GuiComponent.h"
|
|
|
|
#include <functional>
|
|
|
|
#include "../Font.h"
|
2013-08-23 02:41:40 +00:00
|
|
|
#include "NinePatchComponent.h"
|
2013-08-22 20:29:50 +00:00
|
|
|
|
|
|
|
class ButtonComponent : public GuiComponent
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ButtonComponent(Window* window);
|
|
|
|
|
|
|
|
void setPressedFunc(std::function<void()> f);
|
|
|
|
|
|
|
|
bool input(InputConfig* config, Input input) override;
|
|
|
|
void render(const Eigen::Affine3f& parentTrans) override;
|
|
|
|
|
|
|
|
void setText(const std::string& text, unsigned int color);
|
2013-08-23 02:41:40 +00:00
|
|
|
|
|
|
|
void onSizeChanged() override;
|
|
|
|
|
2013-08-22 20:29:50 +00:00
|
|
|
private:
|
|
|
|
std::shared_ptr<Font> getFont();
|
|
|
|
std::function<void()> mPressedFunc;
|
|
|
|
|
|
|
|
std::string mText;
|
|
|
|
std::unique_ptr<TextCache> mTextCache;
|
2013-08-23 02:41:40 +00:00
|
|
|
NinePatchComponent mBox;
|
2013-08-22 20:29:50 +00:00
|
|
|
};
|