ES-DE/src/components/ButtonComponent.h

39 lines
901 B
C
Raw Normal View History

2013-08-22 20:29:50 +00:00
#pragma once
#include "../GuiComponent.h"
#include <functional>
#include "../Font.h"
#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 focusedTextColor, unsigned int unfocusedTextColor = 0x555555FF);
void onSizeChanged() override;
void onFocusGained() override;
void onFocusLost() override;
2013-08-22 20:29:50 +00:00
private:
std::shared_ptr<Font> getFont();
std::function<void()> mPressedFunc;
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;
std::unique_ptr<TextCache> mTextCache;
NinePatchComponent mBox;
2013-08-22 20:29:50 +00:00
};