14#include <egt/buttongroup.h>
15#include <egt/detail/meta.h>
16#include <egt/geometry.h>
18#include <egt/imageholder.h>
19#include <egt/textwidget.h>
77 explicit Button(
const std::string& text = {},
78 const AlignFlags& text_align = default_text_align())
noexcept;
86 const AlignFlags& text_align = default_text_align()) noexcept;
94 const AlignFlags& text_align = default_text_align())
noexcept;
103 const std::string& text,
105 const AlignFlags& text_align = default_text_align()) noexcept;
129 void text(const std::
string& text) override;
145 return on_event(handler, {EventId::pointer_click});
151 using Widget::checked;
160 using TextWidget::min_size_hint;
168 void set_parent(
Widget* parent) override;
172 static
Size default_button_size_value;
174 static
void register_handler();
175 static
void unregister_handler();
215 using Button::Button;
221 Button::handle(event);
225 case EventId::pointer_click:
242 explicit Switch(
const std::string& text = {},
243 const Rect& rect = {})
noexcept;
270 using Button::min_size_hint;
283 void text(
const std::string& text)
override;
292 if (detail::change_if_diff<>(m_show_label, value))
299 EGT_NODISCARD
bool show_label()
const {
return m_show_label; }
308 if (detail::change_if_diff<>(m_switch_align,
align))
360 bool m_show_label{
true};
367 mutable std::unique_ptr<Image> m_normal_switch;
368 mutable std::unique_ptr<Image> m_checked_switch;
376namespace experimental
Alignment flags.
Definition widgetflags.h:379
A Frame is a Widget that has children widgets.
Definition frame.h:45
Definition imageholder.h:35
Raster image resource used for drawing or displaying.
Definition image.h:39
std::function< void(Event &event)> EventCallback
Event handler callback function.
Definition object.h:55
uint64_t RegisterHandle
Handle type.
Definition object.h:61
Drawing interface for 2D graphics.
Definition painter.h:45
Abstract base serializer class.
Definition serialize.h:34
std::list< std::tuple< std::string, std::string, Serializer::Attributes > > Properties
Definition serialize.h:47
Signal class used for defining a signal and dispatching events.
Definition signal.h:30
EGT_NODISCARD Image * switch_image(bool checked) const
Get the image, if any, used to draw the widget's switch, based on the value of its 'checked' flag.
EGT_NODISCARD Size min_size_hint() const override
Get a minimum size hint for the Widget.
Switch(Serializer::Properties &props, bool is_derived) noexcept
void switch_image(const Image &image, bool checked)
Add an image to draw the widget's switch, based on the value of its 'checked' flag.
void draw(Painter &painter, const Rect &rect) override
Draw the widget.
EGT_NODISCARD bool show_label() const
Get the show label state.
Definition button.h:299
Switch(Serializer::Properties &props) noexcept
Definition button.h:248
void serialize(Serializer &serializer) const override
Serialize the widget to the specified serializer.
static void default_draw(const Switch &widget, Painter &painter, const Rect &rect)
Default draw method for the Switch.
void switch_align(const AlignFlags &align)
Set the alignement of the switch relative to the text.
Definition button.h:306
virtual void draw_switch(Painter &painter, const Rect &handle) const
Switch(const std::string &text={}, const Rect &rect={}) noexcept
void show_label(bool value)
Enable/disable showing the label text.
Definition button.h:290
void reset_switch_image(bool checked)
Remove the image, if any, used to draw the widget's switch, based on the value of its 'checked' flag.
void handle(Event &event) override
Handle an event.
EGT_NODISCARD AlignFlags switch_align() const
Get the switch alignment.
Definition button.h:318
void text(const std::string &text) override
Set the text.
A widget with text and text related properties.
Definition textwidget.h:33
ImageHolder< Button, Palette::ColorId::button_bg, Palette::ColorId::border, Palette::ColorId::button_text > ImageButton
Button that also contains an Image.
Definition button.h:207
T & align(T &widget, const AlignFlags &a)
Helper to set alignment of a widget.
Definition widgetflags.h:624
EGT framework namespace.
Definition animation.h:24
A single event that has information about the event and state for the event.
Definition event.h:255
EGT_NODISCARD const EventId & id() const noexcept
Get the id of the event.
Definition event.h:284