This commit is contained in:
2025-10-27 19:03:34 +01:00
parent 5f47c88770
commit 6af2d72ea8
2 changed files with 13 additions and 12 deletions

View File

@@ -31,7 +31,7 @@ void Notifier::destroy() {
}
// [SINGLETON] Con este método obtenemos el objeto y podemos trabajar con él
Notifier* Notifier::get() {
auto Notifier::get() -> Notifier* {
return Notifier::notifier;
}
@@ -168,7 +168,7 @@ void Notifier::show(std::vector<std::string> texts, NotificationText text_is, Ui
n.shape = SHAPE;
n.display_duration = display_duration;
const float Y_POS = OFFSET + -TRAVEL_DIST;
n.rect = {desp_h, Y_POS, WIDTH, HEIGHT};
n.rect = {.x = desp_h, .y = Y_POS, .w = WIDTH, .h = HEIGHT};
// Crea la textura
n.surface = std::make_shared<Surface>(WIDTH, HEIGHT);
@@ -180,16 +180,16 @@ void Notifier::show(std::vector<std::string> texts, NotificationText text_is, Ui
// Dibuja el fondo de la notificación
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};
n.surface->fillRect(&rect, bg_color_);
rect = {4 / 2, 1, WIDTH - 4, HEIGHT - 2};
rect = {.x = 4 / 2, .y = 1, .w = WIDTH - 4, .h = HEIGHT - 2};
n.surface->fillRect(&rect, bg_color_);
rect = {1, 4 / 2, WIDTH - 2, HEIGHT - 4};
rect = {.x = 1, .y = 4 / 2, .w = WIDTH - 2, .h = HEIGHT - 4};
n.surface->fillRect(&rect, bg_color_);
rect = {0, 4, WIDTH, HEIGHT - (4 * 2)};
rect = {.x = 0, .y = 4, .w = WIDTH, .h = HEIGHT - (4 * 2)};
n.surface->fillRect(&rect, bg_color_);
}
@@ -208,7 +208,7 @@ void Notifier::show(std::vector<std::string> texts, NotificationText text_is, Ui
}
// Escribe el texto de la notificación
const Uint8 COLOR = static_cast<Uint8>(PaletteColor::WHITE);
const auto COLOR = static_cast<Uint8>(PaletteColor::WHITE);
int iterator = 0;
for (const auto& text : texts) {
switch (text_is) {
@@ -239,7 +239,7 @@ void Notifier::show(std::vector<std::string> texts, NotificationText text_is, Ui
}
// Indica si hay notificaciones activas
bool Notifier::isActive() { return !notifications_.empty(); }
auto Notifier::isActive() -> bool { return !notifications_.empty(); }
// Finaliza y elimnina todas las notificaciones activas
void Notifier::clearNotifications() {
@@ -253,8 +253,9 @@ void Notifier::clearNotifications() {
}
// Obtiene los códigos de las notificaciones
std::vector<std::string> Notifier::getCodes() {
auto Notifier::getCodes() -> std::vector<std::string> {
std::vector<std::string> codes;
codes.reserve(notifications_.size());
for (const auto& notification : notifications_) {
codes.emplace_back(notification.code);
}

View File

@@ -91,7 +91,7 @@ class Notifier {
static void destroy();
// [SINGLETON] Con este método obtenemos el objeto y podemos trabajar con él
static Notifier* get();
static auto get() -> Notifier*;
// Dibuja las notificaciones por pantalla
void render();
@@ -103,8 +103,8 @@ class Notifier {
void show(std::vector<std::string> texts, NotificationText text_is = NotificationText::LEFT, Uint32 display_duration = DEFAULT_NOTIFICATION_DURATION, int icon = -1, bool can_be_removed = true, const std::string& code = std::string());
// Indica si hay notificaciones activas
bool isActive();
auto isActive() -> bool;
// Obtiene los códigos de las notificaciones
std::vector<std::string> getCodes();
auto getCodes() -> std::vector<std::string>;
};