ServiceMenu: animacions acabades
This commit is contained in:
@@ -523,34 +523,34 @@ void ServiceMenu::precalculateMenuWidths()
|
|||||||
// Para cada grupo
|
// Para cada grupo
|
||||||
for (int group = 0; group < 5; ++group) {
|
for (int group = 0; group < 5; ++group) {
|
||||||
SettingsGroup sg = static_cast<SettingsGroup>(group);
|
SettingsGroup sg = static_cast<SettingsGroup>(group);
|
||||||
int max_width = MIN_WIDTH_;
|
int max_option_width = 0;
|
||||||
|
int max_value_width = 0;
|
||||||
for (const auto &option : options_) {
|
for (const auto &option : options_) {
|
||||||
if (option.group != sg) continue;
|
if (option.group != sg) continue;
|
||||||
int option_width = element_text_->lenght(option.caption);
|
// Opción más larga
|
||||||
int value_width = 0;
|
max_option_width = std::max(max_option_width, element_text_->lenght(option.caption, -2));
|
||||||
// Calcular el valor más ancho posible para esta opción
|
// Valor más largo de todos los posibles valores de todas las opciones
|
||||||
switch (option.type) {
|
switch (option.type) {
|
||||||
case ValueType::BOOL:
|
case ValueType::BOOL:
|
||||||
value_width = std::max(element_text_->lenght(lang::getText("[SERVICE_MENU] ON")),
|
max_value_width = std::max({max_value_width,
|
||||||
element_text_->lenght(lang::getText("[SERVICE_MENU] OFF")));
|
element_text_->lenght(lang::getText("[SERVICE_MENU] ON"), -2),
|
||||||
|
element_text_->lenght(lang::getText("[SERVICE_MENU] OFF"), -2)});
|
||||||
break;
|
break;
|
||||||
case ValueType::INT:
|
case ValueType::INT:
|
||||||
// Considera el valor máximo y mínimo como strings
|
max_value_width = std::max({max_value_width,
|
||||||
value_width = std::max(
|
element_text_->lenght(std::to_string(option.min_value), -2),
|
||||||
element_text_->lenght(std::to_string(option.min_value)),
|
element_text_->lenght(std::to_string(option.max_value), -2)});
|
||||||
element_text_->lenght(std::to_string(option.max_value)));
|
|
||||||
break;
|
break;
|
||||||
case ValueType::LIST:
|
case ValueType::LIST:
|
||||||
for (const auto &val : option.value_list)
|
for (const auto &val : option.value_list)
|
||||||
value_width = std::max(value_width, element_text_->lenght(val));
|
max_value_width = std::max(max_value_width, element_text_->lenght(val, -2));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
value_width = 0;
|
break;
|
||||||
}
|
}
|
||||||
int total_width = option_width + MIN_GAP_OPTION_VALUE_ + value_width;
|
|
||||||
max_width = std::max(max_width, total_width);
|
|
||||||
}
|
}
|
||||||
group_menu_widths_[group] = max_width;
|
size_t total_width = max_option_width + MIN_GAP_OPTION_VALUE_ + max_value_width + OPTIONS_HORIZONTAL_PADDING_*2;
|
||||||
|
group_menu_widths_[group] = std::max(MIN_WIDTH_, total_width);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ private:
|
|||||||
static constexpr const char *MENU_SOUND_ = "clock.wav"; // Sonido al navegar por el menú
|
static constexpr const char *MENU_SOUND_ = "clock.wav"; // Sonido al navegar por el menú
|
||||||
static constexpr size_t OPTIONS_HORIZONTAL_PADDING_ = 20; // Relleno horizontal de las opciones
|
static constexpr size_t OPTIONS_HORIZONTAL_PADDING_ = 20; // Relleno horizontal de las opciones
|
||||||
static constexpr size_t MIN_WIDTH_ = 240; // Anchura mínima del menu
|
static constexpr size_t MIN_WIDTH_ = 240; // Anchura mínima del menu
|
||||||
static constexpr size_t MIN_GAP_OPTION_VALUE_ = 20; // Espacio mínimo entre una opción y su valor
|
static constexpr size_t MIN_GAP_OPTION_VALUE_ = 30; // Espacio mínimo entre una opción y su valor
|
||||||
|
|
||||||
// --- Enumeraciones internas ---
|
// --- Enumeraciones internas ---
|
||||||
enum class Aspect
|
enum class Aspect
|
||||||
@@ -244,9 +244,8 @@ private:
|
|||||||
void updateResizeAnimation();
|
void updateResizeAnimation();
|
||||||
|
|
||||||
// --- Métodos internos: Cálculo de anchos ---
|
// --- Métodos internos: Cálculo de anchos ---
|
||||||
void precalculateMenuWidths();
|
void precalculateMenuWidths();
|
||||||
int getMenuWidthForGroup(SettingsGroup group) const;
|
int getMenuWidthForGroup(SettingsGroup group) const;
|
||||||
|
|
||||||
|
|
||||||
// --- Patrón Singleton ---
|
// --- Patrón Singleton ---
|
||||||
ServiceMenu(); // Constructor privado
|
ServiceMenu(); // Constructor privado
|
||||||
|
|||||||
Reference in New Issue
Block a user