Arreglos en la estructura i format del codi

This commit is contained in:
2025-03-01 22:36:22 +01:00
parent 360ebfd2e6
commit aca2be98af
27 changed files with 371 additions and 560 deletions

View File

@@ -35,8 +35,7 @@ Notifier *Notifier::get()
// Constructor
Notifier::Notifier(const std::string &icon_file, const std::string &text)
: renderer_(Screen::get()->getRenderer()),
icon_texture_(!icon_file.empty() ? Resource::get()->getTexture(icon_file) : nullptr),
: icon_texture_(!icon_file.empty() ? Resource::get()->getTexture(icon_file) : nullptr),
text_(Resource::get()->getText(text)),
bg_color_(options.notifications.color),
wait_time_(150),
@@ -84,8 +83,8 @@ void Notifier::update()
// Comprueba los estados
if (notifications_[i].state == NotificationStatus::RISING)
{
//const float step = ((float)notifications_[i].counter / notifications_[i].travel_dist);
//const int alpha = 255 * step;
// const float step = ((float)notifications_[i].counter / notifications_[i].travel_dist);
// const int alpha = 255 * step;
constexpr int ALPHA = 255;
if (options.notifications.getVerticalPosition() == NotificationPosition::TOP)
@@ -117,11 +116,10 @@ void Notifier::update()
else if (notifications_[i].state == NotificationStatus::VANISHING)
{
//const float step = (notifications_[i].counter / (float)notifications_[i].travel_dist);
//const int ALPHA = 255 * (1 - step);
// const float step = (notifications_[i].counter / (float)notifications_[i].travel_dist);
// const int ALPHA = 255 * (1 - step);
constexpr int ALPHA = 255;
if (options.notifications.getVerticalPosition() == NotificationPosition::TOP)
{
notifications_[i].rect.y--;
@@ -235,34 +233,34 @@ void Notifier::show(std::vector<std::string> texts, NotificationText text_is, in
n.rect = {desp_h, y_pos, width, height};
// Crea la textura
n.texture = std::make_shared<Texture>(renderer_);
n.texture = std::make_shared<Texture>(Screen::get()->getRenderer());
n.texture->createBlank(width, height, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET);
n.texture->setBlendMode(SDL_BLENDMODE_BLEND);
// Prepara para dibujar en la textura
n.texture->setAsRenderTarget(renderer_);
n.texture->setAsRenderTarget(Screen::get()->getRenderer());
// Dibuja el fondo de la notificación
SDL_SetRenderDrawColor(renderer_, bg_color_.r, bg_color_.g, bg_color_.b, 255);
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), bg_color_.r, bg_color_.g, bg_color_.b, 255);
SDL_Rect rect;
if (shape == NotificationShape::ROUNDED)
{
rect = {4, 0, width - (4 * 2), height};
SDL_RenderFillRect(renderer_, &rect);
SDL_RenderFillRect(Screen::get()->getRenderer(), &rect);
rect = {4 / 2, 1, width - 4, height - 2};
SDL_RenderFillRect(renderer_, &rect);
SDL_RenderFillRect(Screen::get()->getRenderer(), &rect);
rect = {1, 4 / 2, width - 2, height - 4};
SDL_RenderFillRect(renderer_, &rect);
SDL_RenderFillRect(Screen::get()->getRenderer(), &rect);
rect = {0, 4, width, height - (4 * 2)};
SDL_RenderFillRect(renderer_, &rect);
SDL_RenderFillRect(Screen::get()->getRenderer(), &rect);
}
else if (shape == NotificationShape::SQUARED)
{
SDL_RenderClear(renderer_);
SDL_RenderClear(Screen::get()->getRenderer());
}
// Dibuja el icono de la notificación
@@ -291,7 +289,7 @@ void Notifier::show(std::vector<std::string> texts, NotificationText text_is, in
}
// Deja de dibujar en la textura
SDL_SetRenderTarget(renderer_, nullptr);
SDL_SetRenderTarget(Screen::get()->getRenderer(), nullptr);
// Crea el sprite de la notificación
n.sprite = std::make_shared<Sprite>(n.texture, n.rect);