claude: treballant en el nou define_buttons

This commit is contained in:
2025-08-06 14:12:29 +02:00
parent 1224af2a9b
commit 6d36291f51
12 changed files with 650 additions and 190 deletions

View File

@@ -0,0 +1,84 @@
#pragma once
#include <SDL3/SDL.h>
#include <memory>
#include <string>
#include <vector>
#include "color.h"
class Text;
class WindowMessage {
public:
WindowMessage(
std::shared_ptr<Text> text_renderer,
const std::string& title = "",
const Color& bg_color = Color{40, 40, 60, 220},
const Color& border_color = Color{100, 100, 120, 255},
const Color& title_color = Color{255, 255, 255, 255},
const Color& text_color = Color{200, 200, 200, 255}
);
// Métodos principales
void render();
void update();
// Control de visibilidad
void show();
void hide();
[[nodiscard]] auto isVisible() const -> bool { return visible_; }
// Configuración de contenido
void setTitle(const std::string& title);
void setText(const std::string& text);
void setTexts(const std::vector<std::string>& texts);
void addText(const std::string& text);
void clearTexts();
// Configuración de posición y tamaño
void setPosition(float x, float y);
void setSize(float width, float height);
void centerOnScreen();
void autoSize(); // Ajusta automáticamente al contenido
// Configuración de colores
void setBackgroundColor(const Color& color) { bg_color_ = color; }
void setBorderColor(const Color& color) { border_color_ = color; }
void setTitleColor(const Color& color) { title_color_ = color; }
void setTextColor(const Color& color) { text_color_ = color; }
// Configuración de espaciado
void setPadding(float padding) { padding_ = padding; }
void setLineSpacing(float spacing) { line_spacing_ = spacing; }
// Getters
[[nodiscard]] auto getRect() const -> const SDL_FRect& { return rect_; }
private:
std::shared_ptr<Text> text_renderer_;
// Estado de visibilidad
bool visible_ = false;
// Contenido
std::string title_;
std::vector<std::string> texts_;
// Posición y tamaño
SDL_FRect rect_{0, 0, 300, 200};
float padding_ = 15.0f;
float line_spacing_ = 5.0f;
// Colores
Color bg_color_;
Color border_color_;
Color title_color_;
Color text_color_;
// Métodos privados
void calculateAutoSize();
[[nodiscard]] auto calculateContentHeight() const -> float;
[[nodiscard]] auto calculateContentWidth() const -> float;
};