ServiceMenu: animacions acabades
This commit is contained in:
@@ -523,34 +523,34 @@ void ServiceMenu::precalculateMenuWidths()
|
||||
// Para cada grupo
|
||||
for (int group = 0; group < 5; ++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_) {
|
||||
if (option.group != sg) continue;
|
||||
int option_width = element_text_->lenght(option.caption);
|
||||
int value_width = 0;
|
||||
// Calcular el valor más ancho posible para esta opción
|
||||
// Opción más larga
|
||||
max_option_width = std::max(max_option_width, element_text_->lenght(option.caption, -2));
|
||||
// Valor más largo de todos los posibles valores de todas las opciones
|
||||
switch (option.type) {
|
||||
case ValueType::BOOL:
|
||||
value_width = std::max(element_text_->lenght(lang::getText("[SERVICE_MENU] ON")),
|
||||
element_text_->lenght(lang::getText("[SERVICE_MENU] OFF")));
|
||||
max_value_width = std::max({max_value_width,
|
||||
element_text_->lenght(lang::getText("[SERVICE_MENU] ON"), -2),
|
||||
element_text_->lenght(lang::getText("[SERVICE_MENU] OFF"), -2)});
|
||||
break;
|
||||
case ValueType::INT:
|
||||
// Considera el valor máximo y mínimo como strings
|
||||
value_width = std::max(
|
||||
element_text_->lenght(std::to_string(option.min_value)),
|
||||
element_text_->lenght(std::to_string(option.max_value)));
|
||||
max_value_width = std::max({max_value_width,
|
||||
element_text_->lenght(std::to_string(option.min_value), -2),
|
||||
element_text_->lenght(std::to_string(option.max_value), -2)});
|
||||
break;
|
||||
case ValueType::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;
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user