Untitled
Loading...
Searching...
No Matches
ui.c File Reference
#include "utilities/types.h"
#include "utilities/utilities.h"
#include <math.h>
#include <omp.h>
#include "ui/ui.h"
#include "ui/fonts.h"

Go to the source code of this file.

Functions

int find_empty_element_slot (UIMenu *m)
int find_empty_container_slot (UIMenu *m)
int create_ui_element (int menu_id)
 Creates a UIElement on a given UIMenu.
void delete_ui_container (UIElement *el)
 Deletes a UIContainer, removing all references to it from existing TextBoxes and UIElements on the same UIMenu.
void reassign_elements_to_container (UIElement *el)
 Assigns all children based on current UIContainer children.
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.
void delete_ui_element (int menu, int id)
 Deletes a UIElement, removing it from its possible parent UIContainer and deleting its own possible UIContainer.
UIContainer * create_ui_container (UIElement *el, int menu_id)
 Creates a UIContainer from a given UIElement a given UIMenu.
void scroll_container (UIContainer *c, UISlider *slider, UIMenu *m)
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.
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.
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 align_text_box_label (UIElement *el)
 Aligns a TextBox inside of a UILabel based on its Justify.
bool point_inside_ui_element (UIElement *el, vec2 pos)
vec2 screenspace_to_ui_element_local (UIElement *el, float scale_x, float scale_y, vec2 pos)
bool is_hovering_ui_element (UIElement *el, vec2 pos)
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.
void process_ui_event (UICallback *callback)
void compute_slider_bounds (UIElement *element)
 Computes the minimum and maximum in UI space for a UISlider.
void create_label (UIElement *element, int box, int parent_dropdown, Justify justify)
void create_slider (UIElement *element, vec2 dir, float len)
 Creates a UISlider from a UIElement.
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.

Variables

int TEXT_WIDTH = 1280
int TEXT_HEIGHT = 720
Vector MENUS = {0}
 All UIMenus.

Function Documentation

◆ find_empty_element_slot()

int find_empty_element_slot ( UIMenu * m)

◆ find_empty_container_slot()

int find_empty_container_slot ( UIMenu * m)

◆ scroll_container()

◆ point_inside_ui_element()

◆ screenspace_to_ui_element_local()

vec2 screenspace_to_ui_element_local ( UIElement * el,
float scale_x,
float scale_y,
vec2 pos )

◆ is_hovering_ui_element()

◆ process_ui_event()

◆ create_label()

void create_label ( UIElement * element,
int box,
int parent_dropdown,
Justify justify )

Definition at line 673 of file ui.c.

References UIElement::as, and create_label().

Referenced by create_label().