From 0d8aeb6464103ec8e35c10c448bf08b0b9edc156 Mon Sep 17 00:00:00 2001 From: Steven Van Dorp Date: Fri, 6 Feb 2026 10:00:08 +0100 Subject: Initial Commit --- bindings/minimgui.h | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 bindings/minimgui.h (limited to 'bindings/minimgui.h') diff --git a/bindings/minimgui.h b/bindings/minimgui.h new file mode 100644 index 0000000..3d3c94c --- /dev/null +++ b/bindings/minimgui.h @@ -0,0 +1,76 @@ +#include +#include +#include + +/*=== DEF START ===*/ + +typedef struct { + float x, y; +} V2; + +typedef struct { + float x, y; + float w, h; +} Rect; + +typedef struct { + float a, r, g, b; +} Color; + +typedef void* Image; + +typedef bool(*const InitFn)(); +typedef bool(*const LoopFn)(float dt); +typedef void(*const DeinitFn)(); +void run ( + InitFn const init_fn, + LoopFn const loop_fn, + DeinitFn const deinit_fn +); + +typedef void* Context; +Context context_init(void); +void context_deinit(Context ctx); + +typedef struct { + Color color; + Image image; + bool* hover; + bool consume_hover; + bool ignore_hover_if_consumed; + bool begin_drag_if_hover_and; + bool end_drag_if; + V2** drag; +} RectangleOptions_; +bool rectangle_(Context ctx, Rect rect, RectangleOptions_ o); +/*=== DEF END ===*/ + +#if defined(__GNUC__) || defined(__clang__) +#define PURE __attribute__((pure)) +#else +#define PURE +#endif + +PURE Color color_hex(uint64_t argb) { + uint8_t* arr = (uint8_t*)&argb; + return (Color){ + .a = ((float)arr[0]) / 255.0f, + .r = ((float)arr[1]) / 255.0f, + .g = ((float)arr[2]) / 255.0f, + .b = ((float)arr[3]) / 255.0f, + }; +} + +#define rectangle(ctx, rect, ...) \ + rectangle_(ctx, rect, (RectangleOptions_){ \ + .color = color_hex(0xffffffff), \ + .image = NULL, \ + .hover = NULL, \ + .consume_hover = true, \ + .ignore_hover_if_consumed = true, \ + .begin_drag_if_hover_and = false, \ + .end_drag_if = false, \ + .drag = NULL, \ + __VA_ARGS__ \ + }) + -- cgit v1.2.3