Kohi Game Engine
standard_ui_system.h
Go to the documentation of this file.
1 
13 #pragma once
14 
15 #include <defines.h>
16 #include <identifiers/identifier.h>
17 #include <input_types.h>
19 #include <math/geometry.h>
20 #include <math/math_types.h>
22 #include <systems/xform_system.h>
23 
24 struct frame_data;
25 struct standard_ui_state;
26 struct renderer_system_state;
27 
29 typedef struct standard_ui_system_config {
32 
33 typedef struct standard_ui_renderable {
40 
41 typedef struct standard_ui_render_data {
43  // darray
46 
47 typedef struct sui_mouse_event {
49  i16 x;
50  i16 y;
52 
57 
58 typedef struct sui_keyboard_event {
62 
63 typedef struct sui_clip_mask {
69 
70 typedef struct sui_control {
73  char* name;
74  // TODO: Convert to flags.
80 
82  // darray
84 
87 
88  void* user_data;
90 
91  void (*destroy)(struct standard_ui_state* state, struct sui_control* self);
92  b8 (*load)(struct standard_ui_state* state, struct sui_control* self);
93  void (*unload)(struct standard_ui_state* state, struct sui_control* self);
94 
95  b8 (*update)(struct standard_ui_state* state, struct sui_control* self, struct frame_data* p_frame_data);
96  void (*render_prepare)(struct standard_ui_state* state, struct sui_control* self, const struct frame_data* p_frame_data);
97  b8 (*render)(struct standard_ui_state* state, struct sui_control* self, struct frame_data* p_frame_data, standard_ui_render_data* reneder_data);
98 
105  void (*on_click)(struct standard_ui_state* state, struct sui_control* self, struct sui_mouse_event event);
106  void (*on_mouse_down)(struct standard_ui_state* state, struct sui_control* self, struct sui_mouse_event event);
107  void (*on_mouse_up)(struct standard_ui_state* state, struct sui_control* self, struct sui_mouse_event event);
108  void (*on_mouse_over)(struct standard_ui_state* state, struct sui_control* self, struct sui_mouse_event event);
109  void (*on_mouse_out)(struct standard_ui_state* state, struct sui_control* self, struct sui_mouse_event event);
110  void (*on_mouse_move)(struct standard_ui_state* state, struct sui_control* self, struct sui_mouse_event event);
111 
112  void (*internal_click)(struct standard_ui_state* state, struct sui_control* self, struct sui_mouse_event event);
113  void (*internal_mouse_over)(struct standard_ui_state* state, struct sui_control* self, struct sui_mouse_event event);
114  void (*internal_mouse_out)(struct standard_ui_state* state, struct sui_control* self, struct sui_mouse_event event);
115  void (*internal_mouse_down)(struct standard_ui_state* state, struct sui_control* self, struct sui_mouse_event event);
116  void (*internal_mouse_up)(struct standard_ui_state* state, struct sui_control* self, struct sui_mouse_event event);
117  void (*internal_mouse_move)(struct standard_ui_state* state, struct sui_control* self, struct sui_mouse_event event);
118 
119  void (*on_key)(struct standard_ui_state* state, struct sui_control* self, struct sui_keyboard_event event);
120 
122 
123 typedef struct standard_ui_state {
124  struct renderer_system_state* renderer;
125  struct font_system_state* font_system;
127  // Array of pointers to controls, the system does not own these. The application does.
134  // texture_map ui_atlas;
135 
137 
139 
141 
153 
160 
162 
164 
166 
168 
170 
172 
174 
176 
177 // ---------------------------
178 // Base control
179 // ---------------------------
180 KAPI b8 sui_base_control_create(standard_ui_state* state, const char* name, struct sui_control* out_control);
182 
185 
186 KAPI b8 sui_base_control_update(standard_ui_state* state, struct sui_control* self, struct frame_data* p_frame_data);
187 KAPI b8 sui_base_control_render(standard_ui_state* state, struct sui_control* self, struct frame_data* p_frame_data, standard_ui_render_data* render_data);
188 
195 KAPI void sui_control_position_set(standard_ui_state* state, struct sui_control* self, vec3 position);
196 
This file contains global type definitions which are used throughout the entire engine and applicatio...
#define KAPI
Import/export qualifier.
Definition: defines.h:205
unsigned int u32
Unsigned 32-bit integer.
Definition: defines.h:25
_Bool b8
8-bit boolean type
Definition: defines.h:58
signed short i16
Signed 16-bit integer.
Definition: defines.h:36
unsigned long long u64
Unsigned 64-bit integer.
Definition: defines.h:28
Contains a system for creating numeric identifiers.
keys
Represents available keyboard keys.
Definition: input_types.h:21
mouse_buttons
Represents available mouse buttons.
Definition: input_types.h:8
u16 ktexture
Represents a texture to be used for rendering purposes, stored on the GPU (VRAM)
Definition: kresource_types.h:45
Contains various math types required for the engine.
KAPI b8 sui_base_control_create(standard_ui_state *state, const char *name, struct sui_control *out_control)
KAPI b8 standard_ui_system_control_remove_child(standard_ui_state *state, sui_control *parent, sui_control *child)
KAPI void sui_base_control_destroy(standard_ui_state *state, struct sui_control *self)
KAPI vec3 sui_control_position_get(standard_ui_state *state, struct sui_control *self)
Gets the position on the given control.
struct sui_clip_mask sui_clip_mask
KAPI b8 sui_base_control_update(standard_ui_state *state, struct sui_control *self, struct frame_data *p_frame_data)
KAPI b8 sui_base_control_load(standard_ui_state *state, struct sui_control *self)
KAPI void standard_ui_system_render_prepare_frame(standard_ui_state *state, const struct frame_data *p_frame_data)
KAPI b8 standard_ui_system_control_add_child(standard_ui_state *state, sui_control *parent, sui_control *child)
struct sui_mouse_event sui_mouse_event
struct sui_keyboard_event sui_keyboard_event
KAPI b8 standard_ui_system_initialize(u64 *memory_requirement, standard_ui_state *state, standard_ui_system_config *config)
Initializes the standard UI system. Should be called twice; once to get the memory requirement (passi...
struct sui_control sui_control
KAPI void sui_base_control_unload(standard_ui_state *state, struct sui_control *self)
struct standard_ui_renderable standard_ui_renderable
KAPI b8 standard_ui_system_update_active(standard_ui_state *state, sui_control *control)
struct standard_ui_system_config standard_ui_system_config
The standard UI system configuration.
KAPI void standard_ui_system_focus_control(standard_ui_state *state, sui_control *control)
KAPI b8 sui_base_control_render(standard_ui_state *state, struct sui_control *self, struct frame_data *p_frame_data, standard_ui_render_data *render_data)
KAPI b8 standard_ui_system_update(standard_ui_state *state, struct frame_data *p_frame_data)
KAPI void sui_control_position_set(standard_ui_state *state, struct sui_control *self, vec3 position)
Sets the position on the given control.
sui_keyboard_event_type
Definition: standard_ui_system.h:53
@ SUI_KEYBOARD_EVENT_TYPE_RELEASE
Definition: standard_ui_system.h:55
@ SUI_KEYBOARD_EVENT_TYPE_PRESS
Definition: standard_ui_system.h:54
struct standard_ui_render_data standard_ui_render_data
KAPI b8 standard_ui_system_render(standard_ui_state *state, sui_control *root, struct frame_data *p_frame_data, standard_ui_render_data *render_data)
KAPI void standard_ui_system_shutdown(standard_ui_state *state)
Shuts down the standard UI system.
KAPI b8 standard_ui_system_register_control(standard_ui_state *state, sui_control *control)
struct standard_ui_state standard_ui_state
Engine-level current frame-specific data.
Definition: frame_data.h:11
Definition: renderer_types.h:35
Definition: identifier.h:20
Represents geometry to be used for various purposes (rendering objects in the world,...
Definition: geometry.h:38
A handle is a unique identifier used a system in the engine to avoid using raw pointers where possibl...
Definition: khandle.h:25
Definition: standard_ui_system.h:41
standard_ui_renderable * renderables
Definition: standard_ui_system.h:44
ktexture ui_atlas
Definition: standard_ui_system.h:42
Definition: standard_ui_system.h:33
u32 * group_id
Definition: standard_ui_system.h:34
u32 * per_draw_id
Definition: standard_ui_system.h:35
ktexture atlas_override
Definition: standard_ui_system.h:36
geometry_render_data * clip_mask_render_data
Definition: standard_ui_system.h:38
geometry_render_data render_data
Definition: standard_ui_system.h:37
Definition: standard_ui_system.h:123
u32 inactive_control_count
Definition: standard_ui_system.h:131
struct font_system_state * font_system
Definition: standard_ui_system.h:125
struct renderer_system_state * renderer
Definition: standard_ui_system.h:124
sui_control root
Definition: standard_ui_system.h:133
standard_ui_system_config config
Definition: standard_ui_system.h:126
u32 active_control_count
Definition: standard_ui_system.h:129
u64 focused_id
Definition: standard_ui_system.h:138
sui_control ** inactive_controls
Definition: standard_ui_system.h:132
sui_control ** active_controls
Definition: standard_ui_system.h:130
u32 total_control_count
Definition: standard_ui_system.h:128
ktexture atlas_texture
Definition: standard_ui_system.h:136
The standard UI system configuration.
Definition: standard_ui_system.h:29
u64 max_control_count
Definition: standard_ui_system.h:30
Definition: standard_ui_system.h:63
khandle clip_xform
Definition: standard_ui_system.h:65
geometry_render_data render_data
Definition: standard_ui_system.h:67
u32 reference_id
Definition: standard_ui_system.h:64
kgeometry clip_geometry
Definition: standard_ui_system.h:66
Definition: standard_ui_system.h:70
void(* on_mouse_up)(struct standard_ui_state *state, struct sui_control *self, struct sui_mouse_event event)
Definition: standard_ui_system.h:107
void(* on_mouse_over)(struct standard_ui_state *state, struct sui_control *self, struct sui_mouse_event event)
Definition: standard_ui_system.h:108
void * user_data
Definition: standard_ui_system.h:88
u64 user_data_size
Definition: standard_ui_system.h:89
void(* on_mouse_down)(struct standard_ui_state *state, struct sui_control *self, struct sui_mouse_event event)
Definition: standard_ui_system.h:106
void(* on_click)(struct standard_ui_state *state, struct sui_control *self, struct sui_mouse_event event)
Definition: standard_ui_system.h:105
b8(* update)(struct standard_ui_state *state, struct sui_control *self, struct frame_data *p_frame_data)
Definition: standard_ui_system.h:95
b8 is_active
Definition: standard_ui_system.h:75
void(* internal_mouse_up)(struct standard_ui_state *state, struct sui_control *self, struct sui_mouse_event event)
Definition: standard_ui_system.h:116
void(* internal_click)(struct standard_ui_state *state, struct sui_control *self, struct sui_mouse_event event)
Definition: standard_ui_system.h:112
b8(* load)(struct standard_ui_state *state, struct sui_control *self)
Definition: standard_ui_system.h:92
void(* internal_mouse_over)(struct standard_ui_state *state, struct sui_control *self, struct sui_mouse_event event)
Definition: standard_ui_system.h:113
char * name
Definition: standard_ui_system.h:73
identifier id
Definition: standard_ui_system.h:71
b8 is_pressed
Definition: standard_ui_system.h:78
khandle xform
Definition: standard_ui_system.h:72
void(* render_prepare)(struct standard_ui_state *state, struct sui_control *self, const struct frame_data *p_frame_data)
Definition: standard_ui_system.h:96
void(* on_mouse_out)(struct standard_ui_state *state, struct sui_control *self, struct sui_mouse_event event)
Definition: standard_ui_system.h:109
b8 is_hovered
Definition: standard_ui_system.h:77
struct sui_control ** children
Definition: standard_ui_system.h:83
void(* destroy)(struct standard_ui_state *state, struct sui_control *self)
Definition: standard_ui_system.h:91
void(* internal_mouse_out)(struct standard_ui_state *state, struct sui_control *self, struct sui_mouse_event event)
Definition: standard_ui_system.h:114
void(* on_key)(struct standard_ui_state *state, struct sui_control *self, struct sui_keyboard_event event)
Definition: standard_ui_system.h:119
void(* unload)(struct standard_ui_state *state, struct sui_control *self)
Definition: standard_ui_system.h:93
b8 is_visible
Definition: standard_ui_system.h:76
void * internal_data
Definition: standard_ui_system.h:85
void(* on_mouse_move)(struct standard_ui_state *state, struct sui_control *self, struct sui_mouse_event event)
Definition: standard_ui_system.h:110
void(* internal_mouse_down)(struct standard_ui_state *state, struct sui_control *self, struct sui_mouse_event event)
Definition: standard_ui_system.h:115
struct sui_control * parent
Definition: standard_ui_system.h:81
void(* internal_mouse_move)(struct standard_ui_state *state, struct sui_control *self, struct sui_mouse_event event)
Definition: standard_ui_system.h:117
b8(* render)(struct standard_ui_state *state, struct sui_control *self, struct frame_data *p_frame_data, standard_ui_render_data *reneder_data)
Definition: standard_ui_system.h:97
rect_2d bounds
Definition: standard_ui_system.h:79
u64 internal_data_size
Definition: standard_ui_system.h:86
Definition: standard_ui_system.h:58
keys key
Definition: standard_ui_system.h:59
sui_keyboard_event_type type
Definition: standard_ui_system.h:60
Definition: standard_ui_system.h:47
i16 y
Definition: standard_ui_system.h:50
i16 x
Definition: standard_ui_system.h:49
mouse_buttons mouse_button
Definition: standard_ui_system.h:48
A 3-element vector.
Definition: math_types.h:49
A 4-element vector.
Definition: math_types.h:89