-
-
Couldn't load subscription status.
- Fork 6
Button
-
Fundamentals
-
Examples
-
Methods
The button widget works fundamentally simply, you have a text, and the alignment of text. Each button has it is own optional ekg::cpu::event callback event task, where you can add one lambda function.
The button widget contains two string sets set_text and set_tag, set_tag is reserved for user purposes, while set_text is the visible text of the widget button.
For creating a simple button with no callback event.
auto p_button = ekg::button("cat", ekg::dock::fill | ekg::next);The first parameter is the visible text of a button. The second parameter is the docking alignment in the frame widget.
To create a callback button, with tasks.
p_button->set_callback(new ekg::cpu::event("cat", nullptr, [](void *p_callback) {
ekg::log() << "Cat!";
}));This callback event is not deleted after execution, because it is batched, which means that all clicks will execute this task.
Set the font size of button text, ekg::font::small ekg::font::normal ekg::font::big.
ekg::ui::button *set_font_size(ekg::font font);Get the font size of button text, ekg::font::small ekg::font::normal ekg::font::big.
ekg::font get_font_size();Set dock place, fill next none right bottom.
ekg::ui::button *set_place(uint16_t dock);Set dimension width in pixels.
ekg::ui::button *set_width(float w);Get dimension width in pixels.
float get_width();Set dimension height in font size scale (multiplied by).
ekg::ui::button *set_scaled_height(int32_t h);Get dimension height in font size scale (multiplied by).
int32_t get_scaled_height();Get dimension height in pixels.
float get_height();Set callback event task.
ekg::ui::button *set_callback(ekg::cpu::event *p_callback);Get callback event task.
ekg::cpu::event *get_callback();Set display text.
ekg::ui::button *set_text(std::string_view text);Get display text.
std::string_view get_text();Set button state pressed/callback.
ekg::ui::button *set_value(bool state);Get button state.
bool get_value();Set text alignment dock, center left right top bottom.
ekg::ui::button *set_text_align(uint16_t dock);Get text alignment dock.
uint16_t get_text_align();Set tag for reserved purposes.
ekg::ui::abstract *set_tag(std::string_view tag);Get the tag for reserved purposes.
std::string_view get_tag();Add a child to the widget.
ekg::ui::abstract *add_child(int32_t id);Get the widget child id list.
std::vector<int32_t> &get_child_id_list();Remove a child widget from the mother widget.
ekg::ui::abstract *remove_child(int32_t id);Set the widget ID.
ekg::ui::abstract *set_id(int32_t id);Get the widget ID.
int32_t get_id();Set parent (mother) widget ID.
ekg::ui::abstract *set_parent_id(int32_t parent_id);Get parent (mother) widget ID.
int32_t get_parent_id();Set the alive state of the widget.
ekg::ui::abstract *set_alive(bool is_alive);Get the alive state.
bool is_alive();Destroy the widget.
void destroy();Set the state of the widget, visible invisible.
ekg::ui::abstract *set_state(const ekg::state &_state);Get the state of the widget, visible invisible.
ekg::state get_state();Set the widget type.
ekg::ui::abstract *set_type(const ekg::type &_type);Get the widget type.
ekg::type get_type();Get the place dock, fill next none right bottom.
uint16_t get_place_dock();Get the sync flags reference.
uint16_t &get_sync();Reset the UI data front-end with the widget back-end.
void reset();Access to absolute widget back-end rectangle.
ekg::rect &widget();Get the UI data front-end rectangle.
ekg::rect &ui();Set scaled height layout in font size (multiplied by).
ekg::ui::abstract *set_scaled_height_layout(int32_t scaled_size);Check if the widget has a parent (mother widget).
bool has_parent();Check if the widget has children.
bool has_children();