inital nodes and props

This commit is contained in:
chrisbell committed 2026-11-02 19:42:48 -06:00
1 parent 98f798ad45
commit 5dad34f2e3
12 files changed
+1107 -9

No files matched your search

+94 -1
View File
@@ -39,7 +39,10 @@ enum {
RG_ERR_GENERIC = -1,
RG_ERR_NO_MEMORY = -2,
RG_ERR_STATE = -3,
RG_ERR_LUA = -4
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 };
@@ -72,6 +75,96 @@ 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