service menu vitaminat: cliping, swapping animation i versió

This commit is contained in:
2026-04-14 19:41:17 +02:00
parent 25a36d5064
commit 10a3e2fedd
3 changed files with 118 additions and 7 deletions

View File

@@ -42,6 +42,9 @@ class MenuRenderer {
void onLayoutChanged(const ServiceMenu* menu_state);
void setLayout(const ServiceMenu* menu_state);
// Animación de intercambio de valores entre dos filas del menú actual
void startSwapAnimation(size_t idx_a, size_t idx_b);
// Getters
[[nodiscard]] auto getRect() const -> const SDL_FRect& { return rect_; }
@@ -63,6 +66,7 @@ class MenuRenderer {
size_t upper_height_ = 0;
size_t lower_height_ = 0;
size_t lower_padding_ = 0;
size_t subtitle_offset_ = 0; // Altura reservada para subtítulo del grupo actual
Uint32 color_counter_ = 0;
bool visible_ = false;
@@ -102,6 +106,16 @@ class MenuRenderer {
void stop();
} show_hide_animation_;
// Animación de intercambio: interpola la Y del VALOR de dos filas
// durante su intercambio. El caption se queda estático.
struct SwapAnimation {
bool active = false;
size_t idx_a = 0;
size_t idx_b = 0;
float elapsed = 0.0F;
float duration = 0.4F;
} swap_animation_;
// --- Anchos precalculados ---
std::array<int, ServiceMenu::SETTINGS_GROUP_SIZE> group_menu_widths_ = {};
@@ -112,9 +126,14 @@ class MenuRenderer {
void resize(const ServiceMenu* menu_state);
void setSize(const ServiceMenu* menu_state);
// Altura extra ocupada por el subtítulo del grupo actual (versión + hash en SYSTEM)
[[nodiscard]] auto getGroupSubtitleHeight(const ServiceMenu* menu_state) const -> size_t;
[[nodiscard]] static auto groupHasSubtitle(ServiceMenu::SettingsGroup group) -> bool;
void updateAnimations(float delta_time);
void updateResizeAnimation(float delta_time);
void updateShowHideAnimation(float delta_time);
void updateSwapAnimation(float delta_time);
void updatePosition();
void precalculateMenuWidths(const std::vector<std::unique_ptr<MenuOption>>& all_options, const ServiceMenu* menu_state); // NOLINT(readability-avoid-const-params-in-decls)