From cd5a66c1d1f7157fa2c19823e09a490f6b07a744 Mon Sep 17 00:00:00 2001 From: Cvolton Date: Thu, 15 Aug 2024 15:43:45 +0200 Subject: [PATCH] add Notification::Cancel --- loader/include/Geode/ui/Notification.hpp | 6 ++++++ loader/src/ui/nodes/Notification.cpp | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/loader/include/Geode/ui/Notification.hpp b/loader/include/Geode/ui/Notification.hpp index 1e09d8ba..0efa65c8 100644 --- a/loader/include/Geode/ui/Notification.hpp +++ b/loader/include/Geode/ui/Notification.hpp @@ -93,5 +93,11 @@ namespace geode { * to prematurily hide the notification */ void hide(); + + /** + * Cancels the showing of the notification if it's in the queue. + * Otherwise, it hides the notification if it's currently showing. + */ + void cancel(); }; } diff --git a/loader/src/ui/nodes/Notification.cpp b/loader/src/ui/nodes/Notification.cpp index 3bd57bd0..0aa0579c 100644 --- a/loader/src/ui/nodes/Notification.cpp +++ b/loader/src/ui/nodes/Notification.cpp @@ -211,3 +211,11 @@ void Notification::hide() { nullptr )); } + +void Notification::cancel() { + if(m_pParent) return this->hide(); + + if (s_queue->containsObject(this)) { + s_queue->removeObject(this); + } +} \ No newline at end of file