bwidgets/inc/basic_widgets/w/button.hpp

44 lines
1.5 KiB
C++

#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};
void _handle_focus_change(bool /*unused*/) override {}
void _handle_font_change(core::Font* /*unused*/) override;
void _handle_font_color_change(const SDL_Color& /*unused*/,
const SDL_Color& /*unused*/) override;
void _handle_geometry_change(const SDL_Rect& /*unused*/) noexcept override;
void _handle_renderer_change(core::Renderer* /*unused*/) override;
void _handle_rendering() override;
public:
core::Size border_size {3, 3};
SDL_Color color_bg {150, 150, 150, // NOLINT(readability-magic-numbers)
SDL_ALPHA_OPAQUE};
SDL_Color color_bg_hover {175, 175, 175, // NOLINT(readability-magic-numbers)
SDL_ALPHA_OPAQUE};
Button(Widget* parent = nullptr);
[[nodiscard]] auto size() const noexcept -> core::Size override;
[[nodiscard]] virtual auto text() const noexcept -> const std::string&;
virtual auto text(const std::string&) -> Button*;
};
}
#endif