From 87206cd6950869eeb0f1a7d968e083fdddd7c998 Mon Sep 17 00:00:00 2001 From: Vojtech Bubnik Date: Thu, 15 Oct 2020 09:20:05 +0200 Subject: [PATCH] NotificationManager documentation improvements --- src/slic3r/GUI/NotificationManager.cpp | 7 +++++-- src/slic3r/GUI/NotificationManager.hpp | 23 +++++++++++++++-------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/slic3r/GUI/NotificationManager.cpp b/src/slic3r/GUI/NotificationManager.cpp index 9e6438ca4..eb54d3f27 100644 --- a/src/slic3r/GUI/NotificationManager.cpp +++ b/src/slic3r/GUI/NotificationManager.cpp @@ -9,9 +9,11 @@ #include #include -#include +#include #include +#include + static constexpr float GAP_WIDTH = 10.0f; static constexpr float SPACE_RIGHT_PANEL = 10.0f; @@ -638,7 +640,8 @@ NotificationManager::NotificationManager(wxEvtHandler* evt_handler) : void NotificationManager::push_notification(const NotificationType type, GLCanvas3D& canvas, int timestamp) { auto it = std::find_if(basic_notifications.begin(), basic_notifications.end(), - boost::bind(&NotificationData::type, _1) == type); + std::bind(&NotificationData::type, _1) == type); + assert(it != basic_notifications.end()); if (it != basic_notifications.end()) push_notification_data( *it, canvas, timestamp); } diff --git a/src/slic3r/GUI/NotificationManager.hpp b/src/slic3r/GUI/NotificationManager.hpp index b5b2850f0..ea43523d5 100644 --- a/src/slic3r/GUI/NotificationManager.hpp +++ b/src/slic3r/GUI/NotificationManager.hpp @@ -72,14 +72,16 @@ public: NotificationManager(wxEvtHandler* evt_handler); - // only type means one of basic_notification (see below) + // Push a prefabricated notification from basic_notifications (see the table at the end of this file). void push_notification(const NotificationType type, GLCanvas3D& canvas, int timestamp = 0); - // only text means Undefined type + // Push a NotificationType::CustomNotification with NotificationLevel::RegularNotification and 10s fade out interval. void push_notification(const std::string& text, GLCanvas3D& canvas, int timestamp = 0); + // Push a NotificationType::CustomNotification with provided notification level and 10s for RegularNotification. + // ErrorNotification and ImportantNotification are never faded out. void push_notification(const std::string& text, NotificationLevel level, GLCanvas3D& canvas, int timestamp = 0); - // creates Slicing Error notification with custom text + // Creates Slicing Error notification with a custom text and no fade out. void push_slicing_error_notification(const std::string& text, GLCanvas3D& canvas); - // creates Slicing Warning notification with custom text + // Creates Slicing Warning notification with a custom text and no fade out. void push_slicing_warning_notification(const std::string& text, bool gray, GLCanvas3D& canvas, ObjectID oid, int warning_step); // marks slicing errors as gray void set_all_slicing_errors_gray(bool g); @@ -91,15 +93,16 @@ public: // Release those slicing warnings, which refer to an ObjectID, which is not in the list. // living_oids is expected to be sorted. void remove_slicing_warnings_of_released_objects(const std::vector& living_oids); - // Object partially outside of the printer working space, cannot print. + // Object partially outside of the printer working space, cannot print. No fade out. void push_plater_error_notification(const std::string& text, GLCanvas3D& canvas); - // Object fully out of the printer working space and such. + // Object fully out of the printer working space and such. No fade out. void push_plater_warning_notification(const std::string& text, GLCanvas3D& canvas); // Closes error or warning of the same text void close_plater_error_notification(const std::string& text); void close_plater_warning_notification(const std::string& text); - // creates special notification slicing complete - // if large = true prints printing time and export button + // Creates special notification slicing complete. + // If large = true (Plater side bar is closed), then printing time and export button is shown + // at the notification and fade-out is disabled. Otherwise the fade out time is set to 10s. void push_slicing_complete_notification(GLCanvas3D& canvas, int timestamp, bool large); // Add a print time estimate to an existing SlicingComplete notification. void set_slicing_complete_print_time(const std::string &info); @@ -120,6 +123,7 @@ private: struct NotificationData { NotificationType type; NotificationLevel level; + // Fade out time const int duration; const std::string text1; const std::string hypertext; @@ -290,11 +294,14 @@ private: // Cache of IDs to identify and reuse ImGUI windows. NotificationIDProvider m_id_provider; std::deque> m_pop_notifications; + // Last render time for fade out control. long m_last_time { 0 }; bool m_hovered { false }; //timestamps used for slicing finished - notification could be gone so it needs to be stored here std::unordered_set m_used_timestamps; + // True if G-code preview is active. False if the Plater is active. bool m_in_preview { false }; + // True if the layer editing is enabled in Plater, so that the notifications are shifted left of it. bool m_move_from_overlay { false }; //prepared (basic) notifications