Operation Null Mind 0.4.1
A 2D roguelike top down shooter game made with SDL2
 
Loading...
Searching...
No Matches
UI_text.h
Go to the documentation of this file.
1
30#pragma once
31
32#include <UI.h>
33#include <SDL_ttf.h>
34
43
50typedef struct UI_TextData {
51 char* text;
52 SDL_Texture* textTexture;
53 TTF_Font* font;
56
57UIElement* UI_CreateText(const char* text, SDL_Rect rect,
58 SDL_Color color, float scale, UI_TextAlignment alignment,
59 TTF_Font* font);
60SDL_Texture* UI_CreateTextTexture(const char* text, SDL_Color color, TTF_Font* font);
61
62void UI_UpdateText(UIElement* element);
63void UI_RenderText(UIElement* element);
64void UI_DestroyText(UIElement* element);
65
66void UI_ChangeText(UIElement* element, const char* text);
67void UI_ChangeTextColor(UIElement* element, SDL_Color color);
68
69void UI_SetHovered(UIElement* element, bool hovered);
70bool UI_IsHovered(UIElement* element);
Defines the base UI element structure for the user interface system.
void UI_SetHovered(UIElement *element, bool hovered)
Definition UI_text.c:21
void UI_ChangeTextColor(UIElement *element, SDL_Color color)
Definition UI_text.c:135
void UI_DestroyText(UIElement *element)
Definition UI_text.c:115
UI_TextAlignment
An enum for text alignment.
Definition UI_text.h:38
@ UI_TEXT_ALIGN_LEFT
Definition UI_text.h:39
@ UI_TEXT_ALIGN_CENTER
Definition UI_text.h:40
@ UI_TEXT_ALIGN_RIGHT
Definition UI_text.h:41
void UI_ChangeText(UIElement *element, const char *text)
Definition UI_text.c:125
SDL_Texture * UI_CreateTextTexture(const char *text, SDL_Color color, TTF_Font *font)
Definition UI_text.c:77
void UI_RenderText(UIElement *element)
Definition UI_text.c:109
bool UI_IsHovered(UIElement *element)
Definition UI_text.c:26
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
void UI_UpdateText(UIElement *element)
Definition UI_text.c:87
UI Element structure.
Definition UI.h:55
Data structure for UI text elements.
Definition UI_text.h:50
TTF_Font * font
Font used for text rendering.
Definition UI_text.h:53
UI_TextAlignment alignment
Text alignment (left, center, or right)
Definition UI_text.h:54
SDL_Texture * textTexture
Pre-rendered text texture.
Definition UI_text.h:52
char * text
Text content to display.
Definition UI_text.h:51