2021-07-18 18:26:12 +02:00
|
|
|
#ifndef BWIDGETS_BUTTON_HPP_
|
|
|
|
#define BWIDGETS_BUTTON_HPP_
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include <basic_widgets/w/caption.hpp>
|
|
|
|
#include <basic_widgets/w/feat/mouse_handler.hpp>
|
|
|
|
|
|
|
|
namespace bwidgets::widget
|
|
|
|
{
|
|
|
|
class Button : public Widget, public FontHandler, public MouseHandler
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
Caption _caption;
|
|
|
|
SDL_Rect _caption_area;
|
|
|
|
SDL_Color _color_foreground {0, 0, 0, SDL_ALPHA_OPAQUE};
|
|
|
|
|
2021-07-19 23:50:50 +02:00
|
|
|
virtual void _handle_focus_change(bool) override {}
|
2021-07-18 18:26:12 +02:00
|
|
|
virtual void _handle_font_change(core::Font*) override;
|
2021-07-19 23:50:50 +02:00
|
|
|
virtual void _handle_font_color_change(const SDL_Color&, const SDL_Color&) override;
|
2021-07-18 18:26:12 +02:00
|
|
|
virtual void _handle_geometry_change(const SDL_Rect&) noexcept override;
|
|
|
|
virtual void _handle_renderer_change(core::Renderer*) override;
|
|
|
|
virtual void _handle_rendering() override;
|
|
|
|
|
|
|
|
public:
|
2021-07-19 23:50:50 +02:00
|
|
|
core::Size border_size {3, 3};
|
|
|
|
SDL_Color color_bg {150, 150, 150, SDL_ALPHA_OPAQUE};
|
|
|
|
SDL_Color color_bg_hover {175, 175, 175, SDL_ALPHA_OPAQUE};
|
2021-07-18 18:26:12 +02:00
|
|
|
|
|
|
|
Button(Widget* parent=nullptr);
|
|
|
|
|
|
|
|
virtual core::Size size() const noexcept override;
|
|
|
|
virtual const std::string& text() const noexcept;
|
2021-07-19 23:50:50 +02:00
|
|
|
virtual Button* text(std::string);
|
2021-07-18 18:26:12 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|