Missed ui.h

main
noah metz 2024-11-12 21:00:32 -07:00
parent 4aeea98d45
commit 8a5de3e16e
1 changed files with 34 additions and 4 deletions

@ -145,6 +145,19 @@ typedef struct GPUContainerStruct {
VkDeviceAddress context;
} GPUContainer;
typedef void (*ui_key_callback)(void* ptr, int key, int action, int mods);
typedef void (*ui_button_callback)(void* ptr, float x, float y, int button, int action, int mods);
typedef void (*ui_scroll_callback)(void* ptr, double x, double y);
typedef void (*ui_cursor_callback)(void* ptr, float x, float y);
typedef struct UICallbacksStruct {
uint32_t element;
ui_key_callback key;
ui_button_callback button;
ui_scroll_callback scroll;
ui_cursor_callback cursor;
} UICallbacks;
typedef struct ContainerStruct {
VkBuffer container[MAX_FRAMES_IN_FLIGHT];
@ -157,6 +170,9 @@ typedef struct ContainerStruct {
uint32_t id;
uint32_t layer_count;
Layer* layers;
uint32_t callback_count;
UICallbacks* callbacks;
} Container;
typedef struct ContainerInputStruct {
@ -167,6 +183,9 @@ typedef struct ContainerInputStruct {
uint32_t layer_count;
LayerInput* layers;
uint32_t callback_count;
UICallbacks* callbacks;
} ContainerInput;
typedef struct GPUUIContextStruct {
@ -176,7 +195,7 @@ typedef struct GPUUIContextStruct {
vec2 scale;
} GPUUIContext;
typedef struct UIContext {
typedef struct UIContextStruct {
VkDeviceAddress address;
VkBuffer context;
@ -211,9 +230,11 @@ typedef struct UIContext {
FT_Library freetype;
uint32_t active_element;
UICallbacks* active_callbacks;
uint32_t active_container;
uint32_t active_captures;
uint32_t active_element;
double cursor[2];
} UIContext;
VkResult create_ui_context(
@ -267,6 +288,9 @@ VkResult update_ui_string(
UIContext* ui,
RenderContext* gpu);
Container* context_container(uint32_t container_id, UIContext* ui);
GPUDrawable* container_drawable(uint32_t element_id, Container* container);
bool ui_intersect(
double cursor[2],
RenderContext* gpu,
@ -275,4 +299,10 @@ bool ui_intersect(
uint32_t* element,
vec2 position);
void set_active_element(uint32_t container, uint32_t element, UIContext* ui);
void clear_active_element(UIContext* ui);
void anchor_offset(RenderContext* gpu, Container* container, vec2 offset);
#endif