mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-31 04:31:15 -06:00 
			
		
		
		
	Merge branch 'dk_update' into master
This commit is contained in:
		
						commit
						489c750451
					
				
					 4 changed files with 40 additions and 29 deletions
				
			
		|  | @ -2395,7 +2395,7 @@ void GLCanvas3D::on_idle(wxIdleEvent& evt) | ||||||
| 
 | 
 | ||||||
|     m_dirty |= notification_mgr->requires_render(); |     m_dirty |= notification_mgr->requires_render(); | ||||||
| #endif // ENABLE_NEW_NOTIFICATIONS_FADE_OUT 
 | #endif // ENABLE_NEW_NOTIFICATIONS_FADE_OUT 
 | ||||||
| 
 |     // FIXME
 | ||||||
|     m_dirty |= m_main_toolbar.update_items_state(); |     m_dirty |= m_main_toolbar.update_items_state(); | ||||||
|     m_dirty |= m_undoredo_toolbar.update_items_state(); |     m_dirty |= m_undoredo_toolbar.update_items_state(); | ||||||
|     m_dirty |= wxGetApp().plater()->get_view_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; |     m_dirty |= mouse3d_controller_applied; | ||||||
| 
 | 
 | ||||||
| #if ENABLE_NEW_NOTIFICATIONS_FADE_OUT  | #if ENABLE_NEW_NOTIFICATIONS_FADE_OUT  | ||||||
|     if (!m_dirty) { |     if (notification_mgr->requires_update()) { | ||||||
|         if (notification_mgr->requires_update()) |  | ||||||
|         evt.RequestMore(); |         evt.RequestMore(); | ||||||
|         return; |  | ||||||
|     } |     } | ||||||
| #else | #endif // ENABLE_NEW_NOTIFICATIONS_FADE_OUT 
 | ||||||
|  | 
 | ||||||
|     if (!m_dirty) |     if (!m_dirty) | ||||||
|         return; |         return; | ||||||
| #endif // ENABLE_NEW_NOTIFICATIONS_FADE_OUT 
 |  | ||||||
| 
 | 
 | ||||||
