Corregidos ~2570 issues automáticamente con clang-tidy --fix-errors más ajustes manuales posteriores: - modernize: designated-initializers, trailing-return-type, use-auto, avoid-c-arrays (→ std::array<>), use-ranges, use-emplace, deprecated-headers, use-equals-default, pass-by-value, return-braced-init-list, use-default-member-init - readability: math-missing-parentheses, implicit-bool-conversion, braces-around-statements, isolate-declaration, use-std-min-max, identifier-naming, else-after-return, redundant-casting, convert-member-functions-to-static, make-member-function-const, static-accessed-through-instance - performance: avoid-endl, unnecessary-value-param, type-promotion, inefficient-vector-operation - dead code: XOR_KEY (orphan tras eliminar encryptData/decryptData), dead stores en engine.cpp y png_shape.cpp - NOLINT justificado en 10 funciones con alta complejidad cognitiva (initialize, render, main, processEvents, update×3, performDemoAction, randomizeOnDemoStart, renderDebugHUD, AppLogo::update) Compilación: gcc -Wall sin warnings. clang-tidy: 0 issues. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
113 lines
3.7 KiB
C++
113 lines
3.7 KiB
C++
#pragma once
|
|
|
|
#include <SDL3/SDL.h>
|
|
|
|
#include <memory>
|
|
#include <queue>
|
|
#include <string>
|
|
|
|
// Forward declarations
|
|
class TextRenderer;
|
|
class ThemeManager;
|
|
|
|
/**
|
|
* @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)
|
|
// NOTA: Los colores se obtienen dinámicamente desde ThemeManager en render()
|
|
};
|
|
|
|
Notifier();
|
|
~Notifier();
|
|
|
|
/**
|
|
* @brief Inicializa el notifier con un TextRenderer y ThemeManager
|
|
* @param renderer SDL renderer para dibujar
|
|
* @param text_renderer TextRenderer configurado con tamaño absoluto
|
|
* @param theme_manager ThemeManager para obtener colores dinámicos con LERP
|
|
* @param window_width Ancho de ventana física
|
|
* @param window_height Alto de ventana física
|
|
* @return true si inicialización exitosa
|
|
*/
|
|
bool init(SDL_Renderer* renderer, TextRenderer* text_renderer, ThemeManager* theme_manager, 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)
|
|
* @note Los colores se obtienen dinámicamente desde ThemeManager cada frame
|
|
*/
|
|
void show(const std::string& text, Uint64 duration = 0);
|
|
|
|
/**
|
|
* @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_;
|
|
ThemeManager* theme_manager_; // Gestor de temas para obtener colores dinámicos con LERP
|
|
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);
|
|
};
|