2021-08-06 14:22:56 +02:00
|
|
|
#ifndef BWIDGETS_BUTTON_HPP
|
|
|
|
#define BWIDGETS_BUTTON_HPP
|
2021-07-18 18:26:12 +02:00
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
2021-08-06 14:22:56 +02:00
|
|
|
#include <basic_widgets/core/type/color.hpp>
|
2021-08-19 15:00:44 +02:00
|
|
|
#include <basic_widgets/w/base/widget.hpp>
|
|
|
|
#include <basic_widgets/w/feat/font_handler.hpp>
|
2021-08-17 11:40:03 +02:00
|
|
|
#include <basic_widgets/w/feat/mouse_handler.hpp>
|
2021-07-18 18:26:12 +02:00
|
|
|
|
2021-08-06 14:22:56 +02:00
|
|
|
namespace bwidgets
|
2021-07-18 18:26:12 +02:00
|
|
|
{
|
2021-08-17 11:40:03 +02:00
|
|
|
class Button : public virtual Widget,
|
2021-08-15 20:04:53 +02:00
|
|
|
public virtual FontHandler,
|
2021-08-17 11:40:03 +02:00
|
|
|
public virtual MouseHandler
|
2021-07-18 18:26:12 +02:00
|
|
|
{
|
2021-07-29 16:06:03 +02:00
|
|
|
public:
|
2021-08-17 11:40:03 +02:00
|
|
|
static inline const Color default_color_bg {150, 150, 150, SDL_ALPHA_OPAQUE};
|
|
|
|
static inline const Color default_color_bg_hover {175, 175, 175,
|
|
|
|
SDL_ALPHA_OPAQUE};
|
|
|
|
static inline const Color default_color_fg {0, 0, 0, SDL_ALPHA_OPAQUE};
|
2021-08-06 14:22:56 +02:00
|
|
|
|
2021-08-14 10:20:00 +02:00
|
|
|
std::function<Color(int, int, float)> border_gradient;
|
2021-08-14 16:37:02 +02:00
|
|
|
Size border_size {3, 3};
|
|
|
|
Color color_bg = default_color_bg;
|
|
|
|
Color color_bg_hover = default_color_bg_hover;
|
2021-07-29 16:06:03 +02:00
|
|
|
|
2021-08-17 11:40:03 +02:00
|
|
|
using Widget::Widget;
|
2021-08-06 14:22:56 +02:00
|
|
|
|
2021-08-23 23:50:14 +02:00
|
|
|
// Get button text (label).
|
2021-08-21 20:59:39 +02:00
|
|
|
[[nodiscard]] virtual auto text() const noexcept -> std::string_view = 0;
|
2021-08-23 23:50:14 +02:00
|
|
|
// Set button text
|
2021-08-21 20:59:39 +02:00
|
|
|
virtual void text(std::string) = 0;
|
2021-07-18 18:26:12 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|