mirror of
				https://github.com/godotengine/godot.git
				synced 2025-10-31 05:31:01 +00:00 
			
		
		
		
	Change editor viewports gizmos mouse enter/exit from using signals to notificatons
This commit is contained in:
		
							parent
							
								
									24d74510e5
								
							
						
					
					
						commit
						d17cf852e3
					
				
					 2 changed files with 15 additions and 31 deletions
				
			
		|  | @ -128,21 +128,22 @@ constexpr real_t MAX_FOV = 179; | |||
| 
 | ||||
| void ViewportNavigationControl::_notification(int p_what) { | ||||
| 	switch (p_what) { | ||||
| 		case NOTIFICATION_ENTER_TREE: { | ||||
| 			if (!is_connected(SceneStringName(mouse_exited), callable_mp(this, &ViewportNavigationControl::_on_mouse_exited))) { | ||||
| 				connect(SceneStringName(mouse_exited), callable_mp(this, &ViewportNavigationControl::_on_mouse_exited)); | ||||
| 			} | ||||
| 			if (!is_connected(SceneStringName(mouse_entered), callable_mp(this, &ViewportNavigationControl::_on_mouse_entered))) { | ||||
| 				connect(SceneStringName(mouse_entered), callable_mp(this, &ViewportNavigationControl::_on_mouse_entered)); | ||||
| 			} | ||||
| 		} break; | ||||
| 
 | ||||
| 		case NOTIFICATION_DRAW: { | ||||
| 			if (viewport != nullptr) { | ||||
| 				_draw(); | ||||
| 				_update_navigation(); | ||||
| 			} | ||||
| 		} break; | ||||
| 
 | ||||
| 		case NOTIFICATION_MOUSE_ENTER: { | ||||
| 			hovered = true; | ||||
| 			queue_redraw(); | ||||
| 		} break; | ||||
| 
 | ||||
| 		case NOTIFICATION_MOUSE_EXIT: { | ||||
| 			hovered = false; | ||||
| 			queue_redraw(); | ||||
| 		} break; | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
|  | @ -279,16 +280,6 @@ void ViewportNavigationControl::_update_navigation() { | |||
| 	} | ||||
| } | ||||
| 
 | ||||
| void ViewportNavigationControl::_on_mouse_entered() { | ||||
| 	hovered = true; | ||||
| 	queue_redraw(); | ||||
| } | ||||
| 
 | ||||
| void ViewportNavigationControl::_on_mouse_exited() { | ||||
| 	hovered = false; | ||||
| 	queue_redraw(); | ||||
| } | ||||
| 
 | ||||
| void ViewportNavigationControl::set_navigation_mode(Node3DEditorViewport::NavigationMode p_nav_mode) { | ||||
| 	nav_mode = p_nav_mode; | ||||
| } | ||||
|  | @ -313,10 +304,6 @@ void ViewportRotationControl::_notification(int p_what) { | |||
| 			axis_colors.push_back(get_theme_color(SNAME("axis_y_color"), EditorStringName(Editor))); | ||||
| 			axis_colors.push_back(get_theme_color(SNAME("axis_z_color"), EditorStringName(Editor))); | ||||
| 			queue_redraw(); | ||||
| 
 | ||||
| 			if (!is_connected(SceneStringName(mouse_exited), callable_mp(this, &ViewportRotationControl::_on_mouse_exited))) { | ||||
| 				connect(SceneStringName(mouse_exited), callable_mp(this, &ViewportRotationControl::_on_mouse_exited)); | ||||
| 			} | ||||
| 		} break; | ||||
| 
 | ||||
| 		case NOTIFICATION_DRAW: { | ||||
|  | @ -324,6 +311,11 @@ void ViewportRotationControl::_notification(int p_what) { | |||
| 				_draw(); | ||||
| 			} | ||||
| 		} break; | ||||
| 
 | ||||
| 		case NOTIFICATION_MOUSE_EXIT: { | ||||
| 			focused_axis = -2; | ||||
| 			queue_redraw(); | ||||
| 		} break; | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
|  | @ -494,11 +486,6 @@ void ViewportRotationControl::_update_focus() { | |||
| 	} | ||||
| } | ||||
| 
 | ||||
| void ViewportRotationControl::_on_mouse_exited() { | ||||
| 	focused_axis = -2; | ||||
| 	queue_redraw(); | ||||
| } | ||||
| 
 | ||||
| void ViewportRotationControl::set_viewport(Node3DEditorViewport *p_viewport) { | ||||
| 	viewport = p_viewport; | ||||
| } | ||||
|  |  | |||
|  | @ -95,7 +95,6 @@ protected: | |||
| 	void _draw_axis(const Axis2D &p_axis); | ||||
| 	void _get_sorted_axis(Vector<Axis2D> &r_axis); | ||||
| 	void _update_focus(); | ||||
| 	void _on_mouse_exited(); | ||||
| 	void _process_click(int p_index, Vector2 p_position, bool p_pressed); | ||||
| 	void _process_drag(Ref<InputEventWithModifiers> p_event, int p_index, Vector2 p_position, Vector2 p_relative_position); | ||||
| 
 | ||||
|  | @ -1045,8 +1044,6 @@ protected: | |||
| 	void _notification(int p_what); | ||||
| 	virtual void gui_input(const Ref<InputEvent> &p_event) override; | ||||
| 	void _draw(); | ||||
| 	void _on_mouse_entered(); | ||||
| 	void _on_mouse_exited(); | ||||
| 	void _process_click(int p_index, Vector2 p_position, bool p_pressed); | ||||
| 	void _process_drag(int p_index, Vector2 p_position, Vector2 p_relative_position); | ||||
| 	void _update_navigation(); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Robert Yevdokimov
						Robert Yevdokimov