Operation Null Mind 0.4.1
A 2D roguelike top down shooter game made with SDL2
 
Loading...
Searching...
No Matches
UI.h File Reference

Defines the base UI element structure for the user interface system. More...

#include <SDL.h>
#include <vec2.h>
#include <stdbool.h>

Go to the source code of this file.

Classes

struct  UIElement
 UI Element structure. More...
 

Typedefs

typedef struct UIElement UIElement
 

Enumerations

enum  UIElementType {
  UI_ELEMENT_NONE , UI_ELEMENT_PANEL , UI_ELEMENT_BUTTON , UI_ELEMENT_LABEL ,
  UI_ELEMENT_CHECKBOX , UI_ELEMENT_SLIDER , UI_ELEMENT_TEXT , UI_ELEMENT_IMAGE
}
 UI Element Types enumeration. More...
 

Detailed Description

Defines the base UI element structure for the user interface system.

Author
Mango
Date
2025-03-12

Usage Examples

The UIElement struct being used as a base to render UI texts:

// Create a simple text element
static UIElement* titleText = UI_CreateText(
"Operation Null Mind",
(SDL_Rect){400, 100, 400, 50}, // Position and size
(SDL_Color){255, 255, 255, 255}, // Color
1.5f, // Scale
UI_TEXT_ALIGN_CENTER, // Alignment (Look at UI_TextAlignment enum)
app.resources.fonts.titleFont // Font
);
UIElement * UI_CreateText(const char *text, SDL_Rect rect, SDL_Color color, float scale, UI_TextAlignment alignment, TTF_Font *font)
Definition UI_text.c:38
@ UI_TEXT_ALIGN_CENTER
Definition UI_text.h:40
AppData app
A global variable containing the app's resources, state, and configurations.
AppResources resources
The app's resources.
Definition app.h:108
UI Element structure.
Definition UI.h:55

Typedef Documentation

◆ UIElement

typedef struct UIElement UIElement

Enumeration Type Documentation

◆ UIElementType

UI Element Types enumeration.

Used to determine what kind of UI element we're dealing with. Each type has specific behaviors and rendering methods.

Enumerator
UI_ELEMENT_NONE 
UI_ELEMENT_PANEL 
UI_ELEMENT_BUTTON 
UI_ELEMENT_LABEL 
UI_ELEMENT_CHECKBOX 
UI_ELEMENT_SLIDER 
UI_ELEMENT_TEXT 
UI_ELEMENT_IMAGE