/* * ===================================================================================== * * Filename: TextButton.hpp * * Description: * * Created: 28/06/2018 10:16:52 * * Author: Quentin Bazin, * * ===================================================================================== */ #ifndef TEXTBUTTON_HPP_ #define TEXTBUTTON_HPP_ #include #include "Image.hpp" #include "Text.hpp" #include "Widget.hpp" class TextButton : public Widget { public: using Callback = std::function; TextButton(Widget *parent = nullptr); TextButton(const Callback &callback, Widget *parent = nullptr); void onEvent(const SDL_Event &event) override; const std::string &text() const { return m_text.text(); } void setText(const std::string &text); void setCallback(const Callback &callback) { m_callback = callback; } void setEnabled(bool isEnabled) { m_isEnabled = isEnabled; } private: void draw(RenderTarget &target, RenderStates states) const override; Image m_background{"texture-widgets"}; Image m_hoverBackground{"texture-widgets"}; Image m_disabledBackground{"texture-widgets"}; Text m_text; Callback m_callback; bool m_isHovered = false; bool m_isEnabled = true; }; #endif // TEXTBUTTON_HPP_