mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-24 07:05:39 +00:00
613787931a
Reluctantly changed button font to FONT_SIZE_MEDIUM because FONT_SIZE_SMALL has messed up sizing for some unknown reason.
45 lines
1.1 KiB
C++
45 lines
1.1 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);
|
|
|
|
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;
|
|
};
|