Operation Null Mind 0.4.1
A 2D roguelike top down shooter game made with SDL2
 
Loading...
Searching...
No Matches
UI.h
Go to the documentation of this file.
1
23#pragma once
24
25#include <SDL.h>
26#include <vec2.h>
27#include <stdbool.h>
28
45
46// Forward declaration to avoid circular dependency
47typedef struct UIElement UIElement;
48
55struct UIElement {
58 void* data;
61 SDL_Rect rect;
62 bool visible;
63 bool enabled;
64 bool hovered;
65 bool pressed;
68 SDL_Rect srcRect;
69 SDL_Rect dstRect;
70 SDL_Rect textureSize;
71 SDL_Color color;
72 float scale;
74 // Callbacks
75 void (*render)(UIElement* self);
76 void (*update)(UIElement* self);
77 void (*cleanup)(UIElement* self);
78};
UIElementType
UI Element Types enumeration.
Definition UI.h:35
@ UI_ELEMENT_IMAGE
Definition UI.h:43
@ UI_ELEMENT_TEXT
Definition UI.h:42
@ UI_ELEMENT_LABEL
Definition UI.h:39
@ UI_ELEMENT_SLIDER
Definition UI.h:41
@ UI_ELEMENT_NONE
Definition UI.h:36
@ UI_ELEMENT_BUTTON
Definition UI.h:38
@ UI_ELEMENT_CHECKBOX
Definition UI.h:40
@ UI_ELEMENT_PANEL
Definition UI.h:37
UI Element structure.
Definition UI.h:55
SDL_Rect rect
Common properties.
Definition UI.h:61
void(* update)(UIElement *self)
Update logic.
Definition UI.h:76
SDL_Color color
Color tint/modulation.
Definition UI.h:71
bool hovered
Is mouse over this element?
Definition UI.h:64
bool pressed
Is mouse button pressed on this element?
Definition UI.h:65
UIElementType type
Element-specific data (depends on type)
Definition UI.h:57
void(* render)(UIElement *self)
Render function.
Definition UI.h:75
bool visible
Is this element visible?
Definition UI.h:62
void * data
Pointer to element-specific data.
Definition UI.h:58
SDL_Rect dstRect
Destination rectangle for rendering.
Definition UI.h:69
SDL_Rect srcRect
Rendering properties.
Definition UI.h:68
SDL_Rect textureSize
Texture size.
Definition UI.h:70
bool enabled
Is this element interactive?
Definition UI.h:63
void(* cleanup)(UIElement *self)
Free resources.
Definition UI.h:77
float scale
Scale factor for the texture.
Definition UI.h:72
Provides 2D vector functionality for positions, directions, and transformations.