mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-05-29 01:27:38 +08:00
Timeout in requesting renders at notification fadeout.
This commit is contained in:
parent
1210a250c8
commit
2659ac567a
@ -746,7 +746,7 @@ void NotificationManager::PopNotification::update_state()
|
||||
init();
|
||||
|
||||
if (m_hidden) {
|
||||
m_state = EState::Static;
|
||||
m_state = EState::Hidden;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -777,10 +777,16 @@ void NotificationManager::PopNotification::update_state()
|
||||
}
|
||||
if (m_fading_out) {
|
||||
if (!m_paused) {
|
||||
wxMilliClock_t curr_time = wxGetLocalTimeMillis() - m_fading_start;
|
||||
m_state = EState::FadingOutStatic;
|
||||
wxMilliClock_t curr_time = wxGetLocalTimeMillis() - m_fading_start;
|
||||
wxMilliClock_t no_render_time = wxGetLocalTimeMillis() - m_last_render_fading;
|
||||
m_current_fade_opacity = std::clamp(1.0f - 0.001f * static_cast<float>(curr_time.GetValue()) / FADING_OUT_DURATION, 0.0f, 1.0f);
|
||||
if (no_render_time > 100) {
|
||||
m_last_render_fading = wxGetLocalTimeMillis();
|
||||
m_state = EState::FadingOutRender;
|
||||
}
|
||||
}
|
||||
m_state = EState::FadingOut;
|
||||
|
||||
}
|
||||
}
|
||||
#endif // ENABLE_NEW_NOTIFICATIONS_FADE_OUT
|
||||
@ -1207,9 +1213,12 @@ void NotificationManager::render_notifications(float overlay_width)
|
||||
float last_y = 0.0f;
|
||||
|
||||
for (const auto& notification : m_pop_notifications) {
|
||||
notification->render(canvas, last_y, m_move_from_overlay && !m_in_preview, overlay_width);
|
||||
if (notification->get_state() != PopNotification::EState::Finished)
|
||||
last_y = notification->get_top() + GAP_WIDTH;
|
||||
if (notification->get_state() != PopNotification::EState::Hidden) {
|
||||
notification->render(canvas, last_y, m_move_from_overlay && !m_in_preview, overlay_width);
|
||||
if (notification->get_state() != PopNotification::EState::Finished)
|
||||
last_y = notification->get_top() + GAP_WIDTH;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
#else
|
||||
@ -1331,7 +1340,7 @@ void NotificationManager::set_in_preview(bool preview)
|
||||
#if ENABLE_NEW_NOTIFICATIONS_FADE_OUT
|
||||
void NotificationManager::update_notifications()
|
||||
{
|
||||
static size_t last_size = 0;
|
||||
static size_t last_size = m_pop_notifications.size();
|
||||
|
||||
for (auto it = m_pop_notifications.begin(); it != m_pop_notifications.end();) {
|
||||
std::unique_ptr<PopNotification>& notification = *it;
|
||||
@ -1361,10 +1370,12 @@ 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);
|
||||
last_size = curr_size;
|
||||
|
||||
// Ask notification if it needs render
|
||||
if (!m_requires_render) {
|
||||
for (const std::unique_ptr<PopNotification>& notification : m_pop_notifications) {
|
||||
if (notification->requires_render()) {
|
||||
@ -1373,6 +1384,9 @@ void NotificationManager::update_notifications()
|
||||
}
|
||||
}
|
||||
}
|
||||
// Make sure there will be update after last notification erased
|
||||
if (m_requires_render)
|
||||
m_requires_update = true;
|
||||
|
||||
// actualizate timers
|
||||
wxWindow* p = dynamic_cast<wxWindow*>(wxGetApp().plater());
|
||||
@ -1390,7 +1404,7 @@ void NotificationManager::update_notifications()
|
||||
if (!m_hovered && m_last_time < now) {
|
||||
if (now - m_last_time >= 1) {
|
||||
for (auto& notification : m_pop_notifications) {
|
||||
if (notification->get_state() != PopNotification::EState::Static)
|
||||
//if (notification->get_state() != PopNotification::EState::Static)
|
||||
notification->substract_remaining_time();
|
||||
}
|
||||
}
|
||||
|
@ -188,11 +188,11 @@ private:
|
||||
enum class EState
|
||||
{
|
||||
Unknown,
|
||||
Static,
|
||||
Countdown,
|
||||
FadingOut,
|
||||
ClosePending,
|
||||
Finished
|
||||
Hidden,
|
||||
FadingOutRender, // Requesting Render
|
||||
FadingOutStatic,
|
||||
ClosePending, // Requesting Render
|
||||
Finished, // Requesting Render
|
||||
};
|
||||
#else
|
||||
enum class RenderResult
|
||||
@ -234,8 +234,8 @@ private:
|
||||
void hide(bool h) { m_hidden = h; }
|
||||
#if ENABLE_NEW_NOTIFICATIONS_FADE_OUT
|
||||
void update_state();
|
||||
bool requires_render() const { return m_fading_out || m_close_pending || m_finished; }
|
||||
bool requires_update() const { return m_state != EState::Static; }
|
||||
bool requires_render() const { return m_state == EState::FadingOutRender || m_state == EState::ClosePending || m_state == EState::Finished; }
|
||||
bool requires_update() const { return m_state != EState::Hidden; }
|
||||
EState get_state() const { return m_state; }
|
||||
#endif // ENABLE_NEW_NOTIFICATIONS_FADE_OUT
|
||||
|
||||
@ -293,6 +293,7 @@ private:
|
||||
bool m_fading_out { false };
|
||||
#if ENABLE_NEW_NOTIFICATIONS_FADE_OUT
|
||||
wxMilliClock_t m_fading_start { 0LL };
|
||||
wxMilliClock_t m_last_render_fading { 0LL };
|
||||
#else
|
||||
// total time left when fading beggins
|
||||
float m_fading_time{ 0.0f };
|
||||
|
Loading…
x
Reference in New Issue
Block a user