clang-tidy modernize
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <SDL3/SDL.h> // Para SDL_FRect, Uint32
|
||||
|
||||
#include <array>
|
||||
#include <cstddef> // Para size_t
|
||||
#include <memory> // Para shared_ptr, unique_ptr
|
||||
#include <vector> // Para vector
|
||||
@@ -14,59 +15,59 @@ class MenuOption;
|
||||
class Text;
|
||||
|
||||
class MenuRenderer {
|
||||
public:
|
||||
MenuRenderer(const ServiceMenu *menu_state, std::shared_ptr<Text> element_text, std::shared_ptr<Text> title_text);
|
||||
public:
|
||||
MenuRenderer(const ServiceMenu *menu_state, std::shared_ptr<Text> element_text, std::shared_ptr<Text> title_text);
|
||||
|
||||
// Métodos principales de la vista
|
||||
void render(const ServiceMenu *menu_state);
|
||||
void update(const ServiceMenu *menu_state);
|
||||
// Métodos principales de la vista
|
||||
void render(const ServiceMenu *menu_state);
|
||||
void update(const ServiceMenu *menu_state);
|
||||
|
||||
// Método para notificar al renderer que el layout puede haber cambiado
|
||||
void onLayoutChanged(const ServiceMenu *menu_state);
|
||||
void setLayout(const ServiceMenu *menu_state);
|
||||
// Método para notificar al renderer que el layout puede haber cambiado
|
||||
void onLayoutChanged(const ServiceMenu *menu_state);
|
||||
void setLayout(const ServiceMenu *menu_state);
|
||||
|
||||
// Getters
|
||||
[[nodiscard]] auto getRect() const -> const SDL_FRect & { return rect_; }
|
||||
// Getters
|
||||
[[nodiscard]] auto getRect() const -> const SDL_FRect & { return rect_; }
|
||||
|
||||
private:
|
||||
// --- Referencias a los renderizadores de texto ---
|
||||
std::shared_ptr<Text> element_text_;
|
||||
std::shared_ptr<Text> title_text_;
|
||||
private:
|
||||
// --- Referencias a los renderizadores de texto ---
|
||||
std::shared_ptr<Text> element_text_;
|
||||
std::shared_ptr<Text> title_text_;
|
||||
|
||||
// --- Variables de estado de la vista (layout y animación) ---
|
||||
SDL_FRect rect_{};
|
||||
SDL_FRect border_rect_{};
|
||||
size_t width_ = 0;
|
||||
size_t height_ = 0;
|
||||
size_t options_height_ = 0;
|
||||
size_t options_padding_ = 0;
|
||||
size_t options_y_ = 0;
|
||||
size_t title_height_ = 0;
|
||||
size_t title_padding_ = 0;
|
||||
size_t upper_height_ = 0;
|
||||
size_t lower_height_ = 0;
|
||||
size_t lower_padding_ = 0;
|
||||
Uint32 color_counter_ = 0;
|
||||
// --- Variables de estado de la vista (layout y animación) ---
|
||||
SDL_FRect rect_{};
|
||||
SDL_FRect border_rect_{};
|
||||
size_t width_ = 0;
|
||||
size_t height_ = 0;
|
||||
size_t options_height_ = 0;
|
||||
size_t options_padding_ = 0;
|
||||
size_t options_y_ = 0;
|
||||
size_t title_height_ = 0;
|
||||
size_t title_padding_ = 0;
|
||||
size_t upper_height_ = 0;
|
||||
size_t lower_height_ = 0;
|
||||
size_t lower_padding_ = 0;
|
||||
Uint32 color_counter_ = 0;
|
||||
|
||||
// --- Variables para animación de resize ---
|
||||
SDL_FRect rect_anim_from_{};
|
||||
SDL_FRect rect_anim_to_{};
|
||||
int resize_anim_step_ = 0;
|
||||
int resize_anim_steps_ = 8;
|
||||
bool resizing_ = false;
|
||||
// --- Variables para animación de resize ---
|
||||
SDL_FRect rect_anim_from_{};
|
||||
SDL_FRect rect_anim_to_{};
|
||||
int resize_anim_step_ = 0;
|
||||
int resize_anim_steps_ = 8;
|
||||
bool resizing_ = false;
|
||||
|
||||
// --- Anchos precalculados ---
|
||||
int group_menu_widths_[5]{};
|
||||
// --- Anchos precalculados ---
|
||||
std::array<int, 5> group_menu_widths_ = {};
|
||||
|
||||
// --- Métodos privados de la vista ---
|
||||
void setAnchors(const ServiceMenu *menu_state);
|
||||
auto calculateNewRect(const ServiceMenu *menu_state) -> SDL_FRect;
|
||||
void resize(const ServiceMenu *menu_state);
|
||||
void setSize(const ServiceMenu *menu_state);
|
||||
void updateResizeAnimation();
|
||||
void precalculateMenuWidths(const std::vector<std::unique_ptr<MenuOption>> &all_options, const ServiceMenu *menu_state);
|
||||
[[nodiscard]] auto getMenuWidthForGroup(ServiceMenu::SettingsGroup group) const -> int;
|
||||
auto getAnimatedSelectedColor() -> Color;
|
||||
void updateColorCounter();
|
||||
auto setRect(SDL_FRect rect) -> SDL_FRect;
|
||||
// --- Métodos privados de la vista ---
|
||||
void setAnchors(const ServiceMenu *menu_state);
|
||||
auto calculateNewRect(const ServiceMenu *menu_state) -> SDL_FRect;
|
||||
void resize(const ServiceMenu *menu_state);
|
||||
void setSize(const ServiceMenu *menu_state);
|
||||
void updateResizeAnimation();
|
||||
void precalculateMenuWidths(const std::vector<std::unique_ptr<MenuOption>> &all_options, const ServiceMenu *menu_state);
|
||||
[[nodiscard]] auto getMenuWidthForGroup(ServiceMenu::SettingsGroup group) const -> int;
|
||||
auto getAnimatedSelectedColor() -> Color;
|
||||
void updateColorCounter();
|
||||
auto setRect(SDL_FRect rect) -> SDL_FRect;
|
||||
};
|
||||
|
||||
@@ -31,10 +31,14 @@ class ServiceMenu {
|
||||
static constexpr size_t MIN_WIDTH = 240;
|
||||
static constexpr size_t MIN_GAP_OPTION_VALUE = 30;
|
||||
|
||||
// --- Métodos de singleton ---
|
||||
static void init();
|
||||
static void destroy();
|
||||
static auto get() -> ServiceMenu *;
|
||||
ServiceMenu(const ServiceMenu &) = delete;
|
||||
auto operator=(const ServiceMenu &) -> ServiceMenu & = delete;
|
||||
|
||||
// --- Métodos principales ---
|
||||
void toggle();
|
||||
void render();
|
||||
void update();
|
||||
@@ -96,10 +100,10 @@ private:
|
||||
[[nodiscard]] auto settingsGroupToString(SettingsGroup group) const -> std::string;
|
||||
void setHiddenOptions();
|
||||
|
||||
// --- Singleton ---
|
||||
// --- Constructores y destructor privados (singleton) ---
|
||||
ServiceMenu();
|
||||
~ServiceMenu() = default;
|
||||
ServiceMenu(const ServiceMenu &) = delete;
|
||||
auto operator=(const ServiceMenu &) -> ServiceMenu & = delete;
|
||||
|
||||
// --- Instancia singleton ---
|
||||
static ServiceMenu *instance;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user