mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-30 20:21:12 -06:00 
			
		
		
		
	Faster switching of parameter pages if the page is switched
by cursor keys in the tree control: The page update is delayed to idle.
This commit is contained in:
		
							parent
							
								
									5243d3e53c
								
							
						
					
					
						commit
						ec8602f8d9
					
				
					 2 changed files with 23 additions and 12 deletions
				
			
		|  | @ -293,7 +293,20 @@ void Tab::create_preset_tab() | |||
|     m_treectrl->AddRoot("root"); | ||||
|     m_treectrl->SetIndent(0); | ||||
| 
 | ||||
|     m_treectrl->Bind(wxEVT_TREE_SEL_CHANGED, &Tab::OnTreeSelChange, this); | ||||
|     // Delay processing of the following handler until the message queue is flushed.
 | ||||
|     // This helps to process all the cursor key events on Windows in the tree control,
 | ||||
|     // so that the cursor jumps to the last item.
 | ||||
|     m_treectrl->Bind(wxEVT_TREE_SEL_CHANGED, [this](wxTreeEvent&) { | ||||
|             if (!m_disable_tree_sel_changed_event && !m_pages.empty()) | ||||
|                 m_page_switch_planned = true; | ||||
|         }); | ||||
|     m_treectrl->Bind(wxEVT_IDLE, [this](wxIdleEvent&) { | ||||
|             if (m_page_switch_planned) { | ||||
|             	this->tree_sel_change_delayed(); | ||||
|                 m_page_switch_planned = false; | ||||
|             } | ||||
|         }); | ||||
| 
 | ||||
|     m_treectrl->Bind(wxEVT_KEY_DOWN, &Tab::OnKeyDown, this); | ||||
| 
 | ||||
|     // Initialize the page.
 | ||||
|  | @ -3370,14 +3383,11 @@ void Tab::active_selected_page() | |||
|     toggle_options(); | ||||
| } | ||||
| 
 | ||||
| void Tab::OnTreeSelChange(wxTreeEvent& event) | ||||
| void Tab::tree_sel_change_delayed() | ||||
| { | ||||
|     if (m_disable_tree_sel_changed_event) | ||||
|         return; | ||||
| 
 | ||||
| // There is a bug related to Ubuntu overlay scrollbars, see https://github.com/prusa3d/PrusaSlicer/issues/898 and https://github.com/prusa3d/PrusaSlicer/issues/952.
 | ||||
| // The issue apparently manifests when Show()ing a window with overlay scrollbars while the UI is frozen. For this reason,
 | ||||
| // we will Thaw the UI prematurely on Linux. This means destroing the no_updates object prematurely.
 | ||||
| 	// There is a bug related to Ubuntu overlay scrollbars, see https://github.com/prusa3d/PrusaSlicer/issues/898 and https://github.com/prusa3d/PrusaSlicer/issues/952.
 | ||||
| 	// The issue apparently manifests when Show()ing a window with overlay scrollbars while the UI is frozen. For this reason,
 | ||||
| 	// we will Thaw the UI prematurely on Linux. This means destroing the no_updates object prematurely.
 | ||||
| #ifdef __linux__ | ||||
|     std::unique_ptr<wxWindowUpdateLocker> no_updates(new wxWindowUpdateLocker(this)); | ||||
| #else | ||||
|  | @ -3390,9 +3400,6 @@ void Tab::OnTreeSelChange(wxTreeEvent& event) | |||
| //#endif
 | ||||
| #endif | ||||
| 
 | ||||
|     if (m_pages.empty()) | ||||
|         return; | ||||
| 
 | ||||
|     Page* page = nullptr; | ||||
|     const auto sel_item = m_treectrl->GetSelection(); | ||||
|     const auto selection = sel_item ? m_treectrl->GetItemText(sel_item) : ""; | ||||
|  |  | |||
|  | @ -130,7 +130,7 @@ protected: | |||
| 	wxScrolledWindow*	m_page_view {nullptr}; | ||||
| 	wxBoxSizer*			m_page_sizer {nullptr}; | ||||
| 
 | ||||
|     ModeSizer*     m_mode_sizer; | ||||
|     ModeSizer*			m_mode_sizer; | ||||
| 
 | ||||
|    	struct PresetDependencies { | ||||
| 		Preset::Type type	  = Preset::TYPE_INVALID; | ||||
|  | @ -238,6 +238,9 @@ protected: | |||
| 
 | ||||
| 	DynamicPrintConfig 	m_cache_config; | ||||
| 
 | ||||
| 
 | ||||
| 	bool				m_page_switch_planned = false; | ||||
| 
 | ||||
| public: | ||||
| 	PresetBundle*		m_preset_bundle; | ||||
| 	bool				m_show_btn_incompatible_presets = false; | ||||
|  | @ -351,6 +354,7 @@ protected: | |||
| 	void 			compatible_widget_reload(PresetDependencies &deps); | ||||
| 	void			load_key_value(const std::string& opt_key, const boost::any& value, bool saved_value = false); | ||||
| 
 | ||||
| 	void			tree_sel_change_delayed(); | ||||
| 	void			on_presets_changed(); | ||||
| 	void			build_preset_description_line(ConfigOptionsGroup* optgroup); | ||||
| 	void			update_preset_description_line(); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 bubnikv
						bubnikv