2013-08-22 20:29:50 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "../GuiComponent.h"
|
|
|
|
#include <functional>
|
2013-10-04 23:24:41 +00:00
|
|
|
#include "../resources/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;
|
|
|
|
|
2014-01-25 23:34:29 +00:00
|
|
|
void setText(const std::string& text, const std::string& helpText, unsigned int focusedTextColor, unsigned int unfocusedTextColor = 0x555555FF);
|
2013-08-23 02:41:40 +00:00
|
|
|
|
|
|
|
void onSizeChanged() override;
|
2013-09-07 22:43:36 +00:00
|
|
|
void onFocusGained() override;
|
|
|
|
void onFocusLost() override;
|
2013-08-23 02:41:40 +00:00
|
|
|
|
2014-01-25 23:34:29 +00:00
|
|
|
virtual std::vector<HelpPrompt> getHelpPrompts() override;
|
|
|
|
|
2013-08-22 20:29:50 +00:00
|
|
|
private:
|
|
|
|
std::shared_ptr<Font> getFont();
|
|
|
|
std::function<void()> mPressedFunc;
|
|
|
|
|
2013-09-07 22:43:36 +00:00
|
|
|
bool mFocused;
|
|
|
|
unsigned int mTextColorFocused;
|
|
|
|
unsigned int mTextColorUnfocused;
|
|
|
|
int mTextPulseTime;
|
|
|
|
|
|
|
|
unsigned int getCurTextColor() const;
|
|
|
|
|
2013-08-22 20:29:50 +00:00
|
|
|
std::string mText;
|
2014-01-25 23:34:29 +00:00
|
|
|
std::string mHelpText;
|
2013-08-22 20:29:50 +00:00
|
|
|
std::unique_ptr<TextCache> mTextCache;
|
2013-08-23 02:41:40 +00:00
|
|
|
NinePatchComponent mBox;
|
2013-08-22 20:29:50 +00:00
|
|
|
};
|