#pragma once #include "../GuiComponent.h" #include #include "../Font.h" #include "NinePatchComponent.h" class ButtonComponent : public GuiComponent { public: ButtonComponent(Window* window); void setPressedFunc(std::function 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; private: std::shared_ptr getFont(); std::function mPressedFunc; bool mFocused; unsigned int mTextColorFocused; unsigned int mTextColorUnfocused; int mTextPulseTime; unsigned int getCurTextColor() const; std::string mText; std::unique_ptr mTextCache; NinePatchComponent mBox; };