move from imgui to CLAY

This commit is contained in:
2026-02-25 15:20:47 -05:00
parent 6656b6d0b2
commit 12dae774e4
41 changed files with 6835 additions and 77320 deletions

65
src/ui/ui_core.h Normal file
View File

@@ -0,0 +1,65 @@
#pragma once
// ui_core.h - Thin wrapper around Clay (https://github.com/nicbarker/clay)
// Provides Clay initialization, per-frame lifecycle, and text measurement bridging.
#include "base/base_inc.h"
#include "clay.h"
////////////////////////////////
// Text measurement callback (provided by renderer)
// This is our app-level callback; we adapt it to Clay's signature internally.
typedef Vec2F32 (*UI_MeasureTextFn)(const char *text, S32 length, F32 font_size, void *user_data);
////////////////////////////////
// UI Context
struct UI_Context {
Clay_Context *clay_ctx;
void *clay_memory;
// Text measurement
UI_MeasureTextFn measure_text_fn;
void *measure_text_user_data;
};
////////////////////////////////
// Lifecycle
UI_Context *ui_create(F32 viewport_w, F32 viewport_h);
void ui_destroy(UI_Context *ctx);
// Call each frame before declaring layout
void ui_begin_frame(UI_Context *ctx, F32 viewport_w, F32 viewport_h,
Vec2F32 mouse_pos, B32 mouse_down,
Vec2F32 scroll_delta, F32 dt);
// Call after layout is declared; returns Clay's render command array
Clay_RenderCommandArray ui_end_frame(UI_Context *ctx);
////////////////////////////////
// Text measurement
void ui_set_measure_text_fn(UI_Context *ctx, UI_MeasureTextFn fn, void *user_data);
////////////////////////////////
// Theme colors (convenience - 0-255 Clay_Color)
struct UI_Theme {
Clay_Color bg_dark;
Clay_Color bg_medium;
Clay_Color bg_light;
Clay_Color bg_lighter;
Clay_Color border;
Clay_Color text;
Clay_Color text_dim;
Clay_Color accent;
Clay_Color accent_hover;
Clay_Color title_bar;
Clay_Color scrollbar_bg;
Clay_Color scrollbar_grab;
};
extern UI_Theme g_theme;
void ui_init_theme();