clang-tidy
This commit is contained in:
@@ -22,9 +22,7 @@ auto ActionListOption::getMaxValueWidth(Text* text) const -> int {
|
||||
int max_width = 0;
|
||||
for (const auto& option : options_) {
|
||||
int width = text->length(option, -2);
|
||||
if (width > max_width) {
|
||||
max_width = width;
|
||||
}
|
||||
max_width = std::max(width, max_width);
|
||||
}
|
||||
return max_width;
|
||||
}
|
||||
@@ -66,7 +64,7 @@ auto ActionListOption::findCurrentIndex() const -> size_t {
|
||||
}
|
||||
|
||||
const std::string CURRENT_VALUE = value_getter_();
|
||||
auto it = std::find(options_.begin(), options_.end(), CURRENT_VALUE);
|
||||
auto it = std::ranges::find(options_, CURRENT_VALUE);
|
||||
|
||||
if (it != options_.end()) {
|
||||
return static_cast<size_t>(std::distance(options_.begin(), it));
|
||||
|
||||
@@ -75,7 +75,7 @@ void MenuRenderer::render(const ServiceMenu *menu_state) {
|
||||
if (shouldShowContent()) {
|
||||
// Dibuja el título
|
||||
float y = rect_.y + title_padding_;
|
||||
title_text_->writeDX(Text::COLOR | Text::CENTER, rect_.x + rect_.w / 2.0F, y, menu_state->getTitle(), -4, param.service_menu.title_color);
|
||||
title_text_->writeDX(Text::COLOR | Text::CENTER, rect_.x + (rect_.w / 2.0F), y, menu_state->getTitle(), -4, param.service_menu.title_color);
|
||||
|
||||
// Dibuja la línea separadora
|
||||
y = rect_.y + upper_height_;
|
||||
@@ -99,7 +99,7 @@ void MenuRenderer::render(const ServiceMenu *menu_state) {
|
||||
} else {
|
||||
const int AVAILABLE_WIDTH = rect_.w - (ServiceMenu::OPTIONS_HORIZONTAL_PADDING * 2);
|
||||
std::string truncated_caption = getTruncatedValue(option_pairs.at(i).first, AVAILABLE_WIDTH);
|
||||
element_text_->writeDX(Text::CENTER | Text::COLOR, rect_.x + rect_.w / 2.0F, y, truncated_caption, -2, current_color);
|
||||
element_text_->writeDX(Text::CENTER | Text::COLOR, rect_.x + (rect_.w / 2.0F), y, truncated_caption, -2, current_color);
|
||||
}
|
||||
y += options_height_ + options_padding_;
|
||||
}
|
||||
@@ -232,7 +232,7 @@ void MenuRenderer::setSize(const ServiceMenu *menu_state) {
|
||||
|
||||
updatePosition();
|
||||
options_y_ = rect_.y + upper_height_ + lower_padding_;
|
||||
border_rect_ = {rect_.x - 1, rect_.y + 1, rect_.w + 2, rect_.h - 2};
|
||||
border_rect_ = {.x = rect_.x - 1, .y = rect_.y + 1, .w = rect_.w + 2, .h = rect_.h - 2};
|
||||
}
|
||||
|
||||
// --- Métodos de animación y posición ---
|
||||
@@ -305,7 +305,7 @@ void MenuRenderer::updatePosition() {
|
||||
break;
|
||||
}
|
||||
// Actualizar el rectángulo del borde junto con el principal
|
||||
border_rect_ = {rect_.x - 1, rect_.y + 1, rect_.w + 2, rect_.h - 2};
|
||||
border_rect_ = {.x = rect_.x - 1, .y = rect_.y + 1, .w = rect_.w + 2, .h = rect_.h - 2};
|
||||
}
|
||||
|
||||
// Resto de métodos (sin cambios significativos)
|
||||
@@ -349,7 +349,7 @@ auto MenuRenderer::getAnimatedSelectedColor() const -> Color {
|
||||
return color_cycle_.at(color_counter_ % color_cycle_.size());
|
||||
}
|
||||
auto MenuRenderer::setRect(SDL_FRect rect) -> SDL_FRect {
|
||||
border_rect_ = {rect.x - 1, rect.y + 1, rect.w + 2, rect.h - 2};
|
||||
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 {
|
||||
@@ -404,5 +404,5 @@ auto MenuRenderer::getTruncatedValue(const std::string &value, int available_wid
|
||||
return truncated;
|
||||
}
|
||||
|
||||
auto MenuRenderer::easeOut(float t) -> float { return 1.0F - (1.0F - t) * (1.0F - t); }
|
||||
auto MenuRenderer::easeOut(float t) -> float { return 1.0F - ((1.0F - t) * (1.0F - t)); }
|
||||
auto MenuRenderer::shouldShowContent() const -> bool { return !show_hide_animation_.active; }
|
||||
@@ -164,8 +164,7 @@ void Notifier::show(std::vector<std::string> texts, int icon, const std::string&
|
||||
}
|
||||
|
||||
// Elimina las cadenas vacías
|
||||
texts.erase(std::remove_if(texts.begin(), texts.end(), [](const std::string& s) { return s.empty(); }),
|
||||
texts.end());
|
||||
texts.erase(std::ranges::remove_if(texts, [](const std::string& s) { return s.empty(); }).begin(), texts.end());
|
||||
|
||||
// Encuentra la cadena más larga
|
||||
std::string longest;
|
||||
@@ -224,7 +223,7 @@ void Notifier::show(std::vector<std::string> texts, int icon, const std::string&
|
||||
n.texts = texts;
|
||||
n.shape = SHAPE;
|
||||
const float POS_Y = offset + (param.notification.pos_v == Position::TOP ? -TRAVEL_DIST : TRAVEL_DIST);
|
||||
n.rect = {desp_h, POS_Y, WIDTH, HEIGHT};
|
||||
n.rect = {.x = desp_h, .y = POS_Y, .w = WIDTH, .h = HEIGHT};
|
||||
|
||||
// Crea la textura
|
||||
n.texture = std::make_shared<Texture>(renderer_);
|
||||
@@ -238,16 +237,16 @@ void Notifier::show(std::vector<std::string> texts, int icon, const std::string&
|
||||
SDL_SetRenderDrawColor(renderer_, bg_color_.r, bg_color_.g, bg_color_.b, 255);
|
||||
SDL_FRect rect;
|
||||
if (SHAPE == Shape::ROUNDED) {
|
||||
rect = {4, 0, WIDTH - (4 * 2), HEIGHT};
|
||||
rect = {.x = 4, .y = 0, .w = WIDTH - (4 * 2), .h = HEIGHT};
|
||||
SDL_RenderFillRect(renderer_, &rect);
|
||||
|
||||
rect = {4 / 2, 1, WIDTH - 4, HEIGHT - 2};
|
||||
rect = {.x = 4 / 2, .y = 1, .w = WIDTH - 4, .h = HEIGHT - 2};
|
||||
SDL_RenderFillRect(renderer_, &rect);
|
||||
|
||||
rect = {1, 4 / 2, WIDTH - 2, HEIGHT - 4};
|
||||
rect = {.x = 1, .y = 4 / 2, .w = WIDTH - 2, .h = HEIGHT - 4};
|
||||
SDL_RenderFillRect(renderer_, &rect);
|
||||
|
||||
rect = {0, 4, WIDTH, HEIGHT - (4 * 2)};
|
||||
rect = {.x = 0, .y = 4, .w = WIDTH, .h = HEIGHT - (4 * 2)};
|
||||
SDL_RenderFillRect(renderer_, &rect);
|
||||
}
|
||||
|
||||
@@ -271,7 +270,7 @@ void Notifier::show(std::vector<std::string> texts, int icon, const std::string&
|
||||
const Color COLOR{255, 255, 255};
|
||||
int iterator = 0;
|
||||
for (const auto& text : texts) {
|
||||
text_->writeColored(PADDING_IN_H + ICON_SPACE, PADDING_IN_V + iterator * (text_->getCharacterSize() + 1), text, COLOR);
|
||||
text_->writeColored(PADDING_IN_H + ICON_SPACE, PADDING_IN_V + (iterator * (text_->getCharacterSize() + 1)), text, COLOR);
|
||||
++iterator;
|
||||
}
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ class Notifier {
|
||||
|
||||
// --- Constructores y destructor privados (singleton) ---
|
||||
Notifier(const std::string &icon_file, std::shared_ptr<Text> text); // Constructor privado
|
||||
~Notifier() = default; // Destructor privado
|
||||
~Notifier() = default; // Destructor privado
|
||||
|
||||
// --- Instancia singleton ---
|
||||
static Notifier *instance; // Instancia única de Notifier
|
||||
|
||||
@@ -43,7 +43,7 @@ void WindowMessage::render() {
|
||||
std::string visible_title = getTruncatedText(title_, available_width);
|
||||
if (!visible_title.empty()) {
|
||||
text_renderer_->writeStyle(
|
||||
rect_.x + rect_.w / 2.0F,
|
||||
rect_.x + (rect_.w / 2.0F),
|
||||
current_y,
|
||||
visible_title,
|
||||
title_style_);
|
||||
@@ -55,9 +55,9 @@ void WindowMessage::render() {
|
||||
SDL_SetRenderDrawColor(renderer, config_.border_color.r, config_.border_color.g, config_.border_color.b, config_.border_color.a);
|
||||
SDL_RenderLine(renderer,
|
||||
rect_.x + config_.padding,
|
||||
current_y - config_.title_separator_spacing / 2.0F,
|
||||
current_y - (config_.title_separator_spacing / 2.0F),
|
||||
rect_.x + rect_.w - config_.padding,
|
||||
current_y - config_.title_separator_spacing / 2.0F);
|
||||
current_y - (config_.title_separator_spacing / 2.0F));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ void WindowMessage::render() {
|
||||
std::string visible_text = getTruncatedText(text, available_width);
|
||||
if (!visible_text.empty()) {
|
||||
text_renderer_->writeStyle(
|
||||
rect_.x + rect_.w / 2.0F,
|
||||
rect_.x + (rect_.w / 2.0F),
|
||||
current_y,
|
||||
visible_text,
|
||||
text_style_);
|
||||
@@ -147,7 +147,7 @@ void WindowMessage::clearTexts() {
|
||||
}
|
||||
|
||||
void WindowMessage::setPosition(float x, float y, PositionMode mode) {
|
||||
anchor_ = {x, y};
|
||||
anchor_ = {.x = x, .y = y};
|
||||
position_mode_ = mode;
|
||||
updatePosition();
|
||||
}
|
||||
@@ -373,7 +373,7 @@ auto WindowMessage::shouldShowContent() const -> bool {
|
||||
|
||||
auto WindowMessage::easeOut(float t) -> float {
|
||||
// Función de suavizado ease-out cuadrática
|
||||
return 1.0F - (1.0F - t) * (1.0F - t);
|
||||
return 1.0F - ((1.0F - t) * (1.0F - t));
|
||||
}
|
||||
|
||||
auto WindowMessage::getAvailableTextWidth() const -> float {
|
||||
|
||||
Reference in New Issue
Block a user