clang-format

This commit is contained in:
2025-08-10 14:49:49 +02:00
parent d21a474754
commit 8da2db9686
10 changed files with 297 additions and 269 deletions

View File

@@ -13,25 +13,33 @@
// --- Implementación de las estructuras de animación ---
void MenuRenderer::ResizeAnimation::start(float from_w, float from_h, float to_w, float to_h) {
start_width = from_w; start_height = from_h;
target_width = to_w; target_height = to_h;
start_width = from_w;
start_height = from_h;
target_width = to_w;
target_height = to_h;
elapsed = 0.0F;
active = true;
}
void MenuRenderer::ResizeAnimation::stop() { active = false;
void MenuRenderer::ResizeAnimation::stop() {
active = false;
elapsed = 0.0F;
}
void MenuRenderer::ShowHideAnimation::startShow(float to_w, float to_h) {
type = Type::SHOWING; target_width = to_w; target_height = to_h;
type = Type::SHOWING;
target_width = to_w;
target_height = to_h;
elapsed = 0.0F;
active = true;
}
void MenuRenderer::ShowHideAnimation::startHide() { type = Type::HIDING;
void MenuRenderer::ShowHideAnimation::startHide() {
type = Type::HIDING;
elapsed = 0.0F;
active = true;
}
void MenuRenderer::ShowHideAnimation::stop() { type = Type::NONE; active = false;
void MenuRenderer::ShowHideAnimation::stop() {
type = Type::NONE;
active = false;
elapsed = 0.0F;
}
@@ -62,7 +70,7 @@ void MenuRenderer::render(const ServiceMenu *menu_state) {
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), BORDER_COLOR.r, BORDER_COLOR.g, BORDER_COLOR.b, 255);
SDL_RenderRect(Screen::get()->getRenderer(), &rect_);
SDL_RenderRect(Screen::get()->getRenderer(), &border_rect_);
// Solo renderizar contenido si la animación lo permite
if (shouldShowContent()) {
// Dibuja el título
@@ -101,7 +109,7 @@ void MenuRenderer::render(const ServiceMenu *menu_state) {
void MenuRenderer::update(const ServiceMenu *menu_state) {
float delta_time = 1.0F / 60.0F; // Asumiendo 60 FPS
updateAnimations(delta_time);
if (visible_) {
updateColorCounter();
param.service_menu.selected_color = getAnimatedSelectedColor();
@@ -110,7 +118,7 @@ void MenuRenderer::update(const ServiceMenu *menu_state) {
// --- Nuevos métodos de control ---
void MenuRenderer::show(const ServiceMenu* menu_state) {
void MenuRenderer::show(const ServiceMenu *menu_state) {
if (visible_) {
return;
}
@@ -118,13 +126,13 @@ void MenuRenderer::show(const ServiceMenu* menu_state) {
// Calcula el tamaño final y lo usa para la animación
SDL_FRect target_rect = calculateNewRect(menu_state);
// Detener cualquier animación anterior
resize_animation_.stop();
// Iniciar animación de mostrar
show_hide_animation_.startShow(target_rect.w, target_rect.h);
// El tamaño inicial es cero para la animación
rect_.w = 0.0F;
rect_.h = 0.0F;
@@ -194,14 +202,13 @@ auto MenuRenderer::calculateNewRect(const ServiceMenu *menu_state) -> SDL_FRect
const auto &display_options = menu_state->getDisplayOptions();
lower_height_ = ((!display_options.empty() ? display_options.size() - 1 : 0) * (options_height_ + options_padding_)) + options_height_ + (lower_padding_ * 2);
height_ = std::min(upper_height_ + lower_height_, max_menu_height_);
SDL_FRect new_rect = {0, 0, (float)width_, (float)height_};
// La posición x, y se establecerá en `updatePosition`
return new_rect;
}
void MenuRenderer::resize(const ServiceMenu *menu_state) {
SDL_FRect new_rect = calculateNewRect(menu_state);
@@ -219,7 +226,7 @@ void MenuRenderer::setSize(const ServiceMenu *menu_state) {
SDL_FRect new_rect = calculateNewRect(menu_state);
rect_.w = new_rect.w;
rect_.h = new_rect.h;
show_hide_animation_.stop();
resize_animation_.stop();
@@ -242,7 +249,7 @@ void MenuRenderer::updateAnimations(float delta_time) {
void MenuRenderer::updateShowHideAnimation(float delta_time) {
show_hide_animation_.elapsed += delta_time;
float duration = show_hide_animation_.duration;
if (show_hide_animation_.elapsed >= duration) {
if (show_hide_animation_.type == ShowHideAnimation::Type::SHOWING) {
rect_.w = show_hide_animation_.target_width;
@@ -286,7 +293,6 @@ void MenuRenderer::updateResizeAnimation(float delta_time) {
options_y_ = rect_.y + upper_height_ + lower_padding_;
}
void MenuRenderer::updatePosition() {
switch (position_mode_) {
case PositionMode::CENTERED: