59 lines
1.9 KiB
C++
59 lines
1.9 KiB
C++
#ifndef BWIDGETS_BUTTON_HPP
|
|
#define BWIDGETS_BUTTON_HPP
|
|
|
|
#include <functional>
|
|
#include <string>
|
|
|
|
#include <basic_widgets/core/type/color.hpp>
|
|
#include <basic_widgets/w/caption.hpp>
|
|
#include <basic_widgets/w/feat/mouse_handler_impl.hpp>
|
|
|
|
namespace bwidgets
|
|
{
|
|
class Button : public virtual Widget,
|
|
public virtual FontHandler,
|
|
public virtual MouseHandlerImpl
|
|
{
|
|
protected:
|
|
Caption _caption;
|
|
SDL_Rect _caption_area {};
|
|
Color _color_foreground = default_color_fg;
|
|
|
|
void _handle_font_change(const std::shared_ptr<Font>&) override;
|
|
void _handle_font_color_change(Color, Color)
|
|
override;
|
|
void _handle_geometry_change(const SDL_Rect&) override;
|
|
void _handle_renderer_change(const std::shared_ptr<Renderer>&) override;
|
|
void _handle_rendering() override;
|
|
void _on_push(bool) override;
|
|
|
|
public:
|
|
static const Color default_color_bg;
|
|
static const Color default_color_bg_hover;
|
|
static const Color default_color_fg;
|
|
|
|
std::function<Color(int, int, float)> border_gradient;
|
|
Size border_size {3, 3};
|
|
Color color_bg = default_color_bg;
|
|
Color color_bg_hover = default_color_bg_hover;
|
|
|
|
using EventHandlerImpl::handle_event;
|
|
using FocusHandlerImpl::focus;
|
|
using FocusHandlerImpl::focus_handler;
|
|
|
|
Button(Widget* parent = nullptr) noexcept;
|
|
Button(const Button&) = delete;
|
|
Button(Button&&) = delete;
|
|
~Button() override = default;
|
|
auto operator=(const Button&) = delete;
|
|
auto operator=(Button&&) = delete;
|
|
|
|
[[nodiscard]] auto size() const noexcept -> Size override;
|
|
|
|
[[nodiscard]] virtual auto text() const noexcept -> const std::string&;
|
|
virtual auto text(const std::string&) -> Button*;
|
|
};
|
|
}
|
|
|
|
#endif
|