|     _refresh_if_shown_on_screen(); |     _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) { |     if (m_extra_frame_requested || mouse3d_controller_applied) { | ||||||
| #endif // ENABLE_NEW_NOTIFICATIONS_FADE_OUT 
 |  | ||||||
|         m_dirty = true; |         m_dirty = true; | ||||||
|         m_extra_frame_requested = false; |         m_extra_frame_requested = false; | ||||||
|         evt.RequestMore(); |         evt.RequestMore(); | ||||||
|  |  | ||||||
|  | @ -70,8 +70,8 @@ bool GLToolbarItem::update_visibility() | ||||||
|     bool ret = (m_data.visible != visible); |     bool ret = (m_data.visible != visible); | ||||||
|     if (ret) |     if (ret) | ||||||
|         m_data.visible = visible; |         m_data.visible = visible; | ||||||
| 
 |     // Return false for separator as it would always return true.
 | ||||||
|     return ret; |     return is_separator() ? false : ret; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| bool GLToolbarItem::update_enabled_state() | bool GLToolbarItem::update_enabled_state() | ||||||
|  |  | ||||||
|  | @ -20,6 +20,8 @@ static constexpr float GAP_WIDTH = 10.0f; | ||||||
| static constexpr float SPACE_RIGHT_PANEL = 10.0f; | static constexpr float SPACE_RIGHT_PANEL = 10.0f; | ||||||
| #if ENABLE_NEW_NOTIFICATIONS_FADE_OUT  | #if ENABLE_NEW_NOTIFICATIONS_FADE_OUT  | ||||||
| static constexpr float FADING_OUT_DURATION = 2.0f; | 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 
 | #endif // ENABLE_NEW_NOTIFICATIONS_FADE_OUT 
 | ||||||
| 
 | 
 | ||||||
| namespace Slic3r { | namespace Slic3r { | ||||||
|  | @ -746,7 +748,7 @@ void NotificationManager::PopNotification::update_state() | ||||||
| 		init(); | 		init(); | ||||||
| 
 | 
 | ||||||
| 	if (m_hidden) { | 	if (m_hidden) { | ||||||
| 		m_state = EState::Static; | 		m_state = EState::Hidden; | ||||||
| 		return; | 		return; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | @ -777,10 +779,16 @@ void NotificationManager::PopNotification::update_state() | ||||||
| 	} | 	} | ||||||
| 	if (m_fading_out) { | 	if (m_fading_out) { | ||||||
| 		if (!m_paused) { | 		if (!m_paused) { | ||||||
|  | 			m_state = EState::FadingOutStatic; | ||||||
| 			wxMilliClock_t curr_time      = wxGetLocalTimeMillis() - m_fading_start; | 			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); | 			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 
 | #endif // ENABLE_NEW_NOTIFICATIONS_FADE_OUT 
 | ||||||
|  | @ -1207,10 +1215,13 @@ void NotificationManager::render_notifications(float overlay_width) | ||||||
| 	float last_y = 0.0f; | 	float last_y = 0.0f; | ||||||
| 
 | 
 | ||||||
| 	for (const auto& notification : m_pop_notifications) { | 	for (const auto& notification : m_pop_notifications) { | ||||||
|  | 		if (notification->get_state() != PopNotification::EState::Hidden) { | ||||||
| 			notification->render(canvas, last_y, m_move_from_overlay && !m_in_preview, overlay_width); | 			notification->render(canvas, last_y, m_move_from_overlay && !m_in_preview, overlay_width); | ||||||
| 			if (notification->get_state() != PopNotification::EState::Finished) | 			if (notification->get_state() != PopNotification::EState::Finished) | ||||||
| 				last_y = notification->get_top() + GAP_WIDTH; | 				last_y = notification->get_top() + GAP_WIDTH; | ||||||
| 		} | 		} | ||||||
|  | 		 | ||||||
|  | 	} | ||||||
| } | } | ||||||
| #else | #else | ||||||
| void NotificationManager::render_notifications(float overlay_width) | void NotificationManager::render_notifications(float overlay_width) | ||||||
|  | @ -1331,7 +1342,7 @@ void NotificationManager::set_in_preview(bool preview) | ||||||
| #if ENABLE_NEW_NOTIFICATIONS_FADE_OUT  | #if ENABLE_NEW_NOTIFICATIONS_FADE_OUT  | ||||||
| void NotificationManager::update_notifications() | 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();) { | 	for (auto it = m_pop_notifications.begin(); it != m_pop_notifications.end();) { | ||||||
| 		std::unique_ptr<PopNotification>& notification = *it; | 		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(); | 	size_t curr_size = m_pop_notifications.size(); | ||||||
| 	m_requires_render = m_hovered || (last_size != curr_size); | 	m_requires_render = m_hovered || (last_size != curr_size); | ||||||
| 	last_size = curr_size; | 	last_size = curr_size; | ||||||
| 
 | 
 | ||||||
|  | 	// Ask notification if it needs render
 | ||||||
| 	if (!m_requires_render) { | 	if (!m_requires_render) { | ||||||
| 		for (const std::unique_ptr<PopNotification>& notification : m_pop_notifications) { | 		for (const std::unique_ptr<PopNotification>& notification : m_pop_notifications) { | ||||||
| 			if (notification->requires_render()) { | 			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
 | 	// actualizate timers
 | ||||||
| 	wxWindow* p = dynamic_cast<wxWindow*>(wxGetApp().plater()); | 	wxWindow* p = dynamic_cast<wxWindow*>(wxGetApp().plater()); | ||||||
|  | @ -1390,7 +1406,7 @@ void NotificationManager::update_notifications() | ||||||
| 		if (!m_hovered && m_last_time < now) { | 		if (!m_hovered && m_last_time < now) { | ||||||
| 			if (now - m_last_time >= 1) { | 			if (now - m_last_time >= 1) { | ||||||
| 				for (auto& notification : m_pop_notifications) { | 				for (auto& notification : m_pop_notifications) { | ||||||
| 					if (notification->get_state() != PopNotification::EState::Static) | 					//if (notification->get_state() != PopNotification::EState::Static)
 | ||||||
| 						notification->substract_remaining_time(); | 						notification->substract_remaining_time(); | ||||||
| 				} | 				} | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
|  | @ -188,11 +188,11 @@ private: | ||||||
| 		enum class EState | 		enum class EState | ||||||
| 		{ | 		{ | ||||||
| 			Unknown, | 			Unknown, | ||||||
| 			Static, | 			Hidden, | ||||||
| 			Countdown, | 			FadingOutRender,  // Requesting Render
 | ||||||
| 			FadingOut, | 			FadingOutStatic, | ||||||
| 			ClosePending, | 			ClosePending,     // Requesting Render
 | ||||||
| 			Finished | 			Finished,         // Requesting Render
 | ||||||
| 		}; | 		}; | ||||||
| #else | #else | ||||||
| 		enum class RenderResult | 		enum class RenderResult | ||||||
|  | @ -234,8 +234,8 @@ private: | ||||||
|         void                   hide(bool h) { m_hidden = h; } |         void                   hide(bool h) { m_hidden = h; } | ||||||
| #if ENABLE_NEW_NOTIFICATIONS_FADE_OUT  | #if ENABLE_NEW_NOTIFICATIONS_FADE_OUT  | ||||||
| 		void                   update_state(); | 		void                   update_state(); | ||||||
| 		bool				   requires_render() const { return m_fading_out || m_close_pending || m_finished; } | 		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::Static; } | 		bool				   requires_update() const { return m_state != EState::Hidden; } | ||||||
| 		EState                 get_state() const { return m_state; } | 		EState                 get_state() const { return m_state; } | ||||||
| #endif // ENABLE_NEW_NOTIFICATIONS_FADE_OUT 
 | #endif // ENABLE_NEW_NOTIFICATIONS_FADE_OUT 
 | ||||||
| 
 | 
 | ||||||
|  | @ -293,6 +293,7 @@ private: | ||||||
| 		bool             m_fading_out           { false }; | 		bool             m_fading_out           { false }; | ||||||
| #if ENABLE_NEW_NOTIFICATIONS_FADE_OUT  | #if ENABLE_NEW_NOTIFICATIONS_FADE_OUT  | ||||||
| 		wxMilliClock_t   m_fading_start         { 0LL }; | 		wxMilliClock_t   m_fading_start         { 0LL }; | ||||||
|  | 		wxMilliClock_t   m_last_render_fading   { 0LL }; | ||||||
| #else | #else | ||||||
| 		// total time left when fading beggins
 | 		// total time left when fading beggins
 | ||||||
| 		float            m_fading_time{ 0.0f }; | 		float            m_fading_time{ 0.0f }; | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 David Kocik
						David Kocik