CARACTERÍSTICAS:
- Notificaciones con fondo personalizado por tema (15 temas)
- Soporte completo para temas estáticos y dinámicos
- Interpolación LERP de colores durante transiciones
- Actualización por frame durante animaciones de temas
IMPLEMENTACIÓN:
Theme System:
- Añadido getNotificationBackgroundColor() a interfaz Theme
- StaticTheme: Color fijo por tema
- DynamicTheme: Interpolación entre keyframes
- ThemeManager: LERP durante transiciones (PHASE 3)
- ThemeSnapshot: Captura color para transiciones suaves
Colores por Tema:
Estáticos (9):
- SUNSET: Púrpura oscuro (120, 40, 80)
- OCEAN: Azul marino (20, 50, 90)
- NEON: Púrpura oscuro (60, 0, 80)
- FOREST: Marrón tierra (70, 50, 30)
- RGB: Gris claro (220, 220, 220)
- MONOCHROME: Gris oscuro (50, 50, 50)
- LAVENDER: Violeta oscuro (80, 50, 100)
- CRIMSON: Rojo oscuro (80, 10, 10)
- EMERALD: Verde oscuro (10, 80, 10)
Dinámicos (6, 20 keyframes totales):
- SUNRISE: 3 keyframes (noche→alba→día)
- OCEAN_WAVES: 2 keyframes (profundo→claro)
- NEON_PULSE: 2 keyframes (apagado→encendido)
- FIRE: 4 keyframes (brasas→llamas→inferno→llamas)
- AURORA: 4 keyframes (verde→violeta→cian→violeta)
- VOLCANIC: 4 keyframes (ceniza→erupción→lava→enfriamiento)
Notifier:
- Añadido SDL_Color bg_color a estructura Notification
- Método show() acepta parámetro bg_color
- renderBackground() usa color dinámico (no negro fijo)
- Soporte para cambios de color cada frame
Engine:
- Obtiene color de fondo desde ThemeManager
- Pasa bg_color al notifier en cada notificación
- Sincronizado con tema activo y transiciones
FIXES:
- TEXT_ABSOLUTE_SIZE cambiado de 16px a 12px (múltiplo nativo)
- Centrado de notificaciones corregido en F3 fullscreen
- updatePhysicalWindowSize() usa SDL_GetCurrentDisplayMode en F3
- Notificaciones centradas correctamente en ventana/F3/F4
🎨 Generated with Claude Code
50 lines
1.9 KiB
C++
50 lines
1.9 KiB
C++
#pragma once
|
|
|
|
#include <SDL3/SDL.h>
|
|
#include <SDL3_ttf/SDL_ttf.h>
|
|
#include <string>
|
|
|
|
class TextRenderer {
|
|
public:
|
|
TextRenderer();
|
|
~TextRenderer();
|
|
|
|
// Inicializa el renderizador de texto con una fuente
|
|
bool init(SDL_Renderer* renderer, const char* font_path, int font_size, bool use_antialiasing = true);
|
|
|
|
// Libera recursos
|
|
void cleanup();
|
|
|
|
// Renderiza texto en la posición especificada con color RGB
|
|
void print(int x, int y, const char* text, uint8_t r, uint8_t g, uint8_t b);
|
|
void print(int x, int y, const std::string& text, uint8_t r, uint8_t g, uint8_t b);
|
|
|
|
// Renderiza texto en coordenadas lógicas, pero convierte a físicas para tamaño absoluto
|
|
void printPhysical(int logical_x, int logical_y, const char* text, uint8_t r, uint8_t g, uint8_t b, float scale_x, float scale_y);
|
|
void printPhysical(int logical_x, int logical_y, const std::string& text, uint8_t r, uint8_t g, uint8_t b, float scale_x, float scale_y);
|
|
|
|
// Renderiza texto en coordenadas físicas absolutas (tamaño fijo independiente de resolución)
|
|
// NOTA: Este método usa el tamaño de fuente tal cual fue cargado, sin escalado
|
|
void printAbsolute(int physical_x, int physical_y, const char* text, SDL_Color color);
|
|
void printAbsolute(int physical_x, int physical_y, const std::string& text, SDL_Color color);
|
|
|
|
// Obtiene el ancho de un texto renderizado (en píxeles lógicos para compatibilidad)
|
|
int getTextWidth(const char* text);
|
|
|
|
// Obtiene el ancho de un texto en píxeles FÍSICOS reales (sin escalado)
|
|
// Útil para notificaciones y elementos UI de tamaño fijo
|
|
int getTextWidthPhysical(const char* text);
|
|
|
|
// Obtiene la altura de la fuente
|
|
int getTextHeight();
|
|
|
|
// Verifica si está inicializado correctamente
|
|
bool isInitialized() const { return font_ != nullptr && renderer_ != nullptr; }
|
|
|
|
private:
|
|
SDL_Renderer* renderer_;
|
|
TTF_Font* font_;
|
|
int font_size_;
|
|
bool use_antialiasing_;
|
|
};
|