From 14def875d68eda57741a07bec29ec49b00626b75 Mon Sep 17 00:00:00 2001 From: Alessandro Mauri Date: Mon, 5 Dec 2022 23:18:51 +0100 Subject: [PATCH] stuff before rewrite --- ugui.h | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/ugui.h b/ugui.h index bdc6661..bcb2353 100644 --- a/ugui.h +++ b/ugui.h @@ -1,8 +1,11 @@ #ifndef _UGUI_H #define _UGUI_H -/* Point Coordinate */ +// Macros +#define UG_STACK(T) struct { T *items; int idx; int size; } + +/* Point Coordinate */ // coordinate type, or how it is measured enum { UG_CTYPE_PX = 0x0, @@ -84,6 +87,11 @@ typedef struct { struct ug_vec2 { int x, y; }; + +typedef struct { + int x, y; + int w, h; +} ug_rect_t; //---// /* Mouse button mask */ @@ -195,6 +203,17 @@ typedef struct { } ug_element_t; //---// +/* Layout region */ +typedef struct { + ug_rect_t rect; + // FIXME: is this needed? + unsigned int id; + // indentation level, used in trees + // FIXME: is this needed? + unsigned int indent; +} ug_layout_region_t; +//---//s + /* Global context */ // one context per phisical window // a phisical window can be anything, but here it basically represents the true @@ -206,9 +225,7 @@ typedef struct { float scale, dpi, ppm; // the user pushes the things that he wants to draw onto the element stack, // which contains all the primitives needed to draw the wanted element - unsigned char *e_stack; - unsigned int e_size; - unsigned int e_idx; + UG_STACK(unsigned char) e_stack; // the element which has focus unsigned int focus_id; // the element that we are hovering @@ -373,4 +390,8 @@ int ui_layout_set_px(ug_ctx_t *ctx); // ui elements int ug_slider(ug_ctx_t *ctx, float *stat, float min, float max); + +// un-define macros that we don't want the user to access +#undef UG_STACK + #endif