claude: arreglos d'estil
This commit is contained in:
@@ -11,21 +11,22 @@
|
||||
#include "text.h" // Para Text
|
||||
#include "ui/service_menu.h" // Para ServiceMenu
|
||||
|
||||
// --- Interfaz Base para todas las Opciones del Menú ---
|
||||
|
||||
// --- Clase MenuOption: interfaz base para todas las opciones del menú ---
|
||||
class MenuOption {
|
||||
public:
|
||||
// --- Enums ---
|
||||
enum class Behavior {
|
||||
ADJUST, // Solo puede ajustar valor (como IntOption, BoolOption, ListOption)
|
||||
SELECT, // Solo puede ejecutar acción (como ActionOption, FolderOption)
|
||||
BOTH // Puede tanto ajustar como ejecutar acción (como ActionListOption)
|
||||
};
|
||||
|
||||
// --- Constructor y destructor ---
|
||||
MenuOption(std::string caption, ServiceMenu::SettingsGroup group, bool hidden = false)
|
||||
: caption_(std::move(caption)), group_(group), hidden_(hidden) {}
|
||||
|
||||
virtual ~MenuOption() = default;
|
||||
|
||||
// --- Getters ---
|
||||
[[nodiscard]] auto getCaption() const -> const std::string & { return caption_; }
|
||||
[[nodiscard]] auto getGroup() const -> ServiceMenu::SettingsGroup { return group_; }
|
||||
[[nodiscard]] auto isHidden() const -> bool { return hidden_; }
|
||||
@@ -37,10 +38,10 @@ class MenuOption {
|
||||
[[nodiscard]] virtual auto getTargetGroup() const -> ServiceMenu::SettingsGroup { return ServiceMenu::SettingsGroup::MAIN; }
|
||||
virtual void executeAction() {}
|
||||
|
||||
// Método virtual para que cada opción calcule el ancho de su valor más largo.
|
||||
virtual auto getMaxValueWidth(Text *text_renderer) const -> int { return 0; }
|
||||
virtual auto getMaxValueWidth(Text *text_renderer) const -> int { return 0; } // Método virtual para que cada opción calcule el ancho de su valor más largo
|
||||
|
||||
protected:
|
||||
// --- Variables ---
|
||||
std::string caption_;
|
||||
ServiceMenu::SettingsGroup group_;
|
||||
bool hidden_;
|
||||
|
||||
@@ -16,13 +16,13 @@ class Texture;
|
||||
// --- Clase Notifier: gestiona las notificaciones en pantalla (singleton) ---
|
||||
class Notifier {
|
||||
public:
|
||||
// Posiciones de las notificaciones
|
||||
// --- Enums ---
|
||||
enum class Position {
|
||||
TOP,
|
||||
BOTTOM,
|
||||
LEFT,
|
||||
MIDDLE,
|
||||
RIGHT,
|
||||
TOP, // Parte superior
|
||||
BOTTOM, // Parte inferior
|
||||
LEFT, // Lado izquierdo
|
||||
MIDDLE, // Centro
|
||||
RIGHT, // Lado derecho
|
||||
};
|
||||
|
||||
// --- Métodos de singleton ---
|
||||
@@ -41,31 +41,31 @@ class Notifier {
|
||||
auto checkCode(const std::string &code) -> bool { return stringInVector(getCodes(), code); } // Comprueba si hay alguna notificación con un código concreto
|
||||
|
||||
private:
|
||||
// --- Tipos internos ---
|
||||
// --- Enums privados ---
|
||||
enum class State {
|
||||
RISING,
|
||||
STAY,
|
||||
VANISHING,
|
||||
FINISHED,
|
||||
RISING, // Apareciendo
|
||||
STAY, // Visible
|
||||
VANISHING, // Desapareciendo
|
||||
FINISHED, // Terminada
|
||||
};
|
||||
|
||||
enum class Shape {
|
||||
ROUNDED,
|
||||
SQUARED,
|
||||
ROUNDED, // Forma redondeada
|
||||
SQUARED, // Forma cuadrada
|
||||
};
|
||||
|
||||
// --- Estructura Notification ---
|
||||
// --- Estructuras privadas ---
|
||||
struct Notification {
|
||||
std::shared_ptr<Texture> texture; // Textura de la notificación
|
||||
std::shared_ptr<Sprite> sprite; // Sprite asociado
|
||||
std::vector<std::string> texts; // Textos a mostrar
|
||||
int counter{0}; // Contador de tiempo
|
||||
SDL_FRect rect; // Rectángulo de la notificación
|
||||
std::string code; // Código identificador de la notificación
|
||||
State state{State::RISING}; // Estado de la notificación
|
||||
Shape shape{Shape::SQUARED}; // Forma de la notificación
|
||||
SDL_FRect rect; // Rectángulo de la notificación
|
||||
int counter{0}; // Contador de tiempo
|
||||
int y{0}; // Posición vertical
|
||||
int travel_dist{0}; // Distancia a recorrer
|
||||
std::string code; // Código identificador de la notificación
|
||||
|
||||
// Constructor
|
||||
explicit Notification()
|
||||
@@ -78,9 +78,9 @@ class Notifier {
|
||||
std::shared_ptr<Text> text_; // Objeto para dibujar texto
|
||||
|
||||
// --- Variables de estado ---
|
||||
std::vector<Notification> notifications_; // Lista de notificaciones activas
|
||||
Color bg_color_; // Color de fondo de las notificaciones
|
||||
int wait_time_; // Tiempo que se ve la notificación
|
||||
std::vector<Notification> notifications_; // Lista de notificaciones activas
|
||||
bool stack_; // Indica si las notificaciones se apilan
|
||||
bool has_icons_; // Indica si el notificador tiene textura para iconos
|
||||
|
||||
@@ -97,10 +97,10 @@ class Notifier {
|
||||
static void moveNotificationVertically(Notification ¬ification, int direction); // Mueve verticalmente una notificación en una dirección dada (útil para animación en apilamiento)
|
||||
void transitionToStayState(int index); // Cambia el estado de una notificación de RISING a STAY cuando ha alcanzado su posición final
|
||||
|
||||
// --- Constructor y destructor ---
|
||||
// --- Constructores y destructor privados (singleton) ---
|
||||
Notifier(std::string icon_file, std::shared_ptr<Text> text); // Constructor privado
|
||||
~Notifier() = default; // Destructor privado
|
||||
|
||||
// --- Singleton ---
|
||||
static Notifier *instance;
|
||||
// --- Instancia singleton ---
|
||||
static Notifier *instance; // Instancia única de Notifier
|
||||
};
|
||||
Reference in New Issue
Block a user