GLCanvas on_idle changes to do updates on notifications correctly. Changed updating separators in GLToolbar.

This commit is contained in:
David Kocik 2020-12-08 09:09:38 +01:00
parent 2659ac567a
commit 3f11b7dea5
3 changed files with 11 additions and 15 deletions

View file

@ -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();

View file

@ -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()

View file

@ -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 {
@ -781,7 +783,7 @@ void NotificationManager::PopNotification::update_state()
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) {
if (no_render_time > FADING_OUT_TIMEOUT) {
m_last_render_fading = wxGetLocalTimeMillis();
m_state = EState::FadingOutRender;
}