mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-24 07:05:39 +00:00
08dfc32f89
Added some more back buttons. Forced text in OptionListComponent to be all capitals.
48 lines
1.2 KiB
C++
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;
|
|
};
|