neteja cppcheck (105 → 0)
This commit is contained in:
@@ -381,9 +381,7 @@ void MenuRenderer::updatePosition() {
|
||||
// Resto de métodos (sin cambios significativos)
|
||||
|
||||
void MenuRenderer::precalculateMenuWidths(const std::vector<std::unique_ptr<MenuOption>>& all_options, const ServiceMenu* menu_state) { // NOLINT(readability-named-parameter)
|
||||
for (int& w : group_menu_widths_) {
|
||||
w = ServiceMenu::MIN_WIDTH;
|
||||
}
|
||||
std::ranges::fill(group_menu_widths_, ServiceMenu::MIN_WIDTH);
|
||||
for (int group = 0; group < 5; ++group) {
|
||||
auto sg = static_cast<ServiceMenu::SettingsGroup>(group);
|
||||
int max_option_width = 0;
|
||||
@@ -433,33 +431,6 @@ auto MenuRenderer::getAnimatedSelectedColor() const -> Color {
|
||||
static auto color_cycle_ = Colors::generateMirroredCycle(param.service_menu.selected_color, ColorCycleStyle::HUE_WAVE);
|
||||
return color_cycle_.at(color_counter_ % color_cycle_.size());
|
||||
}
|
||||
auto MenuRenderer::setRect(SDL_FRect rect) -> SDL_FRect {
|
||||
border_rect_ = {.x = rect.x - 1, .y = rect.y + 1, .w = rect.w + 2, .h = rect.h - 2};
|
||||
return rect;
|
||||
}
|
||||
auto MenuRenderer::getTruncatedValueWidth(const std::string& value, int available_width) const -> int {
|
||||
int value_width = element_text_->length(value, -2);
|
||||
if (value_width <= available_width) {
|
||||
return value_width;
|
||||
}
|
||||
|
||||
// Calculamos cuántos caracteres podemos mostrar más los puntos suspensivos
|
||||
// Estimamos el ancho de los puntos suspensivos como 3 caracteres promedio
|
||||
int ellipsis_width = element_text_->length("...", -2);
|
||||
int available_for_text = available_width - ellipsis_width;
|
||||
|
||||
if (available_for_text <= 0) {
|
||||
return ellipsis_width; // Solo mostramos los puntos suspensivos
|
||||
}
|
||||
|
||||
// Calculamos aproximadamente cuántos caracteres caben
|
||||
float char_width = static_cast<float>(value_width) / value.length();
|
||||
auto max_chars = static_cast<size_t>(available_for_text / char_width);
|
||||
|
||||
// Verificamos el ancho real del texto truncado
|
||||
std::string truncated = truncateWithEllipsis(value, max_chars);
|
||||
return element_text_->length(truncated, -2);
|
||||
}
|
||||
|
||||
auto MenuRenderer::getTruncatedValue(const std::string& value, int available_width) const -> std::string {
|
||||
int value_width = element_text_->length(value, -2);
|
||||
|
||||
Reference in New Issue
Block a user