mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-30 20:21:12 -06:00 
			
		
		
		
	Handling of gizmos related char events moved into new method GLGizmosManager::on_char()
This commit is contained in:
		
							parent
							
								
									c1d74d2943
								
							
						
					
					
						commit
						d18208458b
					
				
					 3 changed files with 98 additions and 45 deletions
				
			
		|  | @ -654,6 +654,97 @@ bool GLGizmosManager::on_mouse(wxMouseEvent& evt, GLCanvas3D& canvas) | |||
|     return processed; | ||||
| } | ||||
| 
 | ||||
| bool GLGizmosManager::on_char(wxKeyEvent& evt, GLCanvas3D& canvas) | ||||
| { | ||||
|     // see include/wx/defs.h enum wxKeyCode
 | ||||
|     int keyCode = evt.GetKeyCode(); | ||||
|     int ctrlMask = wxMOD_CONTROL; | ||||
| 
 | ||||
|     const Selection& selection = canvas.get_selection(); | ||||
|     bool processed = false; | ||||
| 
 | ||||
|     if ((evt.GetModifiers() & ctrlMask) != 0) | ||||
|     { | ||||
|         switch (keyCode) | ||||
|         { | ||||
|         case WXK_CONTROL_A: | ||||
|         { | ||||
|             // Sla gizmo selects all support points
 | ||||
|             if ((m_current == SlaSupports) && gizmo_event(SLAGizmoEventType::SelectAll)) | ||||
|                 processed = true; | ||||
| 
 | ||||
|             break; | ||||
|         } | ||||
|         } | ||||
|     } | ||||
|     else if (!evt.HasModifiers()) | ||||
|     { | ||||
|         switch (keyCode) | ||||
|         { | ||||
|         // key ESC
 | ||||
|         case WXK_ESCAPE: | ||||
|         { | ||||
|             if ((m_current != SlaSupports) || !gizmo_event(SLAGizmoEventType::DiscardChanges)) | ||||
|                 reset_all_states(); | ||||
| 
 | ||||
|             processed = true; | ||||
|             break; | ||||
|         } | ||||
|         case WXK_RETURN: | ||||
|         { | ||||
|             if ((m_current == SlaSupports) && gizmo_event(SLAGizmoEventType::ApplyChanges)) | ||||
|                 processed = true; | ||||
| 
 | ||||
|             break; | ||||
|         } | ||||
| #ifdef __APPLE__ | ||||
|         case WXK_BACK: // the low cost Apple solutions are not equipped with a Delete key, use Backspace instead.
 | ||||
| #else /* __APPLE__ */ | ||||
|         case WXK_DELETE: | ||||
| #endif /* __APPLE__ */ | ||||
|         { | ||||
|             if ((m_current == SlaSupports) && gizmo_event(SLAGizmoEventType::Delete)) | ||||
|                 processed = true; | ||||
| 
 | ||||
|             break; | ||||
|         } | ||||
|         case 'A': | ||||
|         case 'a': | ||||
|         { | ||||
|             if (m_current == SlaSupports) | ||||
|             { | ||||
|                 gizmo_event(SLAGizmoEventType::AutomaticGeneration); | ||||
|                 // set as processed no matter what's returned by gizmo_event() to avoid the calling canvas to process 'A' as arrange
 | ||||
|                 processed = true; | ||||
|             } | ||||
|             break; | ||||
|         } | ||||
|         case 'M': | ||||
|         case 'm': | ||||
|         { | ||||
|             if ((m_current == SlaSupports) && gizmo_event(SLAGizmoEventType::ManualEditing)) | ||||
|                 processed = true; | ||||
|                  | ||||
|             break; | ||||
|         } | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     if (!processed) | ||||
|     { | ||||
|         if (handle_shortcut(keyCode, selection)) | ||||
|         { | ||||
|             canvas.update_gizmos_data(); | ||||
|             processed = true; | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     if (processed) | ||||
|         canvas.set_as_dirty(); | ||||
| 
 | ||||
|     return processed; | ||||
| } | ||||
| 
 | ||||
| void GLGizmosManager::reset() | ||||
| { | ||||
|     for (GizmosMap::value_type& gizmo : m_gizmos) | ||||
|  |  | |||
|  | @ -153,6 +153,7 @@ public: | |||
|     const std::string& get_tooltip() const { return m_tooltip; } | ||||
| 
 | ||||
|     bool on_mouse(wxMouseEvent& evt, GLCanvas3D& canvas); | ||||
|     bool on_char(wxKeyEvent& evt, GLCanvas3D& canvas); | ||||
| 
 | ||||
| private: | ||||
|     void reset(); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Enrico Turri
						Enrico Turri