Add: Sistema de notificaciones con colores de fondo temáticos
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
This commit is contained in:
108
source/ui/notifier.h
Normal file
108
source/ui/notifier.h
Normal file
@@ -0,0 +1,108 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
#include <string>
|
||||
#include <queue>
|
||||
#include <memory>
|
||||
|
||||
// Forward declaration
|
||||
class TextRenderer;
|
||||
|
||||
/**
|
||||
* @brief Sistema de notificaciones estilo iOS/Android
|
||||
*
|
||||
* Maneja notificaciones temporales con animaciones suaves:
|
||||
* - Slide-in desde arriba
|
||||
* - Fade-out al desaparecer
|
||||
* - Cola FIFO de mensajes
|
||||
* - Fondo semitransparente
|
||||
* - Texto de tamaño fijo independiente de resolución
|
||||
*/
|
||||
class Notifier {
|
||||
public:
|
||||
enum class NotificationState {
|
||||
SLIDING_IN, // Animación de entrada desde arriba
|
||||
VISIBLE, // Visible estático
|
||||
FADING_OUT, // Animación de salida (fade)
|
||||
DONE // Completado, listo para eliminar
|
||||
};
|
||||
|
||||
struct Notification {
|
||||
std::string text;
|
||||
Uint64 created_time;
|
||||
Uint64 duration;
|
||||
NotificationState state;
|
||||
float alpha; // Opacidad 0.0-1.0
|
||||
float y_offset; // Offset Y para animación slide (píxeles)
|
||||
SDL_Color color;
|
||||
SDL_Color bg_color; // Color de fondo de la notificación (RGB)
|
||||
};
|
||||
|
||||
Notifier();
|
||||
~Notifier();
|
||||
|
||||
/**
|
||||
* @brief Inicializa el notifier con un TextRenderer
|
||||
* @param renderer SDL renderer para dibujar
|
||||
* @param text_renderer TextRenderer configurado con tamaño absoluto
|
||||
* @return true si inicialización exitosa
|
||||
*/
|
||||
bool init(SDL_Renderer* renderer, TextRenderer* text_renderer, int window_width, int window_height);
|
||||
|
||||
/**
|
||||
* @brief Actualiza las dimensiones de la ventana (llamar en resize)
|
||||
* @param window_width Nuevo ancho de ventana física
|
||||
* @param window_height Nuevo alto de ventana física
|
||||
*/
|
||||
void updateWindowSize(int window_width, int window_height);
|
||||
|
||||
/**
|
||||
* @brief Muestra una nueva notificación
|
||||
* @param text Texto a mostrar
|
||||
* @param duration Duración en milisegundos (0 = usar default)
|
||||
* @param color Color del texto
|
||||
* @param bg_color Color de fondo de la notificación
|
||||
*/
|
||||
void show(const std::string& text, Uint64 duration = 0, SDL_Color color = {255, 255, 255, 255}, SDL_Color bg_color = {0, 0, 0, 255});
|
||||
|
||||
/**
|
||||
* @brief Actualiza las animaciones de notificaciones
|
||||
* @param current_time Tiempo actual en ms (SDL_GetTicks())
|
||||
*/
|
||||
void update(Uint64 current_time);
|
||||
|
||||
/**
|
||||
* @brief Renderiza la notificación activa
|
||||
*/
|
||||
void render();
|
||||
|
||||
/**
|
||||
* @brief Verifica si hay una notificación activa (visible)
|
||||
* @return true si hay notificación mostrándose
|
||||
*/
|
||||
bool isActive() const;
|
||||
|
||||
/**
|
||||
* @brief Limpia todas las notificaciones pendientes
|
||||
*/
|
||||
void clear();
|
||||
|
||||
private:
|
||||
SDL_Renderer* renderer_;
|
||||
TextRenderer* text_renderer_;
|
||||
int window_width_;
|
||||
int window_height_;
|
||||
|
||||
std::queue<Notification> notification_queue_;
|
||||
std::unique_ptr<Notification> current_notification_;
|
||||
|
||||
/**
|
||||
* @brief Procesa la cola y activa la siguiente notificación si es posible
|
||||
*/
|
||||
void processQueue();
|
||||
|
||||
/**
|
||||
* @brief Dibuja el fondo semitransparente de la notificación
|
||||
*/
|
||||
void renderBackground(int x, int y, int width, int height, float alpha, SDL_Color bg_color);
|
||||
};
|
||||
Reference in New Issue
Block a user