clang-tidy
This commit is contained in:
@@ -9,11 +9,11 @@
|
||||
|
||||
WindowMessage::WindowMessage(
|
||||
std::shared_ptr<Text> text_renderer,
|
||||
const std::string& title,
|
||||
std::string title,
|
||||
const Config& config)
|
||||
: text_renderer_(std::move(text_renderer)),
|
||||
config_(config),
|
||||
title_(title),
|
||||
title_(std::move(title)),
|
||||
title_style_(Text::CENTER | Text::COLOR, config_.title_color, config_.title_color, 0, -2),
|
||||
text_style_(Text::CENTER | Text::COLOR, config_.text_color, config_.text_color, 0, -2) {
|
||||
}
|
||||
@@ -45,7 +45,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_);
|
||||
@@ -58,9 +58,9 @@ void WindowMessage::render() {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +69,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_);
|
||||
@@ -84,7 +84,7 @@ void WindowMessage::update() {
|
||||
if (show_hide_animation_.active || resize_animation_.active) {
|
||||
// Aquí necesitarías el delta_time del game loop
|
||||
// Por ahora usamos un valor fijo, pero idealmente se pasaría como parámetro
|
||||
float delta_time = 1.0f / 60.0f; // Asumiendo 60 FPS
|
||||
float delta_time = 1.0F / 60.0F; // Asumiendo 60 FPS
|
||||
updateAnimation(delta_time);
|
||||
}
|
||||
}
|
||||
@@ -102,8 +102,8 @@ void WindowMessage::show() {
|
||||
|
||||
// Iniciar animación de mostrar desde tamaño 0
|
||||
show_hide_animation_.startShow(rect_.w, rect_.h);
|
||||
rect_.w = 0.0f;
|
||||
rect_.h = 0.0f;
|
||||
rect_.w = 0.0F;
|
||||
rect_.h = 0.0F;
|
||||
updatePosition(); // Reposicionar con tamaño 0
|
||||
}
|
||||
|
||||
@@ -150,8 +150,7 @@ void WindowMessage::clearTexts() {
|
||||
}
|
||||
|
||||
void WindowMessage::setPosition(float x, float y, PositionMode mode) {
|
||||
anchor_x_ = x;
|
||||
anchor_y_ = y;
|
||||
anchor_ = {x, y};
|
||||
position_mode_ = mode;
|
||||
updatePosition();
|
||||
}
|
||||
@@ -163,7 +162,7 @@ void WindowMessage::setSize(float width, float height) {
|
||||
}
|
||||
|
||||
void WindowMessage::centerOnScreen() {
|
||||
setPosition(getScreenWidth() / 2.0f, getScreenHeight() / 2.0f, PositionMode::CENTERED);
|
||||
setPosition(getScreenWidth() / 2.0F, getScreenHeight() / 2.0F, PositionMode::CENTERED);
|
||||
}
|
||||
|
||||
void WindowMessage::autoSize() {
|
||||
@@ -201,18 +200,18 @@ void WindowMessage::updateStyles() {
|
||||
void WindowMessage::updatePosition() {
|
||||
switch (position_mode_) {
|
||||
case PositionMode::CENTERED:
|
||||
rect_.x = anchor_x_ - rect_.w / 2.0f;
|
||||
rect_.y = anchor_y_ - rect_.h / 2.0f;
|
||||
rect_.x = anchor_.x- rect_.w / 2.0F;
|
||||
rect_.y = anchor_.y - rect_.h / 2.0F;
|
||||
break;
|
||||
case PositionMode::FIXED:
|
||||
rect_.x = anchor_x_;
|
||||
rect_.y = anchor_y_;
|
||||
rect_.x = anchor_.x;
|
||||
rect_.y = anchor_.y;
|
||||
break;
|
||||
}
|
||||
|
||||
// Asegurar que la ventana esté dentro de los límites de la pantalla
|
||||
rect_.x = std::max(0.0f, std::min(rect_.x, getScreenWidth() - rect_.w));
|
||||
rect_.y = std::max(0.0f, std::min(rect_.y, getScreenHeight() - rect_.h));
|
||||
rect_.x = std::max(0.0F, std::min(rect_.x, getScreenWidth() - rect_.w));
|
||||
rect_.y = std::max(0.0F, std::min(rect_.y, getScreenHeight() - rect_.h));
|
||||
}
|
||||
|
||||
void WindowMessage::ensureTextFits() {
|
||||
@@ -282,12 +281,12 @@ auto WindowMessage::calculateContentWidth() const -> float {
|
||||
return max_width;
|
||||
}
|
||||
|
||||
auto WindowMessage::getScreenWidth() const -> float {
|
||||
return static_cast<float>(param.game.width);
|
||||
auto WindowMessage::getScreenWidth() -> float {
|
||||
return param.game.width;
|
||||
}
|
||||
|
||||
auto WindowMessage::getScreenHeight() const -> float {
|
||||
return static_cast<float>(param.game.height);
|
||||
auto WindowMessage::getScreenHeight() -> float {
|
||||
return param.game.height;
|
||||
}
|
||||
|
||||
void WindowMessage::triggerAutoResize() {
|
||||
@@ -321,8 +320,8 @@ void WindowMessage::updateShowHideAnimation(float delta_time) {
|
||||
rect_.h = show_hide_animation_.target_height;
|
||||
} else if (show_hide_animation_.type == ShowHideAnimation::Type::HIDING) {
|
||||
// Ocultar completado
|
||||
rect_.w = 0.0f;
|
||||
rect_.h = 0.0f;
|
||||
rect_.w = 0.0F;
|
||||
rect_.h = 0.0F;
|
||||
visible_ = false;
|
||||
}
|
||||
|
||||
@@ -338,8 +337,8 @@ void WindowMessage::updateShowHideAnimation(float delta_time) {
|
||||
rect_.h = show_hide_animation_.target_height * progress;
|
||||
} else if (show_hide_animation_.type == ShowHideAnimation::Type::HIDING) {
|
||||
// Decrecer desde el tamaño actual hasta 0
|
||||
rect_.w = show_hide_animation_.target_width * (1.0f - progress);
|
||||
rect_.h = show_hide_animation_.target_height * (1.0f - progress);
|
||||
rect_.w = show_hide_animation_.target_width * (1.0F - progress);
|
||||
rect_.h = show_hide_animation_.target_height * (1.0F - progress);
|
||||
}
|
||||
|
||||
updatePosition(); // Mantener la posición centrada durante la animación
|
||||
@@ -377,14 +376,14 @@ auto WindowMessage::shouldShowContent() const -> bool {
|
||||
return !show_hide_animation_.active;
|
||||
}
|
||||
|
||||
auto WindowMessage::easeOut(float t) const -> float {
|
||||
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 {
|
||||
// Ancho disponible = ancho total - padding en ambos lados
|
||||
return rect_.w - (config_.padding * 2.0f);
|
||||
return rect_.w - (config_.padding * 2.0F);
|
||||
}
|
||||
|
||||
auto WindowMessage::getTruncatedText(const std::string& text, float available_width) const -> std::string {
|
||||
@@ -399,10 +398,10 @@ auto WindowMessage::getTruncatedText(const std::string& text, float available_wi
|
||||
}
|
||||
|
||||
// Si no hay espacio suficiente, devolver string vacío
|
||||
if (available_width < 10.0f) { // Mínimo espacio para al menos un carácter
|
||||
if (available_width < 10.0F) { // Mínimo espacio para al menos un carácter
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
// Buscar cuántos caracteres caben usando búsqueda binaria
|
||||
int left = 0;
|
||||
int right = text.length();
|
||||
|
||||
Reference in New Issue
Block a user