diff options
| author | Roberto Esteves <contact@robertoesteves.dev> | 2025-11-22 16:35:06 +0000 |
|---|---|---|
| committer | Roberto Esteves <contact@robertoesteves.dev> | 2025-11-22 16:35:06 +0000 |
| commit | e7c2ec9719349f7a20dd1d4854869c10d8836a11 (patch) | |
| tree | af5b34d8d21cabd4ec6d4206ce5a6fd4651de56c /include | |
| parent | d84537c52f537920369618028f84b48296811fd0 (diff) | |
Diffstat (limited to 'include')
| -rw-r--r-- | include/core/component.h | 15 | ||||
| -rw-r--r-- | include/core/event.h | 48 | ||||
| -rw-r--r-- | include/core/renderer.h (renamed from include/gui/renderer.h) | 2 | ||||
| -rw-r--r-- | include/core/types.h | 42 | ||||
| -rw-r--r-- | include/core/window.h (renamed from include/gui/window.h) | 38 | ||||
| -rw-r--r-- | include/gui/types.h | 35 | ||||
| -rw-r--r-- | include/immediate/immediate.h | 21 | ||||
| -rw-r--r-- | include/internal/utils.h | 3 |
8 files changed, 132 insertions, 72 deletions
diff --git a/include/core/component.h b/include/core/component.h new file mode 100644 index 0000000..639330b --- /dev/null +++ b/include/core/component.h @@ -0,0 +1,15 @@ +#ifndef RUIM_CORE_COMPONENT +#define RUIM_CORE_COMPONENT + +#include "internal/utils.h" + +struct ruim_component { + u64 id, type; + void *data; +}; + +struct ruim_componentTree { + u64 root; +}; + +#endif diff --git a/include/core/event.h b/include/core/event.h new file mode 100644 index 0000000..4798775 --- /dev/null +++ b/include/core/event.h @@ -0,0 +1,48 @@ +#ifndef RUIM_GUI_EVENT +#define RUIM_GUI_EVENT + +#include "core/types.h" +#include "internal/utils.h" + +struct ruim_eventComponent { + u64 sourceID; + u64 eventID; + void *eventData; +}; + +struct ruim_eventKey { + uint32_t keycode; +}; + +struct ruim_eventMouse { + uint32_t keycode; + uint16_t x; + uint16_t y; +}; + +struct ruim_coordinates { + uint16_t x; + uint16_t y; + uint16_t width; + uint16_t height; +}; + +struct ruim_toplevel { + RuimToplevelType type; + RuimToplevelBackend *backend; + + void *data; +}; + +struct ruim_event { + RuimEventType type; + union { + RuimEventWindow window; + RuimEventRedraw redraw; + RuimEventKey key; + RuimEventMouse mouse; + RuimEventComponent component; + } data; +}; + +#endif diff --git a/include/gui/renderer.h b/include/core/renderer.h index 3141a7a..05e4a07 100644 --- a/include/gui/renderer.h +++ b/include/core/renderer.h @@ -1,7 +1,7 @@ #ifndef RUIM_GUI_RENDERER #define RUIM_GUI_RENDERER -#include "gui/types.h" +#include "core/types.h" #ifdef RUIM_PLATFORM_LINUX diff --git a/include/core/types.h b/include/core/types.h new file mode 100644 index 0000000..4e6ae5d --- /dev/null +++ b/include/core/types.h @@ -0,0 +1,42 @@ +#ifndef RUIM_GUI_TYPES +#define RUIM_GUI_TYPES + +typedef struct ruim_surfaceEGL RuimSurfaceEGL; + +typedef struct ruim_toplevel RuimToplevel; +typedef struct ruim_toplevelBackend RuimToplevelBackend; + +typedef struct ruim_coordinates RuimCoordinates; + +typedef unsigned char RuimToplevelBackendType; +#define RUIM_TOPLEVEL_X11 ((RuimToplevelBackendType)1) +#define RUIM_TOPLEVEL_WAYLAND ((RuimToplevelBackendType)2) +#define RUIM_TOPLEVEL_QUARTZ ((RuimToplevelBackendType)3) +#define RUIM_TOPLEVEL_WIN32 ((RuimToplevelBackendType)4) + +typedef unsigned char RuimToplevelType; +#define RUIM_TOPLEVEL_WINDOW ((RuimToplevelType)1) + +typedef unsigned char RuimEventType; +#define RUIM_EVENT_NOTHING ((RuimEventType)0) +#define RUIM_EVENT_KEYUP ((RuimEventType)1) +#define RUIM_EVENT_KEYDOWN ((RuimEventType)2) +#define RUIM_EVENT_MOUSEUP ((RuimEventType)3) +#define RUIM_EVENT_MOUSEDOWN ((RuimEventType)4) +#define RUIM_EVENT_WINDOW ((RuimEventType)5) +#define RUIM_EVENT_REDRAW ((RuimEventType)6) +#define RUIM_EVENT_QUIT ((RuimEventType)7) +#define RUIM_EVENT_COMPONENT ((RuimEventType)8) + +typedef struct ruim_event RuimEvent; +typedef struct ruim_context RuimContext; + +typedef struct ruim_eventKey RuimEventKey; +typedef struct ruim_eventMouse RuimEventMouse; +typedef struct ruim_coordinates RuimEventWindow; +typedef struct ruim_coordinates RuimEventRedraw; +typedef struct ruim_eventComponent RuimEventComponent; + +typedef struct ruim_component RuimComponent; + +#endif diff --git a/include/gui/window.h b/include/core/window.h index 27020c7..2825156 100644 --- a/include/gui/window.h +++ b/include/core/window.h @@ -11,47 +11,13 @@ struct ruim_toplevelBackend { int RuimToplevelBackendInit(RuimToplevelBackend *backend); int RuimToplevelBackendDeinit(RuimToplevelBackend *backend); -struct ruim_toplevelEventKey { - uint32_t keycode; -}; - -struct ruim_toplevelEventMouse { - uint32_t keycode; - uint16_t x; - uint16_t y; -}; - -struct ruim_coordinates { - uint16_t x; - uint16_t y; - uint16_t width; - uint16_t height; -}; - -struct ruim_toplevelEvent { - RuimToplevelEventType type; - union { - RuimToplevelEventWindow window; - RuimToplevelEventRedraw redraw; - RuimToplevelEventKey key; - RuimToplevelEventMouse mouse; - } data; -}; - -struct ruim_toplevel { - RuimToplevelType type; - RuimToplevelBackend *backend; - - void *data; -}; - int RuimToplevelCreate(RuimToplevel *toplevel, RuimToplevelType type); int RuimToplevelDestroy(RuimToplevel *toplevel); int RuimToplevelDisplay(RuimToplevel *toplevel); int RuimToplevelWaitForEvent(RuimToplevel *toplevel); -int RuimToplevelPoll(RuimToplevel *toplevel, RuimToplevelEvent *event); +int RuimToplevelBackendPoll(RuimToplevelBackend *backend, RuimEvent *event); #ifdef RUIM_PLATFORM_LINUX @@ -89,7 +55,7 @@ struct toplevel_x11 { int _create_toplevel_xcb(RuimToplevel *toplevel); int _display_toplevel_xcb(RuimToplevel *toplevel); -int _poll_event_xcb(RuimToplevel *toplevel, RuimToplevelEvent *event); +int _poll_event_xcb(RuimToplevelBackend *backend, RuimEvent *event); int _wait_event_xcb(RuimToplevel *toplevel); int _destroy_toplevel_xcb(RuimToplevel *toplevel); diff --git a/include/gui/types.h b/include/gui/types.h deleted file mode 100644 index 8ca93d2..0000000 --- a/include/gui/types.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef RUIM_GUI_TYPES -#define RUIM_GUI_TYPES - -typedef struct ruim_surfaceEGL RuimSurfaceEGL; - -typedef struct ruim_toplevel RuimToplevel; -typedef struct ruim_toplevelEvent RuimToplevelEvent; -typedef struct ruim_toplevelBackend RuimToplevelBackend; -typedef struct ruim_toplevelEventKey RuimToplevelEventKey; -typedef struct ruim_toplevelEventMouse RuimToplevelEventMouse; - -typedef struct ruim_coordinates RuimCoordinates; -typedef struct ruim_coordinates RuimToplevelEventWindow; -typedef struct ruim_coordinates RuimToplevelEventRedraw; - -typedef unsigned char RuimToplevelBackendType; -#define RUIM_TOPLEVEL_X11 ((RuimToplevelBackendType)1) -#define RUIM_TOPLEVEL_WAYLAND ((RuimToplevelBackendType)2) -#define RUIM_TOPLEVEL_QUARTZ ((RuimToplevelBackendType)3) -#define RUIM_TOPLEVEL_WIN32 ((RuimToplevelBackendType)4) - -typedef unsigned char RuimToplevelType; -#define RUIM_TOPLEVEL_WINDOW ((RuimToplevelType)1) - -typedef unsigned char RuimToplevelEventType; -#define RUIM_TOPLEVEL_EVENT_NOTHING ((RuimToplevelEventType)0) -#define RUIM_TOPLEVEL_EVENT_KEYUP ((RuimToplevelEventType)1) -#define RUIM_TOPLEVEL_EVENT_KEYDOWN ((RuimToplevelEventType)2) -#define RUIM_TOPLEVEL_EVENT_MOUSEUP ((RuimToplevelEventType)3) -#define RUIM_TOPLEVEL_EVENT_MOUSEDOWN ((RuimToplevelEventType)4) -#define RUIM_TOPLEVEL_EVENT_WINDOW ((RuimToplevelEventType)5) -#define RUIM_TOPLEVEL_EVENT_REDRAW ((RuimToplevelEventType)6) -#define RUIM_TOPLEVEL_EVENT_QUIT ((RuimToplevelEventType)7) - -#endif diff --git a/include/immediate/immediate.h b/include/immediate/immediate.h new file mode 100644 index 0000000..d9725c8 --- /dev/null +++ b/include/immediate/immediate.h @@ -0,0 +1,21 @@ +#ifndef RUIM_CORE +#define RUIM_CORE + +#include "core/event.h" +#include "core/renderer.h" +#include "core/types.h" +#include "core/window.h" + +int RuimInit(void); + +void RuimBegin(void); +void RuimEnd(void); + +int RuimWaitForEvent(void); + +const char *RuimGetError(void); + +void RuimBeginWindow(const char *title, RuimCoordinates *coordinates); +void RuimEndWindow(void); + +#endif /* RUIM_CORE */ diff --git a/include/internal/utils.h b/include/internal/utils.h index 8952369..a28ae89 100644 --- a/include/internal/utils.h +++ b/include/internal/utils.h @@ -25,6 +25,9 @@ typedef unsigned int u32; typedef signed long int i64; typedef unsigned long int u64; +typedef float f32; +typedef double f64; + typedef struct { u64 size; const char *buf; |