From 24294d45a9f183a438c0e232034b22e557ede488 Mon Sep 17 00:00:00 2001 From: Edgaru089 Date: Tue, 23 Apr 2024 16:34:01 +0800 Subject: [PATCH] UI wip --- ui.h | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 ui.h diff --git a/ui.h b/ui.h new file mode 100644 index 0000000..537e21a --- /dev/null +++ b/ui.h @@ -0,0 +1,41 @@ +#pragma once + +#include "types.h" +#include "util/vector.h" +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +typedef struct _App App; + +typedef enum { + ui_Running, + ui_Paused, + ui_TitleMenu, + ui_StateCount // Keep at last +} ui_States; + + +// Forward declarations +typedef struct _ui_Button ui_Button; +typedef struct _System_UI System_UI; + +// a Part of the UI. +typedef struct { + void *user; // user data + void (*draw)(System_UI *sys, void *user); // called when the UI is to be drawn +} ui_Part; + +// UI system with its own state machine. +typedef struct _System_UI { + App *super; + vector_Vector *parts[ui_StateCount]; +} System_UI; + + +#ifdef __cplusplus +} +#endif