corregit menu_renderer.cpp, de vegades es modificava el ample del menu al canviar les opcions
This commit is contained in:
@@ -324,8 +324,17 @@ void MenuRenderer::precalculateMenuWidths(const std::vector<std::unique_ptr<Menu
|
||||
}
|
||||
max_option_width = std::max(max_option_width, element_text_->length(option->getCaption(), -2));
|
||||
if (menu_state->getCurrentGroupAlignment() == ServiceMenu::GroupAlignment::LEFT) {
|
||||
// Usar getMaxValueWidth() para considerar TODOS los valores posibles de la opción
|
||||
int option_max_value_width = option->getMaxValueWidth(element_text_.get());
|
||||
int max_available_value_width = static_cast<int>(max_menu_width_) - max_option_width - (ServiceMenu::OPTIONS_HORIZONTAL_PADDING * 2) - ServiceMenu::MIN_GAP_OPTION_VALUE;
|
||||
max_value_width = std::max(max_value_width, getTruncatedValueWidth(option->getValueAsString(), max_available_value_width));
|
||||
|
||||
if (option_max_value_width <= max_available_value_width) {
|
||||
// Si el valor más largo cabe, usar su ancho real
|
||||
max_value_width = std::max(max_value_width, option_max_value_width);
|
||||
} else {
|
||||
// Si no cabe, usar el ancho disponible (será truncado)
|
||||
max_value_width = std::max(max_value_width, max_available_value_width);
|
||||
}
|
||||
}
|
||||
}
|
||||
size_t total_width = max_option_width + (ServiceMenu::OPTIONS_HORIZONTAL_PADDING * 2);
|
||||
|
||||
Reference in New Issue
Block a user