[UI] Host Notification: Replace previous notification in case of new one

This commit is contained in:
Gliniak
2024-08-27 20:48:22 +02:00
parent ee210db096
commit 9c8a575b76
5 changed files with 58 additions and 25 deletions

View File

@@ -25,7 +25,7 @@ ImGuiHostNotification::ImGuiHostNotification(ui::ImGuiDrawer* imgui_drawer,
uint8_t position_id)
: ImGuiNotification(imgui_drawer, NotificationType::Host, title,
description, user_index, position_id) {
SetCreationTime(Clock::QueryHostUptimeMillis());
SetCreationTime(Clock::QueryHostUptimeMillis() + notification_initial_delay);
imgui_drawer->AddNotification(this);
}
@@ -39,11 +39,16 @@ const ImVec2 ImGuiHostNotification::CalculateNotificationSize(ImVec2 text_size,
}
void HostNotificationWindow::OnDraw(ImGuiIO& io) {
if (IsNotificationClosingTime()) {
if (IsNotificationClosingTime() || IsMarkedForDeletion()) {
delete this;
return;
}
// Adding 200ms of delay in case of notification spam.
if (Clock::QueryHostUptimeMillis() < GetCreationTime()) {
return;
}
const std::string longest_notification_text_line =
GetTitle().size() > GetDescription().size() ? GetTitle().c_str()
: GetDescription().c_str();