|
Untitled
|
The structures, functions, constants, and variables within the UI and text rendering system. More...
Data Structures | |
| struct | Glyph |
| A single Glyph in a Font. More... | |
| struct | Font |
| A Font and its Glyphs used for rendering TextBoxes. More... | |
| struct | TextBoxGPU |
| The GPU-side representation of a TextBox. More... | |
| struct | UIElementGPU |
| The GPU-side representation of a UIElement. More... | |
| struct | UIContainer |
| UIContainer that contains both TextBoxes and UIElements and can mask and scroll them. More... | |
| struct | TextBox |
| A structure holding a Font ID and text to be rendered and transformed with its properties. More... | |
| struct | UIValue |
| A value that is manipulated in some way when a UIElement receives an event. More... | |
| union | UIValue::[union].min_val |
| The minimum value data can become. More... | |
| union | UIValue::[union].max_val |
| The maximum value data can become. More... | |
| union | UIValue::[union].inc_val |
| How much data should be incremented. More... | |
| struct | UICallback |
| Describes function pointers for UIElements that determine behavior on events. More... | |
| struct | UILabel |
| UIElement UILabels that contain a TextBox reference. More... | |
| struct | UIElement |
| UIElements that are contained within a UIMenu that may receive events, be contained within UIContainers, or be UIContainers themselves. More... | |
| union | UIElement::[union].as |
| struct | UIMenu |
| The top-most UI structure that contains UIElements, TextBoxes, and UIContainers. More... | |
| struct | UISlider |
| UIElement sliders that interpolate between two points on a line. More... | |
| struct | UIDropdown |
| Unfinished structure for a dropdown that spawns UIElements and TextBoxes when opened. More... | |
Functions | |
| int | move_element_to_menu (int element_idx, int current_menu, int target_menu) |
| Moves a UIElement from its current UIMenu to another UIMenu. | |
| int | move_text_box_to_menu (int tb_idx, int current_menu, int target_menu) |
| Moves a TextBox from its current UIMenu to another UIMenu. | |
| int | get_text_box_from_coords (vec2 pos, int *menu_idx) |
| Finds a TextBox based on a screen position. | |
| int | get_ui_element_from_coords (vec2 pos, int *menu_idx) |
| Finds a UIElement based on a screen position. | |
| int | create_ui_element (int menu_id) |
| Creates a UIElement on a given UIMenu. | |
| UIContainer * | create_ui_container (UIElement *el, int menu_id) |
| Creates a UIContainer from a given UIElement a given UIMenu. | |
| void | delete_ui_element (int menu, int id) |
| Deletes a UIElement, removing it from its possible parent UIContainer and deleting its own possible UIContainer. | |
| void | delete_ui_container (UIElement *el) |
| Deletes a UIContainer, removing all references to it from existing TextBoxes and UIElements on the same UIMenu. | |
| void | handle_ui_event (SDL_Event event, int mouse_x, int mouse_y) |
| Handles an incoming UI event. | |
| void | update_ui_state (float mouse_x, float mouse_y) |
| Handles the persistent UI state from previous frames. | |
| void | compute_slider_bounds (UIElement *element) |
| Computes the minimum and maximum in UI space for a UISlider. | |
| void | create_slider (UIElement *element, vec2 dir, float len) |
| Creates a UISlider from a UIElement. | |
| void | remove_element_from_container (UIContainer *c, UIElement *el) |
| Removes a UIElement from a UIContainer. | |
| void | remove_text_box_from_container (UIContainer *c, TextBox *tb) |
| Removes a TextBox from a UIContainer. | |
| int | find_ui_element_in_menu (UIMenu *m, const char *id) |
| Finds a UIElement inside of a UIMenu via name. | |
| int | find_text_box_in_menu (UIMenu *m, const char *id) |
| Finds a TextBox inside of a UIMenu via name. | |
| int | find_container_in_menu (UIMenu *m, const char *id) |
| Finds a UIContainer inside of a UIMenu via name. | |
| void | align_text_box_label (UIElement *el) |
| Aligns a TextBox inside of a UILabel based on its Justify. | |
| void | assign_element_to_container (UIElement *el, UIContainer *c) |
| Assigns a UIElement to be parented to a UIContainer. | |
| void | assign_text_box_to_container (TextBox *tb, UIContainer *c) |
| Assigns a TextBox to be parented to a UIContainer. | |
| void | reassign_elements_to_container (UIElement *el) |
| Assigns all children based on current UIContainer children. | |
| void | UI_INIT () |
| Simply frees the MENUS buffer and reinitializes the Vector. | |
| UIMenu * | create_menu () |
| Creates a new UIMenu, expanding the MENUS Vector and sets all arrays to free. | |
| bool | container_is_valid (int container, int menu) |
| Checks if a UIContainer and UIMenu ID pairing is valid. | |
| vec2 | screenspace_to_ui (vec2 pos) |
| Transfers a position to local UI space by multiplying it by a ratio of the two resolutions. | |
Variables | |
| Vector | MENUS |
| All UIMenus. | |
| const char * | JUSTIFY_NAMES [] |
| The names of Justify for the Editor UI. | |
| const char * | UI_INTERACTABLE_NAMES [] |
| UIElement interactable names for the union that describe unique functions. | |
FBO Size | |
The size of the rendering FBO, used to convert from screenspace to local UI space. | |
| int | TEXT_WIDTH |
| int | TEXT_HEIGHT |
Default Structures | |
Safe defaults for each UI structure. | |
| UICallback | DEFAULT_CALLBACK |
| UIElement | DEFAULT_UI_ELEMENT |
| UISlider | DEFAULT_SLIDER |
| UILabel | DEFAULT_LABEL |
| UIContainer | DEFAULT_UI_CONTAINER |
| TextBox | DEFAULT_TEXT_BOX |
UI Constants | |
Sizes of UI arrays and UI Scale.
| |
| #define | MAX_UI_ELEMENTS 1024 |
| #define | MAX_UI_CONTAINERS 1024 |
| #define | UI_SCALE_WIDTH 2560 |
| #define | UI_SCALE_HEIGHT 1920 |
| #define | MAX_TEXT_BOXES 1024 |
| #define | MAX_TEXT_BOX_CHARACTERS 256 |
| #define | MAX_UI_CHILDREN 1024 |
| #define | MAX_GLYPHS 256 |
The structures, functions, constants, and variables within the UI and text rendering system.
| struct Glyph |
| Data Fields | ||
|---|---|---|
| int | id | This ID == '<char>' when looking up which Glyph to use (ascii). |
| float | u0 | \(x/w_t\). |
| float | v0 | \(y/h_t\). |
| float | u1 | \((x+w_c)/w_t\). |
| float | v1 | \((y+h_c)/h_t\). |
| int | width | \(w_c\). |
| int | height | \(h_c\). |
| int | xoffset | The x offset before the character. |
| int | yoffset | The y offset before the character. |
| int | xadvance | How much the x advances when it is typed. |
| struct Font |
| Data Fields | ||
|---|---|---|
| int | id | The ID of the Font in FONTS. |
| size_t | texture | The Image ID. |
| Glyph * | glyphs | Glyphs for each character. |
| size_t | glyph_count | The amount of Glyphs. |
| int | tex_w | The texture dimensions. |
| int | tex_h | The texture dimensions. |
| int | highest_y | Used to determine the amount of space to cursor shift for newlines. |
| int | highest_dist | Used to determine the amount of space to cursor shift for newlines. |
| char | name[256] | The name of the file path. |
| struct TextBoxGPU |
| struct UIElementGPU |
The GPU-side representation of a UIElement.
| Data Fields | ||
|---|---|---|
| uint32_t | visible | |
| uint32_t | hovered | |
| uint32_t | shadow | |
| float | shadow_dist | |
| vec2 | pos | |
| vec2 | size | |
| vec2 | shadow_dir | |
| uint32_t | state | |
| uint32_t | type | |
| vec4 | color | |
| vec4 | fill | |
| vec4 | padding | |
| vec2 | translation | |
| vec2 | scale | |
| float | radius | |
| uint32_t | masked | |
| uint32_t | container_id | |
| uint32_t | pad0 | |
| mat4 | model | |
| struct UIContainer |
UIContainer that contains both TextBoxes and UIElements and can mask and scroll them.
| Data Fields | ||
|---|---|---|
| int | uID | The ID inside of UIMenu.containers. |
| bool | free | If this UIContainer is empty or can be replaced. |
| vec2 | scroll_offset | The current offset from \((0,0)\). |
| vec2 | delta_scroll_offset | The difference between this frame's scroll offset and the current. |
| vec2 | scroll_dir | The direction this container moves in when scrolled. |
| bool | wrap | If UIElements and TextBoxes wrap around the container (unused). |
| vec4 | padding | The padding before UIElements and TextBoxes are wrapped or masked. |
| bool | mask | If the UIElements and TextBoxes contained should not be rendered if outside. |
| int | children[1024] | The IDs for UIElements contained. |
| size_t | child_count | The amount of UIElements contained. |
| int | box_children[1024] | The IDs of TextBoxes contained. |
| size_t | box_count | The amount of TextBoxes contained. |
| int | element |
Which UIElement owns this UIContainer.
|
| int | scrollbar |
The scrollbar UISlider UIElement.
|
| char | id[256] |
The name of this UIContainer.
|
| struct TextBox |
A structure holding a Font ID and text to be rendered and transformed with its properties.
| Data Fields | ||
|---|---|---|
| uint | visible | |
| uint | hovered | |
| uint | shadow | |
| float | shadow_dist | How far the drop shadow is. |
| uint | container_id | |
| uint | mask | |
| vec2 | shadow_dir | Which direction to offset the drop shadow in. |
| uint | state | |
| uint | pad0 | |
| uint | pad1 | |
| uint | pad2 | |
| vec4 | color | The color of the text. |
| vec4 | fill |
The fill of the text. (unused) |
| mat4 | model | |
| bool | hovered | Currently this indicates if this TextBox is hovered since it does not receive events. |
| bool | shadow | If there is a drop shadow. |
| bool | visible | If the TextBox is visible. |
| bool | free | If this TextBox is empty and can be overwritten. |
| int | font_id | The Font ID inside of FONTS. |
| uint32_t | uID | The ID inside of UIMenu.text_boxes. |
| Justify | justify | How the text is centered in relation to \((0,0)\) and/or its UILabel. |
| char * | text |
The characters to render.
|
| int | text_cap | The amount of characters allocated. |
| float | text_size | The size to render the Font. |
| float | w | The width of the box after pseudo-rendering in determine_text_box_dimensions(). |
| float | h | The height of the box after pseudo-rendering in determine_text_box_dimensions(). |
| vec2 | translation | Where to place the center of the TextBox on the GPU. |
| float | angle | The angle to transform this box to. |
| vec2 | scale | The scale for this box on the GPU. |
| vec2 | center | The center in relation to \((0,0)\). |
| vec2 | start | The start of the text in relation to \((0,0)\). |
| uint32_t | layer | Rendering sort key (lower drawn first). |
| UIState | state | Only currently indicates if this TextBox is selected in the editor UI. |
| int | menu | The UIMenu that this box is within. |
| int | parent_container |
The UIContainer that contains this TextBox.
|
| char | id[256] |
The name of this TextBox.
|
| struct UIValue |
A value that is manipulated in some way when a UIElement receives an event.
| Data Fields | ||
|---|---|---|
| UIValueType | type | The type of value that is inside of data. |
| UIValueBehavior | behavior | The control upon reaching min or max. |
| union | min_val | |
| union | max_val | |
| union | inc_val | |
| void * | data | The data, which may be simply a pointer that is passed into a function instead of manipulated directly. |
| union UIValue::[union].min_val |
| union UIValue::[union].max_val |
| union UIValue::[union].inc_val |
| struct UICallback |
Describes function pointers for UIElements that determine behavior on events.
| Data Fields | ||
|---|---|---|
| bool | bind_self | If the UIElement should bind itself to this callback. |
| bool | one_shot | If this event only occurs on initial event. |
| UIValue | val | The value to change. |
| void(*) | action_fn(void *) | The function called on action (if there is one). |
| void(*) | unaction_fn(void *) | The function called when action is stopped (if there is one). |
| void *(*) | bind_fn(void *, void *) | The function that binds data to data on initialization. |
| void * | data | The bind data. |
| void(*) | free_data(void *) | The function that frees the bound data. |
| char | id[256] | The name of this UICallback inside of its registry. |
| struct UILabel |
| struct UIElement |
UIElements that are contained within a UIMenu that may receive events, be contained within UIContainers, or be UIContainers themselves.
| Data Fields | ||
|---|---|---|
| uint | visible | |
| uint | hovered | |
| uint | shadow | |
| float | shadow_dist | Unused. |
| vec2 | pos | |
| vec2 | size |
Size of the SDF.
|
| vec2 | shadow_dir | Unused. |
| uint | state | |
| uint | type | |
| vec4 | color | Color of the shape. |
| vec4 | fill | Unused. |
| vec4 | padding | |
| vec2 | translation | X and Y coords where Y+ is down. |
| vec2 | scale | Scale. |
| float | radius | The radius of the circle OR the radius of a rectangle's corners. |
| uint | masked | |
| uint | container_id | |
| uint | pad0 | |
| mat4 | model | |
| bool | shadow | Unused - If the UIElement has a shadow. |
| bool | visible | If the UIElement is visible. |
| bool | free | If the UIElement can be replaced or is empty. |
| UIElementType | type | The type of SDF function to render. |
| uint32_t | uID | The ID inside of UIMenu. |
| vec2 | base_pos |
Where the element was before it was scrolled or manipulated somehow. So that we have an anchor point. |
| float | angle | Angle of rotation. |
| vec2 | center |
The center. Should be at \((0,0)\). |
| uint32_t | layer |
The layer of the UIElement. Lower = bottom-most and drawn first. Higher elements consume events. |
| UICallback | action_callback | The event to occur on action (press or hold) or unaction. |
| UICallback | hover_callback | The event to occur on hover or unhover. |
| bool | already_hovered | To avoid triggering hover events multiple times if not necessary. |
| UIState | state | The current state of the element. |
| int | menu |
The UIMenu this UIElement is inside.
|
| int | container |
The UIContainer this UIElement may control.
|
| int | parent_container |
The UIContainer that contains this UIElement.
|
| char | id[256] |
The name of this UIElement.
|
| UIInteractableType | interactable | The special interactable type this UIElement may be. |
| union | as | |
| union UIElement::[union].as |
| Data Fields | ||
|---|---|---|
| UIDropdown | dropdown | |
| UILabel | label | |
| UISlider | slider | |
| struct UIMenu |
The top-most UI structure that contains UIElements, TextBoxes, and UIContainers.
| Data Fields | ||
|---|---|---|
| uint32_t | uID | The index inside of MENUS. |
| char | id[256] | The unique name of this menu. |
| UIElement | elements[1024] | The UIElements. |
| TextBox | text_boxes[1024] | The TextBoxes. |
| UIContainer | containers[1024] | The UIContainers. |
| struct UISlider |
UIElement sliders that interpolate between two points on a line.
AKA scrollbars. UI_INTERACTABLE_SLIDER
| Data Fields | ||
|---|---|---|
| vec2 | dir | The direction it slides in. |
| vec2 | min | The min in pixel space. |
| vec2 | max | The max in pixel space. |
| float | len | The length in pixel space. |
| float | val |
The current value between min and max val.
|
| float | prev_val | The previous value. |
| float | min_val | The minimum value of the slider. |
| float | max_val | The maximum value of the slider. |
| float | scroll_scale | How much the scroll is supposed to influence the UIContainer. |
| bool | dragging | If we are dragging this UISlider. |
| vec2 | drag_mouse_start | The mouse position on initial drag. |
| vec2 | drag_center_start | The translation of the UISlider on initial drag. |
| float | drag_start_scalar |
The scalar value the slider starts at based on initial drag position.
|
| float | max_proj |
The maximum projected scalar value.
|
| int | container |
The UIContainer that this UISlider scrolls.
|
| struct UIDropdown |
| #define MAX_UI_ELEMENTS 1024 |
Definition at line 33 of file ui.h.
Referenced by create_menu(), delete_ui_container(), find_empty_element_slot(), find_ui_element_in_menu(), get_ui_element_from_coords(), GPU_upload_ui_elements(), handle_ui_event(), handle_ui_selection_event(), init(), load_ui(), render(), render_editor_menu(), render_ui_menu(), save_ui(), and update_ui_state().
| #define MAX_UI_CONTAINERS 1024 |
Definition at line 34 of file ui.h.
Referenced by container_is_valid(), create_menu(), find_container_in_menu(), find_empty_container_slot(), GPU_upload_ui_elements(), load_ui(), render_text_menu(), render_ui_menu(), and save_ui().
| #define UI_SCALE_WIDTH 2560 |
Definition at line 35 of file ui.h.
Referenced by align_text_box_label(), get_text_box_from_coords(), get_ui_element_from_coords(), GPU_upload_singular_element(), GPU_upload_singular_text_box(), is_hovering_ui_element(), screenspace_to_ui(), and update_ui_state().
| #define UI_SCALE_HEIGHT 1920 |
Definition at line 36 of file ui.h.
Referenced by align_text_box_label(), get_text_box_from_coords(), get_ui_element_from_coords(), GPU_upload_singular_element(), GPU_upload_singular_text_box(), is_hovering_ui_element(), screenspace_to_ui(), and update_ui_state().
| #define MAX_TEXT_BOXES 1024 |
Definition at line 37 of file ui.h.
Referenced by add_all_text_boxes_to_draw_buffer(), create_menu(), delete_ui_container(), find_empty_text_box_slot(), find_text_box_in_menu(), get_text_box_from_coords(), init(), load_ui(), render_editor_menu(), and save_ui().
| enum Justify |
| enum UIState |
| enum UIInteractableType |
| enum UIElementType |
Types of SDF shapes that are handled on the GPU.
| Enumerator | |
|---|---|
| UIELEMENT_RECT | |
| UIELEMENT_CIRCLE | |
| UIELEMENT_TYPE_MAX | |
| enum UIValueType |
Types of values that may be controlled by a UI event function pointer.
| Enumerator | |
|---|---|
| UIVAL_NONE | |
| UIVAL_BOOL | |
| UIVAL_INT | |
| UIVAL_FLOAT | |
| UIVAL_CALLBACK | |
| enum UIValueBehavior |
Types of ways that UIValues may be controlled when they reach a minimum or maximum value.
| Enumerator | |
|---|---|
| UIVALBEHAVIOR_NONE | |
| UIVALBEHAVIOR_WRAP | |
| UIVALBEHAVIOR_CLAMP | |
| int move_element_to_menu | ( | int | element_idx, |
| int | current_menu, | ||
| int | target_menu ) |
Moves a UIElement from its current UIMenu to another UIMenu.
| element_idx | The UIElement index into the current UIMenu. |
| current_menu | The current UIMenu. |
| target_menu | The target UIMenu. |
Definition at line 299 of file ui.c.
References CAST_VEC, UIElement::container, delete_ui_container(), delete_ui_element(), UIMenu::elements, find_empty_element_slot(), UIElement::menu, MENUS, move_element_to_menu(), UIElement::parent_container, and UIElement::uID.
Referenced by move_element_to_menu(), and render_ui_menu().
| int move_text_box_to_menu | ( | int | tb_idx, |
| int | current_menu, | ||
| int | target_menu ) |
Moves a TextBox from its current UIMenu to another UIMenu.
| tb_idx | The TextBox index inside of the current UIMenu. |
| current_menu | The current UIMenu. |
| target_menu | The target UIMenu. |
Definition at line 329 of file ui.c.
References CAST_VEC, delete_text_box(), find_empty_text_box_slot(), TextBox::menu, MENUS, move_text_box_to_menu(), TextBox::text, UIMenu::text_boxes, TextBox::text_cap, and TextBox::uID.
Referenced by move_text_box_to_menu(), and render_text_menu().
| int get_text_box_from_coords | ( | vec2 | pos, |
| int * | menu_idx ) |
Finds a TextBox based on a screen position.
Transfers the screenspace pos to UI space.
| pos | The screenspace position. |
| menu_idx | The out pointer to a UIMenu index. |
Definition at line 515 of file ui.c.
References CAST_VEC, Vector::count, TextBox::free, get_text_box_from_coords(), TextBox::h, TextBox::layer, MAX_TEXT_BOXES, MENUS, TextBox::scale, screenspace_to_ui(), TextBox::start, UIMenu::text_boxes, TEXT_HEIGHT, TEXT_WIDTH, TextBox::translation, UI_SCALE_HEIGHT, UI_SCALE_WIDTH, vec2_add(), vec2_inside_bounds(), TextBox::visible, TextBox::w, vec2::x, and vec2::y.
Referenced by get_text_box_from_coords(), and handle_ui_selection_event().
| int get_ui_element_from_coords | ( | vec2 | pos, |
| int * | menu_idx ) |
Finds a UIElement based on a screen position.
Transfers the screenspace pos to UI space.
| pos | The screenspace position. |
| menu_idx | The out pointer to a UIMenu index. |
Definition at line 570 of file ui.c.
References CAST_VEC, Vector::count, UIMenu::elements, UIElement::free, get_ui_element_from_coords(), UIElement::layer, MAX_UI_ELEMENTS, MENUS, point_inside_ui_element(), screenspace_to_ui_element_local(), TEXT_HEIGHT, TEXT_WIDTH, UI_SCALE_HEIGHT, UI_SCALE_WIDTH, and UIElement::visible.
Referenced by get_ui_element_from_coords(), handle_ui_event(), and handle_ui_selection_event().
| int create_ui_element | ( | int | menu_id | ) |
Creates a UIElement on a given UIMenu.
| menu_id | The target UIMenu. |
Definition at line 39 of file ui.c.
References UIElement::action_callback, CAST_VEC, create_ui_element(), DEFAULT_CALLBACK, DEFAULT_UI_ELEMENT, UIMenu::elements, find_empty_element_slot(), UIElement::hover_callback, UIElement::menu, MENUS, and UIElement::uID.
Referenced by create_ui_element(), and render_ui_menu().
| UIContainer * create_ui_container | ( | UIElement * | el, |
| int | menu_id ) |
Creates a UIContainer from a given UIElement a given UIMenu.
Definition at line 197 of file ui.c.
References CAST_VEC, UIElement::container, UIMenu::containers, create_ui_container(), DEFAULT_UI_CONTAINER, UIContainer::element, find_empty_container_slot(), MENUS, UIContainer::uID, and UIElement::uID.
Referenced by create_ui_container(), and render_ui_menu().
| void delete_ui_element | ( | int | menu, |
| int | id ) |
Deletes a UIElement, removing it from its possible parent UIContainer and deleting its own possible UIContainer.
Definition at line 176 of file ui.c.
References CAST_VEC, UIElement::container, UIMenu::containers, delete_ui_container(), delete_ui_element(), UIMenu::elements, UIElement::free, MENUS, UIElement::parent_container, and remove_element_from_container().
Referenced by delete_ui_element(), execute_ui_element_undo(), move_element_to_menu(), and render_ui_menu().
| void delete_ui_container | ( | UIElement * | el | ) |
Deletes a UIContainer, removing all references to it from existing TextBoxes and UIElements on the same UIMenu.
| el | The pointer to the UIElement that owns the UIContainer. |
Definition at line 68 of file ui.c.
References CAST_VEC, UIElement::container, UIMenu::containers, DEFAULT_UI_CONTAINER, delete_ui_container(), UIMenu::elements, TextBox::free, UIContainer::free, UIElement::free, MAX_TEXT_BOXES, MAX_UI_ELEMENTS, UIElement::menu, MENUS, TextBox::parent_container, UIElement::parent_container, UIMenu::text_boxes, and UIContainer::uID.
Referenced by delete_ui_container(), delete_ui_element(), execute_ui_element_undo(), move_element_to_menu(), and render_ui_menu().
| void handle_ui_event | ( | SDL_Event | event, |
| int | mouse_x, | ||
| int | mouse_y ) |
Handles an incoming UI event.
| event | The SDL event to process. |
| mouse_x | Current mouse x. |
| mouse_y | Current mouse y. |
Definition at line 696 of file ui.c.
References UIElement::action_callback, UIElement::already_hovered, CAST_VEC, Vector::count, UIMenu::elements, UIElement::free, get_ui_element_from_coords(), handle_ui_event(), UIElement::hover_callback, is_hovering_ui_element(), MAX_UI_ELEMENTS, MENUS, UICallback::one_shot, process_ui_event(), UIElement::state, UIElement::uID, UISTATE_HOVERED, UISTATE_NONE, UISTATE_PRESSED, and UIElement::visible.
Referenced by handle_ui_event(), and process_sdl_event().
| void update_ui_state | ( | float | mouse_x, |
| float | mouse_y ) |
Handles the persistent UI state from previous frames.
| mouse_x | Current mouse x. |
| mouse_y | Current mouse y. |
Definition at line 816 of file ui.c.
References UIElement::action_callback, UIElement::as, CAST_VEC, UISlider::container, UIMenu::containers, Vector::count, UISlider::dir, UISlider::drag_center_start, UISlider::drag_mouse_start, UISlider::drag_start_scalar, UISlider::dragging, UIMenu::elements, UIElement::free, UIElement::hover_callback, UIElement::interactable, UISlider::max_proj, MAX_UI_ELEMENTS, MENUS, UISlider::min, UISlider::prev_val, process_ui_event(), scroll_container(), UIElement::state, TEXT_HEIGHT, TEXT_WIDTH, UIElement::translation, UI_INTERACTABLE_SLIDER, UI_SCALE_HEIGHT, UI_SCALE_WIDTH, UISTATE_HOVERED, UISTATE_NONE, UISTATE_PRESSED, update_ui_state(), UISlider::val, vec2_add(), vec2_dot(), vec2_scale(), and vec2_sub().
Referenced by main(), and update_ui_state().
| void compute_slider_bounds | ( | UIElement * | element | ) |
Computes the minimum and maximum in UI space for a UISlider.
Definition at line 663 of file ui.c.
References UIElement::as, compute_slider_bounds(), UISlider::dir, UISlider::len, UISlider::max, UISlider::max_proj, UISlider::min, UIElement::translation, vec2_add(), vec2_length(), vec2_scale(), and vec2_sub().
Referenced by compute_slider_bounds(), create_slider(), and render_ui_menu().
Creates a UISlider from a UIElement.
Definition at line 682 of file ui.c.
References UIElement::as, compute_slider_bounds(), UIElement::container, create_slider(), UIElement::interactable, and UI_INTERACTABLE_SLIDER.
Referenced by create_slider().
| void remove_element_from_container | ( | UIContainer * | c, |
| UIElement * | el ) |
Removes a UIElement from a UIContainer.
Shifts the rest of the children array forward.
| c | The UIContainer. |
| el | The UIElement. |
Definition at line 139 of file ui.c.
References UIContainer::child_count, UIContainer::children, UIElement::parent_container, remove_element_from_container(), REMOVE_FROM_ARR, and UIElement::uID.
Referenced by delete_ui_element(), execute_ui_element_undo(), remove_element_from_container(), and render_ui_menu().
| void remove_text_box_from_container | ( | UIContainer * | c, |
| TextBox * | tb ) |
Removes a TextBox from a UIContainer.
Shifts the rest of the children array forward.
Definition at line 157 of file ui.c.
References UIContainer::box_children, UIContainer::box_count, REMOVE_FROM_ARR, remove_text_box_from_container(), and TextBox::uID.
Referenced by delete_text_box(), execute_text_box_undo(), remove_text_box_from_container(), and render_text_menu().
| int find_ui_element_in_menu | ( | UIMenu * | m, |
| const char * | id ) |
Finds a UIElement inside of a UIMenu via name.
| m | The UIMenu to search. |
| id | The name string to compare. |
Definition at line 242 of file ui.c.
References UIMenu::elements, find_ui_element_in_menu(), UIElement::free, UIElement::id, MAX_UI_ELEMENTS, and UIElement::uID.
Referenced by find_ui_element_in_menu().
| int find_text_box_in_menu | ( | UIMenu * | m, |
| const char * | id ) |
Finds a TextBox inside of a UIMenu via name.
| m | The UIMenu to search. |
| id | The name string to compare. |
Definition at line 261 of file ui.c.
References find_text_box_in_menu(), TextBox::free, TextBox::id, MAX_TEXT_BOXES, UIMenu::text_boxes, and TextBox::uID.
Referenced by find_text_box_in_menu(), and render_ui_menu().
| int find_container_in_menu | ( | UIMenu * | m, |
| const char * | id ) |
Finds a UIContainer inside of a UIMenu via name.
| m | The UIMenu to search. |
| id | The name string to compare. |
Definition at line 280 of file ui.c.
References UIMenu::containers, find_container_in_menu(), UIContainer::free, UIContainer::id, MAX_UI_CONTAINERS, and UIContainer::uID.
Referenced by find_container_in_menu().
| void align_text_box_label | ( | UIElement * | el | ) |
Aligns a TextBox inside of a UILabel based on its Justify.
Definition at line 410 of file ui.c.
References UILabel::align, align_text_box_label(), UIElement::as, UILabel::box, CAST_VEC, TextBox::h, JUSTIFY_BOTTOM_CENTER, JUSTIFY_BOTTOM_LEFT, JUSTIFY_BOTTOM_RIGHT, JUSTIFY_CENTER, JUSTIFY_LEFT, JUSTIFY_RIGHT, JUSTIFY_TOP_CENTER, JUSTIFY_TOP_LEFT, JUSTIFY_TOP_RIGHT, UIElement::menu, MENUS, UIElement::scale, UIMenu::text_boxes, TEXT_HEIGHT, TEXT_WIDTH, TextBox::translation, UIElement::translation, UI_SCALE_HEIGHT, UI_SCALE_WIDTH, TextBox::w, vec2::x, and vec2::y.
Referenced by align_text_box_label(), execute_ui_element_undo(), and render_ui_menu().
| void assign_element_to_container | ( | UIElement * | el, |
| UIContainer * | c ) |
Assigns a UIElement to be parented to a UIContainer.
| el | The UIElement to assign. |
| c | The target parent UIContainer. |
Definition at line 367 of file ui.c.
References assign_element_to_container(), UIContainer::child_count, UIContainer::children, UIElement::parent_container, UIContainer::uID, and UIElement::uID.
Referenced by assign_element_to_container(), execute_ui_element_undo(), and render_ui_menu().
| void assign_text_box_to_container | ( | TextBox * | tb, |
| UIContainer * | c ) |
Assigns a TextBox to be parented to a UIContainer.
| el | The TextBox to assign. |
| c | The target parent UIContainer. |
Definition at line 388 of file ui.c.
References assign_text_box_to_container(), UIContainer::box_children, UIContainer::box_count, TextBox::parent_container, TextBox::uID, and UIContainer::uID.
Referenced by assign_text_box_to_container(), execute_text_box_undo(), and render_text_menu().
| void reassign_elements_to_container | ( | UIElement * | el | ) |
Assigns all children based on current UIContainer children.
| el | The UIElement that is the UIContainer. |
Definition at line 114 of file ui.c.
References UIContainer::box_children, UIContainer::box_count, CAST_VEC, UIContainer::child_count, UIContainer::children, UIElement::container, UIMenu::containers, UIMenu::elements, UIElement::menu, MENUS, TextBox::parent_container, UIElement::parent_container, reassign_elements_to_container(), UIMenu::text_boxes, and UIContainer::uID.
Referenced by execute_ui_element_undo(), and reassign_elements_to_container().
|
inline |
Simply frees the MENUS buffer and reinitializes the Vector.
Definition at line 864 of file ui.h.
References Vector::buffer, init_vector(), MENUS, and UI_INIT().
|
inline |
Creates a new UIMenu, expanding the MENUS Vector and sets all arrays to free.
Definition at line 875 of file ui.h.
References UIMenu::containers, Vector::count, create_menu(), UIMenu::elements, TextBox::free, UIContainer::free, UIElement::free, UIMenu::id, MAX_TEXT_BOXES, MAX_UI_CONTAINERS, MAX_UI_ELEMENTS, MENUS, UIMenu::text_boxes, UIMenu::uID, and vector_expand().
Referenced by create_menu(), and create_performance_overlay().
|
inline |
Checks if a UIContainer and UIMenu ID pairing is valid.
| container | The UIContainer ID. |
| menu | The UIMenu ID. |
Definition at line 905 of file ui.h.
References CAST_VEC, container_is_valid(), UIMenu::containers, Vector::count, UIContainer::free, MAX_UI_CONTAINERS, MENUS, and UIContainer::uID.
Referenced by container_is_valid(), GPU_upload_singular_element(), GPU_upload_ui_elements(), render_text_menu(), render_ui_menu(), and upload_parent_container().
Transfers a position to local UI space by multiplying it by a ratio of the two resolutions.
| pos | The position to transfer. |
Definition at line 934 of file ui.h.
References screenspace_to_ui(), TEXT_HEIGHT, TEXT_WIDTH, UI_SCALE_HEIGHT, UI_SCALE_WIDTH, vec2::x, and vec2::y.
Referenced by get_text_box_from_coords(), handle_ui_selection_event(), and screenspace_to_ui().
|
extern |
Definition at line 11 of file ui.c.
Referenced by align_text_box_label(), get_text_box_from_coords(), get_ui_element_from_coords(), GPU_upload_singular_element(), GPU_upload_singular_text_box(), init(), is_hovering_ui_element(), screenspace_to_ui(), and update_ui_state().
|
extern |
Definition at line 12 of file ui.c.
Referenced by align_text_box_label(), get_text_box_from_coords(), get_ui_element_from_coords(), GPU_upload_singular_element(), GPU_upload_singular_text_box(), init(), is_hovering_ui_element(), screenspace_to_ui(), and update_ui_state().
|
extern |
All UIMenus.
Definition at line 13 of file ui.c.
Referenced by add_all_text_boxes_to_draw_buffer(), align_text_box_label(), container_is_valid(), create_menu(), create_text_box(), create_ui_container(), create_ui_element(), delete_text_box(), delete_ui_container(), delete_ui_element(), execute_text_box_undo(), execute_ui_container_undo(), execute_ui_element_undo(), execute_ui_menu_undo(), get_text_box_from_coords(), get_ui_element_from_coords(), GPU_upload_ui_elements(), handle_ui_event(), handle_ui_selection_event(), load_ui(), move_element_to_menu(), move_text_box_to_menu(), reassign_elements_to_container(), render_editor_menu(), render_text_menu(), render_ui_menu(), save_ui(), toggle_performance_overlay(), UI_INIT(), update_performance_overlay(), and update_ui_state().
| const char* JUSTIFY_NAMES[] |
The names of Justify for the Editor UI.
Definition at line 170 of file ui.h.
Referenced by render_ui_menu().
| const char* UI_INTERACTABLE_NAMES[] |
UIElement interactable names for the union that describe unique functions.
Definition at line 211 of file ui.h.
Referenced by render_ui_menu().
| UICallback DEFAULT_CALLBACK |
Definition at line 579 of file ui.h.
Referenced by create_ui_element().
| UIElement DEFAULT_UI_ELEMENT |
Definition at line 593 of file ui.h.
Referenced by create_ui_element().
| UISlider DEFAULT_SLIDER |
Definition at line 620 of file ui.h.
Referenced by render_ui_menu().
| UILabel DEFAULT_LABEL |
Definition at line 632 of file ui.h.
Referenced by render_ui_menu().
| UIContainer DEFAULT_UI_CONTAINER |
Definition at line 642 of file ui.h.
Referenced by create_ui_container(), and delete_ui_container().
| TextBox DEFAULT_TEXT_BOX |
Definition at line 661 of file ui.h.
Referenced by create_performance_overlay(), create_text_box(), and delete_text_box().