* Move the badge class to the next position. * @param feature Feature being used. * @param class_badge Class badge. * @param columns Maximum column number permitted. */
| 431 | * @param columns Maximum column number permitted. |
| 432 | */ |
| 433 | static void BadgeClassMoveNext(GrfSpecFeature feature, Badge &class_badge, uint columns) |
| 434 | { |
| 435 | GUIBadgeClasses gui_classes(feature); |
| 436 | if (gui_classes.GetClasses().empty()) return; |
| 437 | |
| 438 | auto config = GetBadgeClassConfiguration(feature); |
| 439 | auto it = std::ranges::find(config, class_badge.label, &BadgeClassConfigItem::label); |
| 440 | if (it == std::end(config)) return; |
| 441 | |
| 442 | auto pos_cur = std::ranges::find(gui_classes.GetClasses(), class_badge.class_index, &GUIBadgeClasses::Element::class_index); |
| 443 | if (std::next(pos_cur) == std::end(gui_classes.GetClasses())) { |
| 444 | if (it->column < columns - 1) ++it->column; |
| 445 | return; |
| 446 | } |
| 447 | |
| 448 | auto pos_next = std::ranges::find(config, std::next(pos_cur)->label, &BadgeClassConfigItem::label); |
| 449 | if (it->column < pos_next->column) { |
| 450 | ++it->column; |
| 451 | } else { |
| 452 | /* Rotate elements left so that it is placed after pos_next, maintaining order of non-visible elements. */ |
| 453 | std::rotate(it, std::next(it), std::next(pos_next)); |
| 454 | } |
| 455 | } |
| 456 | |
| 457 | /** |
| 458 | * Handle the badge configuration drop down selection. |
no test coverage detected