#pragma once #include "../GuiComponent.h" #include #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& func = nullptr); void setPressedFunc(std::function 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 getHelpPrompts() override; private: std::shared_ptr getFont(); std::function 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 mTextCache; NinePatchComponent mBox; };