ES-DE/src/components/ButtonComponent.h
Aloshi 08dfc32f89 Added the new help images. Still need to redo HelpComponent to be better.
Added some more back buttons.
Forced text in OptionListComponent to be all capitals.
2014-03-15 17:06:16 -05:00

48 lines
1.2 KiB
C++

#pragma once
#include "../GuiComponent.h"
#include <functional>
#include "../resources/Font.h"
#include "NinePatchComponent.h"
class ButtonComponent : public GuiComponent
{
public:
ButtonComponent(Window* window, const std::string& text = "", const std::string& helpText = "", const std::function<void()>& func = nullptr);
void setPressedFunc(std::function<void()> f);
void setEnabled(bool enable);
bool input(InputConfig* config, Input input) override;
void render(const Eigen::Affine3f& parentTrans) override;
void setText(const std::string& text, const std::string& helpText);
inline const std::string& getText() const { return mText; };
inline const std::function<void()>& getPressedFunc() const { return mPressedFunc; };
void onSizeChanged() override;
void onFocusGained() override;
void onFocusLost() override;
virtual std::vector<HelpPrompt> getHelpPrompts() override;
private:
std::shared_ptr<Font> mFont;
std::function<void()> mPressedFunc;
bool mFocused;
bool mEnabled;
unsigned int mTextColorFocused;
unsigned int mTextColorUnfocused;
unsigned int getCurTextColor() const;
void updateImage();
std::string mText;
std::string mHelpText;
std::unique_ptr<TextCache> mTextCache;
NinePatchComponent mBox;
};