|
CPP-TOOLBOX
|
#include <ui.hpp>
Public Member Functions | |
| UI (float z_layer, UniqueIDGenerator &abs_pos_object_id_generator) | |
| void | process_mouse_position (const glm::vec2 &mouse_pos_ndc) |
| void | process_mouse_just_clicked (const glm::vec2 &mouse_pos_ndc) |
| bool | process_mouse_just_clicked_on_clickable_textboxes (const glm::vec2 &mouse_pos_ndc) |
| bool | process_mouse_just_clicked_on_input_boxes (const glm::vec2 &mouse_pos_ndc) |
| bool | process_mouse_just_clicked_on_dropdown_options (const glm::vec2 &mouse_pos_ndc) |
| bool | process_mouse_just_clicked_on_dropdowns (const glm::vec2 &mouse_pos_ndc) |
| void | unfocus_input_box (UIInputBox &ib) |
| void | unfocus_input_box (int input_box_eid) |
| void | focus_input_box (UIInputBox &ib) |
| void | focus_input_box (int input_box_eid) |
| void | update_dropdown_option (UIDropdown &dropdown, const std::string &option_name) |
| void | process_key_press (const std::string &character_pressed) |
| void | process_confirm_action () |
| void | process_delete_action () |
| void | add_colored_rectangle (vertex_geometry::Rectangle ndc_rectangle, const glm::vec3 &normalized_rgb) |
| void | add_colored_rectangle (float x_pos_ndc, float y_pos_ndc, float width, float height, const glm::vec3 &normalized_rgb) |
| int | add_textbox (const std::string &text, vertex_geometry::Rectangle ndc_text_rectangle, const glm::vec3 &normalized_rgb) |
| int | add_textbox (const std::string &text, float center_x_pos_ndc, float center_y_pos_ndc, float width, float height, const glm::vec3 &normalized_rgb) |
| void | hide_textbox (int doid) |
| void | unhide_textbox (int doid) |
| void | modify_text_of_a_textbox (int doid, std::string new_text) |
| void | modify_colored_rectangle (int doid, vertex_geometry::Rectangle ndc_rectangle) |
| UITextBox * | get_textbox (int doid) |
| UIInputBox * | get_inputbox (int doid) |
| UIRect * | get_colored_rectangle (int doid) |
| int | add_clickable_textbox (std::function< void()> on_click, std::function< void()> on_hover, const std::string &text, float x_pos_ndc, float y_pos_ndc, float width, float height, const glm::vec3 ®ular_color, const glm::vec3 &hover_color) |
| int | add_clickable_textbox (std::function< void()> on_click, std::function< void()> on_hover, const std::string &text, vertex_geometry::Rectangle &rect, const glm::vec3 ®ular_color, const glm::vec3 &hover_color) |
| int | add_dropdown (std::function< void()> on_click, std::function< void()> on_hover, int dropdown_option_idx, const vertex_geometry::Rectangle &rect, const glm::vec3 ®ular_color, const glm::vec3 &hover_color, const std::vector< std::string > &options, std::function< void(std::string)> option_on_click, std::function< void(std::string)> option_on_hover, const glm::vec3 &option_color=glm::vec3(0), const glm::vec3 &option_hover_color=glm::vec3(0)) |
| Adds a dropdown UI element with a main button and multiple selectable options. | |
| bool | remove_clickable_textbox (int do_id) |
| bool | remove_textbox (int do_id) |
| UIClickableTextBox * | get_clickable_textbox (int do_id) |
| int | add_input_box (std::function< void(std::string)> on_confirm, const std::string &placeholder_text, const vertex_geometry::Rectangle &ndc_rect, const glm::vec3 ®ular_color, const glm::vec3 &focused_color) |
| int | add_input_box (std::function< void(std::string)> on_confirm, const std::string &placeholder_text, float x_pos_ndc, float y_pos_ndc, float width, float height, const glm::vec3 ®ular_color, const glm::vec3 &focused_color) |
| const std::vector< UIClickableTextBox > & | get_clickable_text_boxes () const |
| const std::vector< UIDropdown > & | get_dropdowns () const |
| const std::vector< UIInputBox > & | get_input_boxes () const |
| const std::vector< UITextBox > & | get_text_boxes () const |
| const std::vector< UIRect > & | get_colored_boxes () const |
Public Attributes | |
| Logger | logger {"ui"} |
| float | z_layer |
| float | background_layer |
| float | text_layer |
| float | dropdown_background_layer |
| float | dropdown_text_layer |
| UniqueIDGenerator | ui_id_generator |
| UniqueIDGenerator & | abs_pos_object_id_generator |
|
inline |
| int UI::add_clickable_textbox | ( | std::function< void()> | on_click, |
| std::function< void()> | on_hover, | ||
| const std::string & | text, | ||
| float | x_pos_ndc, | ||
| float | y_pos_ndc, | ||
| float | width, | ||
| float | height, | ||
| const glm::vec3 & | regular_color, | ||
| const glm::vec3 & | hover_color ) |
| int UI::add_clickable_textbox | ( | std::function< void()> | on_click, |
| std::function< void()> | on_hover, | ||
| const std::string & | text, | ||
| vertex_geometry::Rectangle & | rect, | ||
| const glm::vec3 & | regular_color, | ||
| const glm::vec3 & | hover_color ) |
| void UI::add_colored_rectangle | ( | float | x_pos_ndc, |
| float | y_pos_ndc, | ||
| float | width, | ||
| float | height, | ||
| const glm::vec3 & | normalized_rgb ) |
| void UI::add_colored_rectangle | ( | vertex_geometry::Rectangle | ndc_rectangle, |
| const glm::vec3 & | normalized_rgb ) |
| int UI::add_dropdown | ( | std::function< void()> | on_click, |
| std::function< void()> | on_hover, | ||
| int | dropdown_option_idx, | ||
| const vertex_geometry::Rectangle & | rect, | ||
| const glm::vec3 & | regular_color, | ||
| const glm::vec3 & | hover_color, | ||
| const std::vector< std::string > & | options, | ||
| std::function< void(std::string)> | option_on_click, | ||
| std::function< void(std::string)> | option_on_hover, | ||
| const glm::vec3 & | option_color = glm::vec3(0), | ||
| const glm::vec3 & | option_hover_color = glm::vec3(0) ) |
Adds a dropdown UI element with a main button and multiple selectable options.
This function creates a dropdown menu consisting of a main button (displaying one of the given options) and a list of selectable dropdown options. Each element in the dropdown (main button and options) is represented as rectangles with text overlays, and is assigned unique internal IDs for rendering and event handling.
| on_click | Callback triggered when the main dropdown button is clicked. |
| on_hover | Callback triggered when the main dropdown button is hovered over. |
| dropdown_option_idx | Index of the option in options to display as the initially selected option. |
| rect | The rectangle defining the size and position of the dropdown button. |
| regular_color | The background color of the main dropdown button in its normal state. |
| hover_color | The background color of the main dropdown button when hovered over. |
| options | A list of strings representing the dropdown options to display. |
| option_on_click | Callback triggered when a dropdown option is clicked. Receives the option string as input. |
| option_on_hover | Callback triggered when a dropdown option is hovered over. Receives the option string as input. |
| option_color | The background color of dropdown options in their normal state. If (0,0,0), a default darker variant of regular_color is used. |
| option_hover_color | The background color of dropdown options when hovered. If (0,0,0), a default darker variant of hover_color is used. |
options must not be empty or else it crashes, also dropdown_option_idx must be a valid index of options | int UI::add_input_box | ( | std::function< void(std::string)> | on_confirm, |
| const std::string & | placeholder_text, | ||
| const vertex_geometry::Rectangle & | ndc_rect, | ||
| const glm::vec3 & | regular_color, | ||
| const glm::vec3 & | focused_color ) |
| int UI::add_input_box | ( | std::function< void(std::string)> | on_confirm, |
| const std::string & | placeholder_text, | ||
| float | x_pos_ndc, | ||
| float | y_pos_ndc, | ||
| float | width, | ||
| float | height, | ||
| const glm::vec3 & | regular_color, | ||
| const glm::vec3 & | focused_color ) |
| int UI::add_textbox | ( | const std::string & | text, |
| float | center_x_pos_ndc, | ||
| float | center_y_pos_ndc, | ||
| float | width, | ||
| float | height, | ||
| const glm::vec3 & | normalized_rgb ) |
| int UI::add_textbox | ( | const std::string & | text, |
| vertex_geometry::Rectangle | ndc_text_rectangle, | ||
| const glm::vec3 & | normalized_rgb ) |
| void UI::focus_input_box | ( | int | input_box_eid | ) |
| void UI::focus_input_box | ( | UIInputBox & | ib | ) |
| const std::vector< UIClickableTextBox > & UI::get_clickable_text_boxes | ( | ) | const |
| UIClickableTextBox * UI::get_clickable_textbox | ( | int | do_id | ) |
| const std::vector< UIRect > & UI::get_colored_boxes | ( | ) | const |
| UIRect * UI::get_colored_rectangle | ( | int | doid | ) |
| const std::vector< UIDropdown > & UI::get_dropdowns | ( | ) | const |
| const std::vector< UIInputBox > & UI::get_input_boxes | ( | ) | const |
| UIInputBox * UI::get_inputbox | ( | int | doid | ) |
| const std::vector< UITextBox > & UI::get_text_boxes | ( | ) | const |
| UITextBox * UI::get_textbox | ( | int | doid | ) |
| void UI::hide_textbox | ( | int | doid | ) |
| void UI::modify_colored_rectangle | ( | int | doid, |
| vertex_geometry::Rectangle | ndc_rectangle ) |
| void UI::modify_text_of_a_textbox | ( | int | doid, |
| std::string | new_text ) |
| void UI::process_confirm_action | ( | ) |
| void UI::process_delete_action | ( | ) |
| void UI::process_key_press | ( | const std::string & | character_pressed | ) |
| void UI::process_mouse_just_clicked | ( | const glm::vec2 & | mouse_pos_ndc | ) |
| bool UI::process_mouse_just_clicked_on_clickable_textboxes | ( | const glm::vec2 & | mouse_pos_ndc | ) |
| bool UI::process_mouse_just_clicked_on_dropdown_options | ( | const glm::vec2 & | mouse_pos_ndc | ) |
| bool UI::process_mouse_just_clicked_on_dropdowns | ( | const glm::vec2 & | mouse_pos_ndc | ) |
| bool UI::process_mouse_just_clicked_on_input_boxes | ( | const glm::vec2 & | mouse_pos_ndc | ) |
| void UI::process_mouse_position | ( | const glm::vec2 & | mouse_pos_ndc | ) |
| bool UI::remove_clickable_textbox | ( | int | do_id | ) |
| bool UI::remove_textbox | ( | int | do_id | ) |
| void UI::unfocus_input_box | ( | int | input_box_eid | ) |
| void UI::unfocus_input_box | ( | UIInputBox & | ib | ) |
| void UI::unhide_textbox | ( | int | doid | ) |
| void UI::update_dropdown_option | ( | UIDropdown & | dropdown, |
| const std::string & | option_name ) |
| UniqueIDGenerator& UI::abs_pos_object_id_generator |
| float UI::background_layer |
| float UI::dropdown_background_layer |
| float UI::dropdown_text_layer |
| Logger UI::logger {"ui"} |
| float UI::text_layer |
| UniqueIDGenerator UI::ui_id_generator |
| float UI::z_layer |