/* regolith.h Regolith public API Author: Chris Bell Last edited by: Chris Bell Last edit date: 11-02-2026 */ #ifndef REGOLITH_H #define REGOLITH_H #include #include #if defined(_WIN32) && defined(RG_SHARED) #ifdef RG_BUILD #define RG_API __declspec(dllexport) #else #define RG_API __declspec(dllimport) #endif #elif defined(__GNUC__) #define RG_API __attribute__((visibility("default"))) #else #define RG_API #endif #ifdef __cplusplus extern "C" { #endif #define RG_VERSION_STRING "0.0.1" /* TODO: Add documentation comments */ enum { RG_OK = 0, RG_ERR_GENERIC = -1, RG_ERR_NO_MEMORY = -2, RG_ERR_STATE = -3, RG_ERR_LUA = -4, RG_ERR_HANDLE = -5, RG_ERR_TYPE = -6, RG_ERR_PROP = -7 }; enum { RG_LOG_TRACE = 0, RG_LOG_DEBUG, RG_LOG_INFO, RG_LOG_WARN, RG_LOG_ERROR }; typedef struct rg_context rg_context; typedef struct rg_allocator { void *(*alloc)(size_t size, void *user); void *(*realloc)(void *ptr, size_t old_size, size_t new_size, void *user); void (*free)(void *ptr, size_t size, void *user); void *user; } rg_allocator; typedef void (*rg_log_fn)(int32_t level, const char *message, void *user); typedef struct rg_config { uint32_t struct_size; rg_allocator allocator; rg_log_fn log; void *log_user; int32_t log_level; int32_t viewport_w; int32_t viewport_h; float display_scale; } rg_config; RG_API const char *rg_version(void); RG_API void rg_config_init(rg_config *config); RG_API rg_context *rg_create(const rg_config *config); RG_API void rg_destroy(rg_context *ctx); RG_API const char *rg_last_error(const rg_context *ctx); typedef uint64_t rg_node; #define RG_NODE_NONE ((rg_node)0) enum { RG_NODE_ROOT = 0, RG_NODE_BOX, RG_NODE_HBOX, RG_NODE_VBOX, RG_NODE_PANEL, RG_NODE_LABEL, RG_NODE_BUTTON, RG_NODE_TYPE_COUNT }; enum { RG_VAL_NONE = 0, RG_VAL_BOOL, RG_VAL_INT, RG_VAL_FLOAT, RG_VAL_ENUM, RG_VAL_COLOR, RG_VAL_SIZE, RG_VAL_VEC4, RG_VAL_STRING }; enum { RG_SIZE_FIT = 0, RG_SIZE_GROW, RG_SIZE_FIXED, RG_SIZE_PERCENT }; enum { RG_DIR_ROW = 0, RG_DIR_COLUMN }; enum { RG_ALIGN_START = 0, RG_ALIGN_CENTER, RG_ALIGN_END }; enum { RG_PROP_DIRECTION = 0, RG_PROP_WIDTH, RG_PROP_HEIGHT, RG_PROP_PADDING, RG_PROP_GAP, RG_PROP_ALIGN_X, RG_PROP_ALIGN_Y, RG_PROP_BACKGROUND, RG_PROP_BORDER_COLOR, RG_PROP_BORDER_WIDTH, RG_PROP_CORNER_RADIUS, RG_PROP_OPACITY, RG_PROP_VISIBLE, RG_PROP_TEXT, RG_PROP_FONT, RG_PROP_FONT_SIZE, RG_PROP_COLOR, RG_PROP_COUNT }; typedef struct rg_value { int32_t type; int32_t i; float f[4]; const char *s; } rg_value; RG_API int32_t rg_type_find(const char *name); RG_API const char *rg_type_name(int32_t type); RG_API rg_node rg_root(const rg_context *ctx); RG_API rg_node rg_node_create(rg_context *ctx, int32_t type); RG_API void rg_node_destroy(rg_context *ctx, rg_node node); RG_API int rg_node_valid(const rg_context *ctx, rg_node node); RG_API int32_t rg_node_type(const rg_context *ctx, rg_node node); RG_API int rg_node_append(rg_context *ctx, rg_node parent, rg_node child); RG_API int rg_node_insert_before(rg_context *ctx, rg_node parent, rg_node child, rg_node ref); RG_API int rg_node_detach(rg_context *ctx, rg_node node); RG_API rg_node rg_node_parent(const rg_context *ctx, rg_node node); RG_API rg_node rg_node_first_child(const rg_context *ctx, rg_node node); RG_API rg_node rg_node_next_sibling(const rg_context *ctx, rg_node node); RG_API int32_t rg_prop_find(const char *name); RG_API const char *rg_prop_name(int32_t prop); RG_API int32_t rg_prop_type(int32_t prop); RG_API int rg_set(rg_context *ctx, rg_node node, int32_t prop, const rg_value *value); RG_API int rg_get(rg_context *ctx, rg_node node, int32_t prop, rg_value *out); RG_API int rg_unset(rg_context *ctx, rg_node node, int32_t prop); RG_API int rg_set_int(rg_context *ctx, rg_node node, int32_t prop, int32_t v); RG_API int rg_set_float(rg_context *ctx, rg_node node, int32_t prop, float v); RG_API int rg_set_string(rg_context *ctx, rg_node node, int32_t prop, const char *v); RG_API int rg_set_color(rg_context *ctx, rg_node node, int32_t prop, float r, float g, float b, float a); #ifdef __cplusplus } #endif #endif