diff options
Diffstat (limited to 'src/slic3r/GUI/NotificationManager.cpp')
-rw-r--r-- | src/slic3r/GUI/NotificationManager.cpp | 47 |
1 files changed, 28 insertions, 19 deletions
diff --git a/src/slic3r/GUI/NotificationManager.cpp b/src/slic3r/GUI/NotificationManager.cpp index fa5aab66c..c2c7727ed 100644 --- a/src/slic3r/GUI/NotificationManager.cpp +++ b/src/slic3r/GUI/NotificationManager.cpp @@ -20,11 +20,11 @@ static constexpr float GAP_WIDTH = 10.0f; static constexpr float SPACE_RIGHT_PANEL = 10.0f; #if ENABLE_NEW_NOTIFICATIONS_FADE_OUT static constexpr float FADING_OUT_DURATION = 2.0f; -// Time in Miliseconds after next render is requested +// Time in Miliseconds after next render when fading out is requested static constexpr int FADING_OUT_TIMEOUT = 100; // If timeout is changed to higher than 1 second, substract_time call should be revorked -static constexpr int MAX_TIMEOUT_MILISECONDS = 1000; -static constexpr int MAX_TIMEOUT_SECONDS = 1; +//static constexpr int MAX_TIMEOUT_MILISECONDS = 1000; +//static constexpr int MAX_TIMEOUT_SECONDS = 1; #endif // ENABLE_NEW_NOTIFICATIONS_FADE_OUT namespace Slic3r { @@ -139,6 +139,7 @@ NotificationManager::PopNotification::PopNotification(const NotificationData &n, , m_hypertext (n.hypertext) , m_text2 (n.text2) , m_evt_handler (evt_handler) + , m_notification_start (GLCanvas3D::timestamp_now()) { //init(); } @@ -760,29 +761,29 @@ void NotificationManager::PopNotification::update_state() return; } + int64_t now = GLCanvas3D::timestamp_now(); + if (m_hovered) { // reset fading m_fading_out = false; m_current_fade_opacity = 1.0f; m_remaining_time = m_data.duration; -// m_notification_start = GLCanvas3D::timestamp_now(); -// BOOST_LOG_TRIVIAL(error) << "hover"; + m_notification_start = now; } - int64_t now = GLCanvas3D::timestamp_now(); + if (m_counting_down) { - //int64_t up_time = GLCanvas3D::timestamp_now() - m_notification_start; + int64_t up_time = now - m_notification_start; if (m_fading_out && m_current_fade_opacity <= 0.0f) m_finished = true; - else if (!m_fading_out && m_remaining_time <=0/*up_time >= m_data.duration * 1000*/) { + else if (!m_fading_out && /*m_remaining_time <=0*/up_time >= m_data.duration * 1000) { m_fading_out = true; m_fading_start = now; m_last_render_fading = now; } else if (!m_fading_out) { - m_next_render = std::min<int64_t>(/*m_data.duration * 1000 - up_time*/m_remaining_time * 1000, MAX_TIMEOUT_MILISECONDS); - //BOOST_LOG_TRIVIAL(error) << (boost::format("up time %1% next render %2%") % up_time % m_next_render); + m_next_render = m_data.duration * 1000 - up_time;//std::min<int64_t>(/*m_data.duration * 1000 - up_time*/m_remaining_time * 1000, MAX_TIMEOUT_MILISECONDS); } } @@ -790,14 +791,12 @@ void NotificationManager::PopNotification::update_state() if (m_finished) { m_state = EState::Finished; m_next_render = 0; - //BOOST_LOG_TRIVIAL(error) << "EState::Finished"; return; } if (m_close_pending) { m_finished = true; m_state = EState::ClosePending; m_next_render = 0; - //BOOST_LOG_TRIVIAL(error) << "EState::ClosePending"; return; } if (m_fading_out) { @@ -813,10 +812,8 @@ void NotificationManager::PopNotification::update_state() m_next_render = 0; } else m_next_render = next_render; - //BOOST_LOG_TRIVIAL(error) << (boost::format("fade render %1%") % m_next_render); } } - //BOOST_LOG_TRIVIAL(error) << (boost::format("remaining time %1% fading %2% next render %3%") % m_remaining_time % m_fading_out % m_next_render); } #endif // ENABLE_NEW_NOTIFICATIONS_FADE_OUT @@ -1214,10 +1211,11 @@ bool NotificationManager::push_notification_data(const NotificationData& notific } bool NotificationManager::push_notification_data(std::unique_ptr<NotificationManager::PopNotification> notification, int timestamp) { +/* #if ENABLE_NEW_NOTIFICATIONS_FADE_OUT m_requires_update = true; #endif // ENABLE_NEW_NOTIFICATIONS_FADE_OUT - +*/ // if timestamped notif, push only new one if (timestamp != 0) { if (m_used_timestamps.find(timestamp) == m_used_timestamps.end()) { @@ -1242,6 +1240,7 @@ bool NotificationManager::push_notification_data(std::unique_ptr<NotificationMan #if ENABLE_NEW_NOTIFICATIONS_FADE_OUT void NotificationManager::render_notifications(float overlay_width) { + sort_notifications(); GLCanvas3D& canvas = *wxGetApp().plater()->get_current_canvas3D(); @@ -1376,6 +1375,14 @@ void NotificationManager::set_in_preview(bool preview) #if ENABLE_NEW_NOTIFICATIONS_FADE_OUT void NotificationManager::update_notifications() { + // no update if not top window + wxWindow* p = dynamic_cast<wxWindow*>(wxGetApp().plater()); + while (p->GetParent() != nullptr) + p = p->GetParent(); + wxTopLevelWindow* top_level_wnd = dynamic_cast<wxTopLevelWindow*>(p); + if (!top_level_wnd->IsActive()) + return; + static size_t last_size = m_pop_notifications.size(); for (auto it = m_pop_notifications.begin(); it != m_pop_notifications.end();) { @@ -1388,7 +1395,7 @@ void NotificationManager::update_notifications() ++it; } } - + /* m_requires_update = false; for (const std::unique_ptr<PopNotification>& notification : m_pop_notifications) { if (notification->requires_update()) { @@ -1396,7 +1403,7 @@ void NotificationManager::update_notifications() break; } } - + */ // update hovering state m_hovered = false; for (const std::unique_ptr<PopNotification>& notification : m_pop_notifications) { @@ -1406,7 +1413,7 @@ void NotificationManager::update_notifications() } } - + /* // Reuire render if some notification was just deleted. size_t curr_size = m_pop_notifications.size(); m_requires_render = m_hovered || (last_size != curr_size); @@ -1424,7 +1431,7 @@ void NotificationManager::update_notifications() // Make sure there will be update after last notification erased if (m_requires_render) m_requires_update = true; - + */ //request frames int64_t next_render = std::numeric_limits<int64_t>::max(); const int64_t max = std::numeric_limits<int64_t>::max(); @@ -1437,6 +1444,7 @@ void NotificationManager::update_notifications() else if (next_render < max) wxGetApp().plater()->get_current_canvas3D()->request_extra_frame_delayed(int(next_render)); + /* // actualizate timers wxWindow* p = dynamic_cast<wxWindow*>(wxGetApp().plater()); while (p->GetParent() != nullptr) @@ -1460,6 +1468,7 @@ void NotificationManager::update_notifications() } } } + */ } #endif // ENABLE_NEW_NOTIFICATIONS_FADE_OUT |