Merge branch 'dk_update' into master
This commit is contained in:
commit
489c750451
@ -2382,7 +2382,7 @@ void GLCanvas3D::on_size(wxSizeEvent& evt)
|
||||
{
|
||||
m_dirty = true;
|
||||
}
|
||||
|
||||
|
||||
void GLCanvas3D::on_idle(wxIdleEvent& evt)
|
||||
{
|
||||
if (!m_initialized)
|
||||
@ -2395,7 +2395,7 @@ void GLCanvas3D::on_idle(wxIdleEvent& evt)
|
||||
|
||||
m_dirty |= notification_mgr->requires_render();
|
||||
#endif // ENABLE_NEW_NOTIFICATIONS_FADE_OUT
|
||||
|
||||
// FIXME
|
||||
m_dirty |= m_main_toolbar.update_items_state();
|
||||
m_dirty |= m_undoredo_toolbar.update_items_state();
|
||||
m_dirty |= wxGetApp().plater()->get_view_toolbar().update_items_state();
|
||||
@ -2404,23 +2404,17 @@ void GLCanvas3D::on_idle(wxIdleEvent& evt)
|
||||
m_dirty |= mouse3d_controller_applied;
|
||||
|
||||
#if ENABLE_NEW_NOTIFICATIONS_FADE_OUT
|
||||
if (!m_dirty) {
|
||||
if (notification_mgr->requires_update())
|
||||
evt.RequestMore();
|
||||
return;
|
||||
if (notification_mgr->requires_update()) {
|
||||
evt.RequestMore();
|
||||
}
|
||||
#else
|
||||
#endif // ENABLE_NEW_NOTIFICATIONS_FADE_OUT
|
||||
|
||||
if (!m_dirty)
|
||||
return;
|
||||
#endif // ENABLE_NEW_NOTIFICATIONS_FADE_OUT
|
||||
|
||||
_refresh_if_shown_on_screen();
|
||||
|
||||
#if ENABLE_NEW_NOTIFICATIONS_FADE_OUT
|
||||
if (m_extra_frame_requested || mouse3d_controller_applied || notification_mgr->requires_update()) {
|
||||
#else
|
||||
if (m_extra_frame_requested || mouse3d_controller_applied) {
|
||||
#endif // ENABLE_NEW_NOTIFICATIONS_FADE_OUT
|
||||
m_dirty = true;
|
||||
m_extra_frame_requested = false;
|
||||
evt.RequestMore();
|
||||
|
@ -70,8 +70,8 @@ bool GLToolbarItem::update_visibility()
|
||||
bool ret = (m_data.visible != visible);
|
||||
if (ret)
|
||||
m_data.visible = visible;
|
||||
|
||||
return ret;
|
||||
// Return false for separator as it would always return true.
|
||||
return is_separator() ? false : ret;
|
||||
}
|
||||
|
||||
bool GLToolbarItem::update_enabled_state()
|
||||
|
@ -20,6 +20,8 @@ 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
|
||||
static constexpr int FADING_OUT_TIMEOUT = 100;
|
||||
#endif // ENABLE_NEW_NOTIFICATIONS_FADE_OUT
|
||||
|
||||
namespace Slic3r {
|
||||
@ -746,7 +748,7 @@ void NotificationManager::PopNotification::update_state()
|
||||
init();
|
||||
|
||||
if (m_hidden) {
|
||||
m_state = EState::Static;
|
||||
m_state = EState::Hidden;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -777,10 +779,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 > FADING_OUT_TIMEOUT) {
|
||||
m_last_render_fading = wxGetLocalTimeMillis();
|
||||
m_state = EState::FadingOutRender;
|
||||
}
|
||||
}
|
||||
m_state = EState::FadingOut;
|
||||
|
||||
}
|
||||
}
|
||||
#endif // ENABLE_NEW_NOTIFICATIONS_FADE_OUT
|
||||
@ -1207,9 +1215,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 +1342,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 +1372,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 +1386,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 +1406,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…
Reference in New Issue
Block a user