style: aplicar fixes de clang-tidy (todo excepto uppercase-literal-suffix)

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>
This commit is contained in:
2026-03-21 10:52:07 +01:00
parent 4801f287df
commit c9bcce6f9b
71 changed files with 3469 additions and 2838 deletions

View File

@@ -1,19 +1,15 @@
#include "dynamic_theme.hpp"
#include <algorithm> // for std::min
DynamicTheme::DynamicTheme(const char* name_en, const char* name_es,
int text_r, int text_g, int text_b,
std::vector<DynamicThemeKeyframe> keyframes,
bool loop)
DynamicTheme::DynamicTheme(const char* name_en, const char* name_es, int text_r, int text_g, int text_b, std::vector<DynamicThemeKeyframe> keyframes, bool loop)
: name_en_(name_en),
name_es_(name_es),
text_r_(text_r), text_g_(text_g), text_b_(text_b),
text_r_(text_r),
text_g_(text_g),
text_b_(text_b),
keyframes_(std::move(keyframes)),
loop_(loop),
current_keyframe_index_(0),
target_keyframe_index_(1),
transition_progress_(0.0f),
paused_(false) {
loop_(loop) {
// Validación: mínimo 2 keyframes
if (keyframes_.size() < 2) {
// Fallback: duplicar primer keyframe si solo hay 1
@@ -29,7 +25,9 @@ DynamicTheme::DynamicTheme(const char* name_en, const char* name_es,
}
void DynamicTheme::update(float delta_time) {
if (paused_) return; // No actualizar si está pausado
if (paused_) {
return; // No actualizar si está pausado
}
// Obtener duración del keyframe objetivo
float duration = keyframes_[target_keyframe_index_].duration;
@@ -74,14 +72,14 @@ void DynamicTheme::advanceToNextKeyframe() {
transition_progress_ = 0.0f;
}
Color DynamicTheme::getBallColor(size_t ball_index, float progress) const {
auto DynamicTheme::getBallColor(size_t ball_index, float progress) const -> Color {
// Obtener keyframes actual y objetivo
const auto& current_kf = keyframes_[current_keyframe_index_];
const auto& target_kf = keyframes_[target_keyframe_index_];
// Si paletas vacías, retornar blanco
if (current_kf.ball_colors.empty() || target_kf.ball_colors.empty()) {
return {255, 255, 255};
return {.r = 255, .g = 255, .b = 255};
}
// Obtener colores de ambos keyframes (con wrap)
@@ -95,15 +93,18 @@ Color DynamicTheme::getBallColor(size_t ball_index, float progress) const {
// (progress parámetro será usado en PHASE 3 para LERP externo)
float t = transition_progress_;
return {
static_cast<int>(lerp(c1.r, c2.r, t)),
static_cast<int>(lerp(c1.g, c2.g, t)),
static_cast<int>(lerp(c1.b, c2.b, t))
};
.r = static_cast<int>(lerp(c1.r, c2.r, t)),
.g = static_cast<int>(lerp(c1.g, c2.g, t)),
.b = static_cast<int>(lerp(c1.b, c2.b, t))};
}
void DynamicTheme::getBackgroundColors(float progress,
float& tr, float& tg, float& tb,
float& br, float& bg, float& bb) const {
float& tr,
float& tg,
float& tb,
float& br,
float& bg,
float& bb) const {
// Obtener keyframes actual y objetivo
const auto& current_kf = keyframes_[current_keyframe_index_];
const auto& target_kf = keyframes_[target_keyframe_index_];

View File

@@ -1,8 +1,9 @@
#pragma once
#include "theme.hpp"
#include <string>
#include "theme.hpp"
// Forward declaration (estructura definida en defines.h)
struct DynamicThemeKeyframe;
@@ -30,10 +31,7 @@ class DynamicTheme : public Theme {
* @param keyframes: Vector de keyframes (mínimo 2)
* @param loop: ¿Volver al inicio al terminar? (siempre true en esta app)
*/
DynamicTheme(const char* name_en, const char* name_es,
int text_r, int text_g, int text_b,
std::vector<DynamicThemeKeyframe> keyframes,
bool loop = true);
DynamicTheme(const char* name_en, const char* name_es, int text_r, int text_g, int text_b, std::vector<DynamicThemeKeyframe> keyframes, bool loop = true);
~DynamicTheme() override = default;
@@ -56,8 +54,12 @@ class DynamicTheme : public Theme {
Color getBallColor(size_t ball_index, float progress) const override;
void getBackgroundColors(float progress,
float& tr, float& tg, float& tb,
float& br, float& bg, float& bb) const override;
float& tr,
float& tg,
float& tb,
float& br,
float& bg,
float& bb) const override;
// ========================================
// ANIMACIÓN (soporte completo)
@@ -90,10 +92,10 @@ class DynamicTheme : public Theme {
// ESTADO DE ANIMACIÓN
// ========================================
size_t current_keyframe_index_ = 0; // Keyframe actual
size_t target_keyframe_index_ = 1; // Próximo keyframe
float transition_progress_ = 0.0f; // Progreso 0.0-1.0 hacia target
bool paused_ = false; // Pausa manual con Shift+D
size_t current_keyframe_index_ = 0; // Keyframe actual
size_t target_keyframe_index_ = 1; // Próximo keyframe
float transition_progress_ = 0.0f; // Progreso 0.0-1.0 hacia target
bool paused_ = false; // Pausa manual con Shift+D
// ========================================
// UTILIDADES PRIVADAS

View File

@@ -1,32 +1,39 @@
#include "static_theme.hpp"
StaticTheme::StaticTheme(const char* name_en, const char* name_es,
int text_r, int text_g, int text_b,
int notif_bg_r, int notif_bg_g, int notif_bg_b,
float bg_top_r, float bg_top_g, float bg_top_b,
float bg_bottom_r, float bg_bottom_g, float bg_bottom_b,
std::vector<Color> ball_colors)
StaticTheme::StaticTheme(const char* name_en, const char* name_es, int text_r, int text_g, int text_b, int notif_bg_r, int notif_bg_g, int notif_bg_b, float bg_top_r, float bg_top_g, float bg_top_b, float bg_bottom_r, float bg_bottom_g, float bg_bottom_b, std::vector<Color> ball_colors)
: name_en_(name_en),
name_es_(name_es),
text_r_(text_r), text_g_(text_g), text_b_(text_b),
notif_bg_r_(notif_bg_r), notif_bg_g_(notif_bg_g), notif_bg_b_(notif_bg_b),
bg_top_r_(bg_top_r), bg_top_g_(bg_top_g), bg_top_b_(bg_top_b),
bg_bottom_r_(bg_bottom_r), bg_bottom_g_(bg_bottom_g), bg_bottom_b_(bg_bottom_b),
text_r_(text_r),
text_g_(text_g),
text_b_(text_b),
notif_bg_r_(notif_bg_r),
notif_bg_g_(notif_bg_g),
notif_bg_b_(notif_bg_b),
bg_top_r_(bg_top_r),
bg_top_g_(bg_top_g),
bg_top_b_(bg_top_b),
bg_bottom_r_(bg_bottom_r),
bg_bottom_g_(bg_bottom_g),
bg_bottom_b_(bg_bottom_b),
ball_colors_(std::move(ball_colors)) {
}
Color StaticTheme::getBallColor(size_t ball_index, float progress) const {
auto StaticTheme::getBallColor(size_t ball_index, float progress) const -> Color {
// Tema estático: siempre retorna color de paleta según índice
// (progress se ignora aquí, pero será usado en PHASE 3 para LERP externo)
if (ball_colors_.empty()) {
return {255, 255, 255}; // Blanco por defecto si paleta vacía
return {.r = 255, .g = 255, .b = 255}; // Blanco por defecto si paleta vacía
}
return ball_colors_[ball_index % ball_colors_.size()];
}
void StaticTheme::getBackgroundColors(float progress,
float& tr, float& tg, float& tb,
float& br, float& bg, float& bb) const {
float& tr,
float& tg,
float& tb,
float& br,
float& bg,
float& bb) const {
// Tema estático: siempre retorna colores de fondo fijos
// (progress se ignora aquí, pero será usado en PHASE 3 para LERP externo)
tr = bg_top_r_;

View File

@@ -1,8 +1,9 @@
#pragma once
#include "theme.hpp"
#include <string>
#include "theme.hpp"
/**
* StaticTheme: Tema estático con 1 keyframe (sin animación)
*
@@ -28,12 +29,7 @@ class StaticTheme : public Theme {
* @param bg_bottom_r, bg_bottom_g, bg_bottom_b: Color inferior de fondo
* @param ball_colors: Paleta de colores para pelotas
*/
StaticTheme(const char* name_en, const char* name_es,
int text_r, int text_g, int text_b,
int notif_bg_r, int notif_bg_g, int notif_bg_b,
float bg_top_r, float bg_top_g, float bg_top_b,
float bg_bottom_r, float bg_bottom_g, float bg_bottom_b,
std::vector<Color> ball_colors);
StaticTheme(const char* name_en, const char* name_es, int text_r, int text_g, int text_b, int notif_bg_r, int notif_bg_g, int notif_bg_b, float bg_top_r, float bg_top_g, float bg_top_b, float bg_bottom_r, float bg_bottom_g, float bg_bottom_b, std::vector<Color> ball_colors);
~StaticTheme() override = default;
@@ -60,8 +56,12 @@ class StaticTheme : public Theme {
Color getBallColor(size_t ball_index, float progress) const override;
void getBackgroundColors(float progress,
float& tr, float& tg, float& tb,
float& br, float& bg, float& bb) const override;
float& tr,
float& tg,
float& tb,
float& br,
float& bg,
float& bb) const override;
// ========================================
// ANIMACIÓN (sin soporte - tema estático)

View File

@@ -1,6 +1,7 @@
#pragma once
#include <vector>
#include "defines.hpp" // for Color, ThemeKeyframe
/**
@@ -47,8 +48,12 @@ class Theme {
* @param br, bg, bb: Color inferior (out)
*/
virtual void getBackgroundColors(float progress,
float& tr, float& tg, float& tb,
float& br, float& bg, float& bb) const = 0;
float& tr,
float& tg,
float& tb,
float& br,
float& bg,
float& bb) const = 0;
// ========================================
// ANIMACIÓN (solo temas dinámicos)
@@ -58,7 +63,7 @@ class Theme {
* Actualiza progreso de animación interna (solo dinámicos)
* @param delta_time: Tiempo transcurrido desde último frame
*/
virtual void update(float delta_time) { }
virtual void update(float delta_time) {}
/**
* ¿Este tema necesita update() cada frame?
@@ -75,7 +80,7 @@ class Theme {
/**
* Reinicia progreso de animación a 0.0 (usado al activar tema)
*/
virtual void resetProgress() { }
virtual void resetProgress() {}
// ========================================
// PAUSA (solo temas dinámicos)
@@ -90,5 +95,5 @@ class Theme {
/**
* Toggle pausa de animación (solo dinámicos, tecla Shift+D)
*/
virtual void togglePause() { }
virtual void togglePause() {}
};

View File

@@ -2,6 +2,7 @@
#include <string>
#include <vector>
#include "defines.hpp" // for Color
/**
@@ -24,23 +25,23 @@
* - Nombres del tema (para debug display durante transición)
*/
struct ThemeSnapshot {
// Colores de fondo degradado
float bg_top_r, bg_top_g, bg_top_b;
float bg_bottom_r, bg_bottom_g, bg_bottom_b;
// Colores de fondo degradado
float bg_top_r, bg_top_g, bg_top_b;
float bg_bottom_r, bg_bottom_g, bg_bottom_b;
// Color de texto UI
int text_color_r, text_color_g, text_color_b;
// Color de texto UI
int text_color_r, text_color_g, text_color_b;
// Color de fondo de notificaciones
int notif_bg_r, notif_bg_g, notif_bg_b;
// Color de fondo de notificaciones
int notif_bg_r, notif_bg_g, notif_bg_b;
// Nombres del tema (para mostrar "SOURCE → TARGET" durante transición)
std::string name_en;
std::string name_es;
// Nombres del tema (para mostrar "SOURCE → TARGET" durante transición)
std::string name_en;
std::string name_es;
// Colores de pelotas capturados (índice = ball_index % ball_colors.size())
// Se capturan suficientes colores para cubrir escenario máximo (50,000 pelotas)
// Nota: Si el tema tiene 8 colores y capturamos 50,000, habrá repetición
// pero permite LERP correcto incluso con muchas pelotas
std::vector<Color> ball_colors;
// Colores de pelotas capturados (índice = ball_index % ball_colors.size())
// Se capturan suficientes colores para cubrir escenario máximo (50,000 pelotas)
// Nota: Si el tema tiene 8 colores y capturamos 50,000, habrá repetición
// pero permite LERP correcto incluso con muchas pelotas
std::vector<Color> ball_colors;
};