2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								/**************************************************************************/  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								/*  canvas_item_editor_plugin.cpp                                         */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								/**************************************************************************/  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								/*                         This file is part of:                          */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								/*                             GODOT ENGINE                               */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								/*                        https://godotengine.org                         */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								/**************************************************************************/  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur.                  */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								/*                                                                        */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								/* Permission is hereby granted, free of charge, to any person obtaining  */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								/* a copy of this software and associated documentation files (the        */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								/* "Software"), to deal in the Software without restriction, including    */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								/* without limitation the rights to use, copy, modify, merge, publish,    */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								/* distribute, sublicense, and/or sell copies of the Software, and to     */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								/* permit persons to whom the Software is furnished to do so, subject to  */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								/* the following conditions:                                              */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								/*                                                                        */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								/* The above copyright notice and this permission notice shall be         */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								/* included in all copies or substantial portions of the Software.        */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								/*                                                                        */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,        */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF     */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY   */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,   */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE      */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                 */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								/**************************************************************************/  
						 
					
						
							
								
									
										
										
										
											2018-01-05 00:50:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								# include  "canvas_item_editor_plugin.h" 
  
						 
					
						
							
								
									
										
										
										
											2017-01-16 08:04:19 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-07 19:33:38 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  "core/config/project_settings.h" 
  
						 
					
						
							
								
									
										
										
										
											2020-04-28 15:19:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  "core/input/input.h" 
  
						 
					
						
							
								
									
										
										
										
											2018-09-11 18:13:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  "core/os/keyboard.h" 
  
						 
					
						
							
								
									
										
										
										
											2020-02-07 02:52:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  "editor/debugger/editor_debugger_node.h" 
  
						 
					
						
							
								
									
										
										
										
											2024-08-19 18:08:31 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  "editor/editor_main_screen.h" 
  
						 
					
						
							
								
									
										
										
										
											2017-03-05 14:21:25 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  "editor/editor_node.h" 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								# include  "editor/editor_settings.h" 
  
						 
					
						
							
								
									
										
										
										
											2023-08-13 02:33:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  "editor/editor_string_names.h" 
  
						 
					
						
							
								
									
										
										
										
											2022-03-25 18:06:46 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  "editor/editor_undo_redo_manager.h" 
  
						 
					
						
							
								
									
										
										
										
											2023-04-12 21:02:28 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  "editor/gui/editor_run_bar.h" 
  
						 
					
						
							
								
									
										
										
										
											2023-04-07 18:59:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  "editor/gui/editor_toaster.h" 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								# include  "editor/gui/editor_zoom_widget.h" 
  
						 
					
						
							
								
									
										
										
										
											2017-03-05 14:21:25 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  "editor/plugins/animation_player_editor_plugin.h" 
  
						 
					
						
							
								
									
										
										
										
											2024-12-18 14:42:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  "editor/plugins/editor_context_menu_plugin.h" 
  
						 
					
						
							
								
									
										
										
										
											2017-03-05 14:21:25 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  "editor/plugins/script_editor_plugin.h" 
  
						 
					
						
							
								
									
										
										
										
											2022-02-12 02:46:22 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  "editor/scene_tree_dock.h" 
  
						 
					
						
							
								
									
										
										
										
											2024-01-15 13:14:55 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  "editor/themes/editor_scale.h" 
  
						 
					
						
							
								
									
										
										
										
											2024-01-17 15:03:55 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  "editor/themes/editor_theme_manager.h" 
  
						 
					
						
							
								
									
										
										
										
											2024-05-16 10:13:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  "scene/2d/audio_stream_player_2d.h" 
  
						 
					
						
							
								
									
										
										
										
											2025-02-27 19:01:23 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  "scene/2d/physics/touch_screen_button.h" 
  
						 
					
						
							
								
									
										
										
										
											2016-10-26 04:27:24 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  "scene/2d/polygon_2d.h" 
  
						 
					
						
							
								
									
										
										
										
											2018-05-04 16:46:32 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  "scene/2d/skeleton_2d.h" 
  
						 
					
						
							
								
									
										
										
										
											2020-03-26 18:49:16 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  "scene/2d/sprite_2d.h" 
  
						 
					
						
							
								
									
										
										
										
											2024-05-16 10:13:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  "scene/gui/base_button.h" 
  
						 
					
						
							
								
									
										
										
										
											2022-07-20 04:00:25 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  "scene/gui/flow_container.h" 
  
						 
					
						
							
								
									
										
										
										
											2015-02-15 18:00:55 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  "scene/gui/grid_container.h" 
  
						 
					
						
							
								
									
										
										
										
											2022-08-01 17:04:35 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  "scene/gui/separator.h" 
  
						 
					
						
							
								
									
										
										
										
											2022-11-19 12:45:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  "scene/gui/split_container.h" 
  
						 
					
						
							
								
									
										
										
										
											2020-04-01 15:28:09 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  "scene/gui/subviewport_container.h" 
  
						 
					
						
							
								
									
										
										
										
											2022-01-19 19:59:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  "scene/gui/view_panner.h" 
  
						 
					
						
							
								
									
										
										
										
											2017-03-05 14:21:25 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  "scene/main/canvas_layer.h" 
  
						 
					
						
							
								
									
										
										
										
											2020-03-03 22:51:12 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  "scene/main/window.h" 
  
						 
					
						
							
								
									
										
										
										
											2016-04-07 12:59:50 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  "scene/resources/packed_scene.h" 
  
						 
					
						
							
								
									
										
										
										
											2023-07-14 22:35:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  "scene/resources/style_box_texture.h" 
  
						 
					
						
							
								
									
										
										
										
											2015-02-15 18:00:55 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-12-10 05:13:02 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# define RULER_WIDTH (15 * EDSCALE) 
  
						 
					
						
							
								
									
										
										
										
											2024-07-13 00:03:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# define DRAG_THRESHOLD (8 * EDSCALE) 
  
						 
					
						
							
								
									
										
										
										
											2022-03-08 15:10:48 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								constexpr  real_t  SCALE_HANDLE_DISTANCE  =  25 ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								constexpr  real_t  MOVE_HANDLE_DISTANCE  =  25 ;  
						 
					
						
							
								
									
										
										
										
											2017-08-29 21:50:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-02-15 18:00:55 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								class  SnapDialog  :  public  ConfirmationDialog  {  
						 
					
						
							
								
									
										
										
										
											2017-01-02 23:03:46 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									GDCLASS ( SnapDialog ,  ConfirmationDialog ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-18 13:31:44 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									friend  class  CanvasItemEditor ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-02-15 18:00:55 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									SpinBox  * grid_offset_x ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									SpinBox  * grid_offset_y ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									SpinBox  * grid_step_x ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-03-09 00:00:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									SpinBox  * grid_step_y ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-02 17:13:46 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									SpinBox  * primary_grid_step_x ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									SpinBox  * primary_grid_step_y ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-03-09 00:00:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									SpinBox  * rotation_offset ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-02-15 18:00:55 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									SpinBox  * rotation_step ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-30 15:18:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									SpinBox  * scale_step ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-03-09 00:00:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-02-15 18:00:55 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								public :  
						 
					
						
							
								
									
										
										
										
											2019-06-26 15:08:25 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									SnapDialog ( )  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-07 22:59:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										const  int  SPIN_BOX_GRID_RANGE  =  16384 ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-02-15 18:00:55 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										const  int  SPIN_BOX_ROTATION_RANGE  =  360 ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-20 23:30:19 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										const  real_t  SPIN_BOX_SCALE_MIN  =  0.01 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										const  real_t  SPIN_BOX_SCALE_MAX  =  100 ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-30 15:18:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-02-15 18:00:55 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Label  * label ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										VBoxContainer  * container ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										GridContainer  * child_container ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-18 13:31:44 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-05-03 22:25:37 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										set_title ( TTR ( " Configure Snap " ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-18 13:31:44 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										container  =  memnew ( VBoxContainer ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-02-15 18:00:55 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										add_child ( container ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-18 13:31:44 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										child_container  =  memnew ( GridContainer ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-02-15 18:00:55 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										child_container - > set_columns ( 3 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										container - > add_child ( child_container ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-18 13:31:44 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										label  =  memnew ( Label ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-05-03 22:25:37 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										label - > set_text ( TTR ( " Grid Offset: " ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-02-15 18:00:55 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										child_container - > add_child ( label ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-06 14:00:16 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										label - > set_h_size_flags ( Control : : SIZE_EXPAND_FILL ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-18 13:31:44 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										grid_offset_x  =  memnew ( SpinBox ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-02-15 18:00:55 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										grid_offset_x - > set_min ( - SPIN_BOX_GRID_RANGE ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										grid_offset_x - > set_max ( SPIN_BOX_GRID_RANGE ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-07 22:59:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										grid_offset_x - > set_allow_lesser ( true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										grid_offset_x - > set_allow_greater ( true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-02-15 18:00:55 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										grid_offset_x - > set_suffix ( " px " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-06 14:00:16 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										grid_offset_x - > set_h_size_flags ( Control : : SIZE_EXPAND_FILL ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-16 20:37:35 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										grid_offset_x - > set_select_all_on_focus ( true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-02-15 18:00:55 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										child_container - > add_child ( grid_offset_x ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-18 13:31:44 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										grid_offset_y  =  memnew ( SpinBox ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-02-15 18:00:55 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										grid_offset_y - > set_min ( - SPIN_BOX_GRID_RANGE ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										grid_offset_y - > set_max ( SPIN_BOX_GRID_RANGE ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-07 22:59:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										grid_offset_y - > set_allow_lesser ( true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										grid_offset_y - > set_allow_greater ( true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-02-15 18:00:55 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										grid_offset_y - > set_suffix ( " px " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-06 14:00:16 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										grid_offset_y - > set_h_size_flags ( Control : : SIZE_EXPAND_FILL ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-16 20:37:35 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										grid_offset_y - > set_select_all_on_focus ( true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-02-15 18:00:55 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										child_container - > add_child ( grid_offset_y ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-10-18 13:31:44 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										label  =  memnew ( Label ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-05-03 22:25:37 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										label - > set_text ( TTR ( " Grid Step: " ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-02-15 18:00:55 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										child_container - > add_child ( label ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-06 14:00:16 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										label - > set_h_size_flags ( Control : : SIZE_EXPAND_FILL ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-18 13:31:44 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										grid_step_x  =  memnew ( SpinBox ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-23 16:05:25 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										grid_step_x - > set_min ( 1 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-02-15 18:00:55 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										grid_step_x - > set_max ( SPIN_BOX_GRID_RANGE ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-07 22:59:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										grid_step_x - > set_allow_greater ( true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-02-15 18:00:55 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										grid_step_x - > set_suffix ( " px " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-06 14:00:16 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										grid_step_x - > set_h_size_flags ( Control : : SIZE_EXPAND_FILL ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-16 20:37:35 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										grid_step_x - > set_select_all_on_focus ( true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-02-15 18:00:55 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										child_container - > add_child ( grid_step_x ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-18 13:31:44 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										grid_step_y  =  memnew ( SpinBox ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-23 16:05:25 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										grid_step_y - > set_min ( 1 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-02-15 18:00:55 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										grid_step_y - > set_max ( SPIN_BOX_GRID_RANGE ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-07 22:59:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										grid_step_y - > set_allow_greater ( true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-02-15 18:00:55 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										grid_step_y - > set_suffix ( " px " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-06 14:00:16 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										grid_step_y - > set_h_size_flags ( Control : : SIZE_EXPAND_FILL ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-16 20:37:35 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										grid_step_y - > set_select_all_on_focus ( true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-02-15 18:00:55 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										child_container - > add_child ( grid_step_y ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-10-15 10:23:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										label  =  memnew ( Label ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-30 22:02:37 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										label - > set_text ( TTR ( " Primary Line Every: " ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-06 14:00:16 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										label - > set_h_size_flags ( Control : : SIZE_EXPAND_FILL ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-15 10:23:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										child_container - > add_child ( label ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-02 17:13:46 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										primary_grid_step_x  =  memnew ( SpinBox ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										primary_grid_step_x - > set_min ( 1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										primary_grid_step_x - > set_step ( 1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										primary_grid_step_x - > set_max ( SPIN_BOX_GRID_RANGE ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										primary_grid_step_x - > set_allow_greater ( true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										primary_grid_step_x - > set_suffix ( " steps " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										primary_grid_step_x - > set_h_size_flags ( Control : : SIZE_EXPAND_FILL ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										primary_grid_step_x - > set_select_all_on_focus ( true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										child_container - > add_child ( primary_grid_step_x ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										primary_grid_step_y  =  memnew ( SpinBox ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										primary_grid_step_y - > set_min ( 1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										primary_grid_step_y - > set_step ( 1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										primary_grid_step_y - > set_max ( SPIN_BOX_GRID_RANGE ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										primary_grid_step_y - > set_allow_greater ( true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										primary_grid_step_y - > set_suffix ( " steps " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										primary_grid_step_y - > set_h_size_flags ( Control : : SIZE_EXPAND_FILL ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										primary_grid_step_y - > set_select_all_on_focus ( true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										child_container - > add_child ( primary_grid_step_y ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-15 10:23:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-10-18 13:31:44 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										container - > add_child ( memnew ( HSeparator ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-10-30 22:02:37 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										// We need to create another GridContainer with the same column count,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										// so we can put an HSeparator above
 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-18 13:31:44 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										child_container  =  memnew ( GridContainer ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-02-15 18:00:55 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										child_container - > set_columns ( 2 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										container - > add_child ( child_container ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-10-18 13:31:44 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										label  =  memnew ( Label ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-05-03 22:25:37 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										label - > set_text ( TTR ( " Rotation Offset: " ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-02-15 18:00:55 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										child_container - > add_child ( label ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-06 14:00:16 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										label - > set_h_size_flags ( Control : : SIZE_EXPAND_FILL ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-18 13:31:44 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										rotation_offset  =  memnew ( SpinBox ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-02-15 18:00:55 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										rotation_offset - > set_min ( - SPIN_BOX_ROTATION_RANGE ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										rotation_offset - > set_max ( SPIN_BOX_ROTATION_RANGE ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										rotation_offset - > set_suffix ( " deg " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-06 14:00:16 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										rotation_offset - > set_h_size_flags ( Control : : SIZE_EXPAND_FILL ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-16 20:37:35 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										rotation_offset - > set_select_all_on_focus ( true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-02-15 18:00:55 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										child_container - > add_child ( rotation_offset ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-18 13:31:44 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										label  =  memnew ( Label ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-05-03 22:25:37 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										label - > set_text ( TTR ( " Rotation Step: " ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-02-15 18:00:55 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										child_container - > add_child ( label ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-06 14:00:16 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										label - > set_h_size_flags ( Control : : SIZE_EXPAND_FILL ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-18 13:31:44 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										rotation_step  =  memnew ( SpinBox ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-02-15 18:00:55 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										rotation_step - > set_min ( - SPIN_BOX_ROTATION_RANGE ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										rotation_step - > set_max ( SPIN_BOX_ROTATION_RANGE ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										rotation_step - > set_suffix ( " deg " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-06 14:00:16 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										rotation_step - > set_h_size_flags ( Control : : SIZE_EXPAND_FILL ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-16 20:37:35 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										rotation_step - > set_select_all_on_focus ( true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-02-15 18:00:55 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										child_container - > add_child ( rotation_step ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-30 15:18:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										container - > add_child ( memnew ( HSeparator ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										child_container  =  memnew ( GridContainer ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										child_container - > set_columns ( 2 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										container - > add_child ( child_container ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										label  =  memnew ( Label ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										label - > set_text ( TTR ( " Scale Step: " ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										child_container - > add_child ( label ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-06 14:00:16 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										label - > set_h_size_flags ( Control : : SIZE_EXPAND_FILL ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-30 15:18:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										scale_step  =  memnew ( SpinBox ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										scale_step - > set_min ( SPIN_BOX_SCALE_MIN ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										scale_step - > set_max ( SPIN_BOX_SCALE_MAX ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										scale_step - > set_allow_greater ( true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-06 14:00:16 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										scale_step - > set_h_size_flags ( Control : : SIZE_EXPAND_FILL ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-30 15:18:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										scale_step - > set_step ( 0.01f ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-16 20:37:35 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										scale_step - > set_select_all_on_focus ( true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-30 15:18:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										child_container - > add_child ( scale_step ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-02-15 18:00:55 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2016-03-09 00:00:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-02 17:13:46 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									void  set_fields ( const  Point2  p_grid_offset ,  const  Point2  p_grid_step ,  const  Vector2i  p_primary_grid_step ,  const  real_t  p_rotation_offset ,  const  real_t  p_rotation_step ,  const  real_t  p_scale_step )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-01-04 01:16:14 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										grid_offset_x - > set_value ( p_grid_offset . x ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										grid_offset_y - > set_value ( p_grid_offset . y ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										grid_step_x - > set_value ( p_grid_step . x ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										grid_step_y - > set_value ( p_grid_step . y ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-02 17:13:46 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										primary_grid_step_x - > set_value ( p_primary_grid_step . x ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										primary_grid_step_y - > set_value ( p_primary_grid_step . y ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-13 17:45:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										rotation_offset - > set_value ( Math : : rad_to_deg ( p_rotation_offset ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										rotation_step - > set_value ( Math : : rad_to_deg ( p_rotation_step ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-30 15:18:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										scale_step - > set_value ( p_scale_step ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-02-15 18:00:55 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2016-03-09 00:00:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-02 17:13:46 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									void  get_fields ( Point2  & p_grid_offset ,  Point2  & p_grid_step ,  Vector2i  & p_primary_grid_step ,  real_t  & p_rotation_offset ,  real_t  & p_rotation_step ,  real_t  & p_scale_step )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-29 21:50:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										p_grid_offset  =  Point2 ( grid_offset_x - > get_value ( ) ,  grid_offset_y - > get_value ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										p_grid_step  =  Point2 ( grid_step_x - > get_value ( ) ,  grid_step_y - > get_value ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-02 17:13:46 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										p_primary_grid_step  =  Vector2i ( primary_grid_step_x - > get_value ( ) ,  primary_grid_step_y - > get_value ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-13 17:45:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										p_rotation_offset  =  Math : : deg_to_rad ( rotation_offset - > get_value ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										p_rotation_step  =  Math : : deg_to_rad ( rotation_step - > get_value ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-30 15:18:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										p_scale_step  =  scale_step - > get_value ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-02-15 18:00:55 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								} ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-04-06 08:42:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								bool  CanvasItemEditor : : _is_node_locked ( const  Node  * p_node )  const  {  
						 
					
						
							
								
									
										
										
										
											2022-04-01 20:30:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									return  p_node - > get_meta ( " _edit_lock_ " ,  false ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-10-16 20:35:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-10-25 19:08:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								bool  CanvasItemEditor : : _is_node_movable ( const  Node  * p_node ,  bool  p_popup_warning )  {  
						 
					
						
							
								
									
										
										
										
											2018-10-16 20:35:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( _is_node_locked ( p_node ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( Object : : cast_to < Control > ( p_node )  & &  Object : : cast_to < Container > ( p_node - > get_parent ( ) ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2018-10-25 19:08:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( p_popup_warning )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-26 20:38:29 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											EditorToaster : : get_singleton ( ) - > popup_str ( TTR ( " Children of a container get their position and size determined only by their parent. " ) ,  EditorToaster : : SEVERITY_WARNING ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-10-25 19:08:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2018-10-16 20:35:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-22 01:30:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-04-05 10:18:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : _snap_if_closer_float (  
						 
					
						
							
								
									
										
										
										
											2021-06-20 23:30:19 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										const  real_t  p_value , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										real_t  & r_current_snap ,  SnapTarget  & r_current_snap_target , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										const  real_t  p_target_value ,  const  SnapTarget  p_snap_target , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										const  real_t  p_radius )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									const  real_t  radius  =  p_radius  /  zoom ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									const  real_t  dist  =  Math : : abs ( p_value  -  p_target_value ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-05 10:18:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( ( p_radius  <  0  | |  dist  <  radius )  & &  ( r_current_snap_target  = =  SNAP_TARGET_NONE  | |  dist  <  Math : : abs ( r_current_snap  -  p_value ) ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										r_current_snap  =  p_target_value ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										r_current_snap_target  =  p_snap_target ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : _snap_if_closer_point (  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										Point2  p_value , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										Point2  & r_current_snap ,  SnapTarget  ( & r_current_snap_target ) [ 2 ] , 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-20 23:30:19 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Point2  p_target_value ,  const  SnapTarget  p_snap_target , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										const  real_t  rotation , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										const  real_t  p_radius )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-07 23:30:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Transform2D  rot_trans  =  Transform2D ( rotation ,  Point2 ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									p_value  =  rot_trans . inverse ( ) . xform ( p_value ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-05 10:18:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									p_target_value  =  rot_trans . inverse ( ) . xform ( p_target_value ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-07 23:30:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									r_current_snap  =  rot_trans . inverse ( ) . xform ( r_current_snap ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-04-05 10:18:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									_snap_if_closer_float ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											p_value . x , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											r_current_snap . x , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											r_current_snap_target [ 0 ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											p_target_value . x , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											p_snap_target , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											p_radius ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									_snap_if_closer_float ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											p_value . y , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											r_current_snap . y , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											r_current_snap_target [ 1 ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											p_target_value . y , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											p_snap_target , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											p_radius ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-07 23:30:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									r_current_snap  =  rot_trans . xform ( r_current_snap ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-04-05 10:18:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : _snap_other_nodes (  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										const  Point2  p_value , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										const  Transform2D  p_transform_to_snap , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										Point2  & r_current_snap ,  SnapTarget  ( & r_current_snap_target ) [ 2 ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										const  SnapTarget  p_snap_target ,  List < const  CanvasItem  * >  p_exceptions , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										const  Node  * p_current )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									const  CanvasItem  * ci  =  Object : : cast_to < CanvasItem > ( p_current ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-05 10:18:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									// Check if the element is in the exception
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									bool  exception  =  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-15 23:45:57 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									for  ( const  CanvasItem  * & E  :  p_exceptions )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if  ( E  = =  p_current )  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-05 10:18:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											exception  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( ci  & &  ! exception )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-18 17:16:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Transform2D  ci_transform  =  ci - > get_screen_transform ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-05 10:18:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( fmod ( ci_transform . get_rotation ( )  -  p_transform_to_snap . get_rotation ( ) ,  ( real_t ) 360.0 )  = =  0.0 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if  ( ci - > _edit_use_rect ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												Point2  begin  =  ci_transform . xform ( ci - > _edit_get_rect ( ) . get_position ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												Point2  end  =  ci_transform . xform ( ci - > _edit_get_rect ( ) . get_position ( )  +  ci - > _edit_get_rect ( ) . get_size ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-05 10:18:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												_snap_if_closer_point ( p_value ,  r_current_snap ,  r_current_snap_target ,  begin ,  p_snap_target ,  ci_transform . get_rotation ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												_snap_if_closer_point ( p_value ,  r_current_snap ,  r_current_snap_target ,  end ,  p_snap_target ,  ci_transform . get_rotation ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-08 21:35:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												Point2  position  =  ci_transform . xform ( Point2 ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-05 10:18:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												_snap_if_closer_point ( p_value ,  r_current_snap ,  r_current_snap_target ,  position ,  p_snap_target ,  ci_transform . get_rotation ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-08 21:35:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-07 23:30:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									for  ( int  i  =  0 ;  i  <  p_current - > get_child_count ( ) ;  i + + )  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-05 10:18:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										_snap_other_nodes ( p_value ,  p_transform_to_snap ,  r_current_snap ,  r_current_snap_target ,  p_snap_target ,  p_exceptions ,  p_current - > get_child ( i ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-07 23:30:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-08-01 16:47:20 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Point2  CanvasItemEditor : : snap_point ( Point2  p_target ,  unsigned  int  p_modes ,  unsigned  int  p_forced_modes ,  const  CanvasItem  * p_self_canvas_item ,  const  List < CanvasItem  * >  & p_other_nodes_exceptions )  {  
						 
					
						
							
								
									
										
										
										
											2019-04-05 10:18:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									snap_target [ 0 ]  =  SNAP_TARGET_NONE ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									snap_target [ 1 ]  =  SNAP_TARGET_NONE ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-06-08 23:24:00 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									bool  is_snap_active  =  smart_snap_active  ^  Input : : get_singleton ( ) - > is_key_pressed ( Key : : CMD_OR_CTRL ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-07 23:30:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									// Smart snap using the canvas position
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Vector2  output  =  p_target ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									real_t  rotation  =  0.0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-04-05 10:18:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( p_self_canvas_item )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-18 17:16:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										rotation  =  p_self_canvas_item - > get_screen_transform ( ) . get_rotation ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-07 23:30:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										// Parent sides and center
 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-27 18:30:39 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( ( is_snap_active  & &  snap_node_parent  & &  ( p_modes  &  SNAP_NODE_PARENT ) )  | |  ( p_forced_modes  &  SNAP_NODE_PARENT ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-05 10:18:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if  ( const  Control  * c  =  Object : : cast_to < Control > ( p_self_canvas_item ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-18 17:16:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												Point2  begin  =  p_self_canvas_item - > get_screen_transform ( ) . xform ( _anchor_to_position ( c ,  Point2 ( 0 ,  0 ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												Point2  end  =  p_self_canvas_item - > get_screen_transform ( ) . xform ( _anchor_to_position ( c ,  Point2 ( 1 ,  1 ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-05 10:18:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												_snap_if_closer_point ( p_target ,  output ,  snap_target ,  begin ,  SNAP_TARGET_PARENT ,  rotation ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												_snap_if_closer_point ( p_target ,  output ,  snap_target ,  ( begin  +  end )  /  2.0 ,  SNAP_TARGET_PARENT ,  rotation ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												_snap_if_closer_point ( p_target ,  output ,  snap_target ,  end ,  SNAP_TARGET_PARENT ,  rotation ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											}  else  if  ( const  CanvasItem  * parent_ci  =  Object : : cast_to < CanvasItem > ( p_self_canvas_item - > get_parent ( ) ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-08 21:35:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												if  ( parent_ci - > _edit_use_rect ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-05 10:18:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													Point2  begin  =  p_self_canvas_item - > get_transform ( ) . affine_inverse ( ) . xform ( parent_ci - > _edit_get_rect ( ) . get_position ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													Point2  end  =  p_self_canvas_item - > get_transform ( ) . affine_inverse ( ) . xform ( parent_ci - > _edit_get_rect ( ) . get_position ( )  +  parent_ci - > _edit_get_rect ( ) . get_size ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													_snap_if_closer_point ( p_target ,  output ,  snap_target ,  begin ,  SNAP_TARGET_PARENT ,  rotation ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													_snap_if_closer_point ( p_target ,  output ,  snap_target ,  ( begin  +  end )  /  2.0 ,  SNAP_TARGET_PARENT ,  rotation ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													_snap_if_closer_point ( p_target ,  output ,  snap_target ,  end ,  SNAP_TARGET_PARENT ,  rotation ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-08 21:35:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-05 10:18:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													Point2  position  =  p_self_canvas_item - > get_transform ( ) . affine_inverse ( ) . xform ( Point2 ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													_snap_if_closer_point ( p_target ,  output ,  snap_target ,  position ,  SNAP_TARGET_PARENT ,  rotation ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-08 21:35:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-07 23:30:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										// Self anchors
 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-27 18:30:39 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( ( is_snap_active  & &  snap_node_anchors  & &  ( p_modes  &  SNAP_NODE_ANCHORS ) )  | |  ( p_forced_modes  &  SNAP_NODE_ANCHORS ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-05 10:18:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if  ( const  Control  * c  =  Object : : cast_to < Control > ( p_self_canvas_item ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-18 17:16:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												Point2  begin  =  p_self_canvas_item - > get_screen_transform ( ) . xform ( _anchor_to_position ( c ,  Point2 ( c - > get_anchor ( SIDE_LEFT ) ,  c - > get_anchor ( SIDE_TOP ) ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												Point2  end  =  p_self_canvas_item - > get_screen_transform ( ) . xform ( _anchor_to_position ( c ,  Point2 ( c - > get_anchor ( SIDE_RIGHT ) ,  c - > get_anchor ( SIDE_BOTTOM ) ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-05 10:18:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												_snap_if_closer_point ( p_target ,  output ,  snap_target ,  begin ,  SNAP_TARGET_SELF_ANCHORS ,  rotation ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												_snap_if_closer_point ( p_target ,  output ,  snap_target ,  end ,  SNAP_TARGET_SELF_ANCHORS ,  rotation ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-07 23:30:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										// Self sides
 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-27 18:30:39 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( ( is_snap_active  & &  snap_node_sides  & &  ( p_modes  &  SNAP_NODE_SIDES ) )  | |  ( p_forced_modes  &  SNAP_NODE_SIDES ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-05 10:18:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if  ( p_self_canvas_item - > _edit_use_rect ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-18 17:16:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												Point2  begin  =  p_self_canvas_item - > get_screen_transform ( ) . xform ( p_self_canvas_item - > _edit_get_rect ( ) . get_position ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												Point2  end  =  p_self_canvas_item - > get_screen_transform ( ) . xform ( p_self_canvas_item - > _edit_get_rect ( ) . get_position ( )  +  p_self_canvas_item - > _edit_get_rect ( ) . get_size ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-05 10:18:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												_snap_if_closer_point ( p_target ,  output ,  snap_target ,  begin ,  SNAP_TARGET_SELF ,  rotation ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												_snap_if_closer_point ( p_target ,  output ,  snap_target ,  end ,  SNAP_TARGET_SELF ,  rotation ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-08 21:35:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-18 23:55:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										// Self center
 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-27 18:30:39 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( ( is_snap_active  & &  snap_node_center  & &  ( p_modes  &  SNAP_NODE_CENTER ) )  | |  ( p_forced_modes  &  SNAP_NODE_CENTER ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-05 10:18:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if  ( p_self_canvas_item - > _edit_use_rect ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-18 17:16:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												Point2  center  =  p_self_canvas_item - > get_screen_transform ( ) . xform ( p_self_canvas_item - > _edit_get_rect ( ) . get_center ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-05 10:18:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												_snap_if_closer_point ( p_target ,  output ,  snap_target ,  center ,  SNAP_TARGET_SELF ,  rotation ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-08 21:35:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-18 17:16:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												Point2  position  =  p_self_canvas_item - > get_screen_transform ( ) . xform ( Point2 ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-05 10:18:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												_snap_if_closer_point ( p_target ,  output ,  snap_target ,  position ,  SNAP_TARGET_SELF ,  rotation ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-08 21:35:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-18 23:55:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									// Other nodes sides
 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-27 18:30:39 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( ( is_snap_active  & &  snap_other_nodes  & &  ( p_modes  &  SNAP_OTHER_NODES ) )  | |  ( p_forced_modes  &  SNAP_OTHER_NODES ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-14 18:21:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Transform2D  to_snap_transform ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-05 10:18:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										List < const  CanvasItem  * >  exceptions  =  List < const  CanvasItem  * > ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-24 15:46:25 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										for  ( const  CanvasItem  * E  :  p_other_nodes_exceptions )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-15 23:45:57 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											exceptions . push_back ( E ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-05 10:18:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if  ( p_self_canvas_item )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											exceptions . push_back ( p_self_canvas_item ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-18 17:16:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											to_snap_transform  =  p_self_canvas_item - > get_screen_transform ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-05 10:18:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										_snap_other_nodes ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												p_target ,  to_snap_transform , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												output ,  snap_target , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												SNAP_TARGET_OTHER_NODE , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												exceptions , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												get_tree ( ) - > get_edited_scene_root ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-18 23:55:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-03-27 18:30:39 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( ( ( is_snap_active  & &  snap_guides  & &  ( p_modes  &  SNAP_GUIDES ) )  | |  ( p_forced_modes  &  SNAP_GUIDES ) )  & &  fmod ( rotation ,  ( real_t ) 360.0 )  = =  0.0 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-01 20:30:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										// Guides.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if  ( Node  * scene  =  EditorNode : : get_singleton ( ) - > get_edited_scene ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											Array  vguides  =  scene - > get_meta ( " _edit_vertical_guides_ " ,  Array ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-18 23:55:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											for  ( int  i  =  0 ;  i  <  vguides . size ( ) ;  i + + )  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-05 10:18:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												_snap_if_closer_float ( p_target . x ,  output . x ,  snap_target [ 0 ] ,  vguides [ i ] ,  SNAP_TARGET_GUIDE ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-18 23:55:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-07 23:30:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-04-01 20:30:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											Array  hguides  =  scene - > get_meta ( " _edit_horizontal_guides_ " ,  Array ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-18 23:55:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											for  ( int  i  =  0 ;  i  <  hguides . size ( ) ;  i + + )  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-05 10:18:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												_snap_if_closer_float ( p_target . y ,  output . y ,  snap_target [ 1 ] ,  hguides [ i ] ,  SNAP_TARGET_GUIDE ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-18 23:55:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-07 23:30:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-10-10 19:41:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( ( ( grid_snap_active  & &  ( p_modes  &  SNAP_GRID ) )  | |  ( p_forced_modes  &  SNAP_GRID ) )  & &  fmod ( rotation ,  ( real_t ) 360.0 )  = =  0.0 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-07 23:30:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										// Grid
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										Point2  offset  =  grid_offset ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if  ( snap_relative )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											List < CanvasItem  * >  selection  =  _get_edited_canvas_items ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-15 15:18:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if  ( selection . size ( )  = =  1  & &  Object : : cast_to < Node2D > ( selection . front ( ) - > get ( ) ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												offset  =  Object : : cast_to < Node2D > ( selection . front ( ) - > get ( ) ) - > get_global_position ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											}  else  if  ( selection . size ( )  >  0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												offset  =  _get_encompassing_rect_from_list ( selection ) . position ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-07 23:30:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										Point2  grid_output ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-12-21 18:02:57 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										grid_output . x  =  Math : : snapped ( p_target . x  -  offset . x ,  grid_step . x  *  Math : : pow ( 2.0 ,  grid_step_multiplier ) )  +  offset . x ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										grid_output . y  =  Math : : snapped ( p_target . y  -  offset . y ,  grid_step . y  *  Math : : pow ( 2.0 ,  grid_step_multiplier ) )  +  offset . y ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-05 10:18:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										_snap_if_closer_point ( p_target ,  output ,  snap_target ,  grid_output ,  SNAP_TARGET_GRID ,  0.0 ,  - 1.0 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-17 22:52:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( ( ( snap_pixel  & &  ( p_modes  &  SNAP_PIXEL ) )  | |  ( p_forced_modes  &  SNAP_PIXEL ) )  & &  rotation  = =  0.0 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-07 23:30:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										// Pixel
 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-03 14:37:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										output  =  output . snappedf ( 1 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-07 23:30:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-04-05 10:18:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									snap_transform  =  Transform2D ( rotation ,  output ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-09-07 23:30:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									return  output ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-06-20 23:30:19 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								real_t  CanvasItemEditor : : snap_angle ( real_t  p_target ,  real_t  p_start )  const  {  
						 
					
						
							
								
									
										
										
										
											2023-06-08 23:24:00 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( ( ( smart_snap_active  | |  snap_rotation )  ^  Input : : get_singleton ( ) - > is_key_pressed ( Key : : CMD_OR_CTRL ) )  & &  snap_rotation_step  ! =  0 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 17:47:24 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( snap_relative )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-12-21 18:02:57 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											return  Math : : snapped ( p_target  -  snap_rotation_offset ,  snap_rotation_step )  +  snap_rotation_offset  +  ( p_start  -  ( int ) ( p_start  /  snap_rotation_step )  *  snap_rotation_step ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 17:47:24 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-12-21 18:02:57 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											return  Math : : snapped ( p_target  -  snap_rotation_offset ,  snap_rotation_step )  +  snap_rotation_offset ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 17:47:24 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										return  p_target ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-07 23:30:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-11 15:59:52 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : shortcut_input ( const  Ref < InputEvent >  & p_ev )  {  
						 
					
						
							
								
									
										
										
										
											2021-04-05 08:52:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_COND ( p_ev . is_null ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-05-20 12:38:03 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Ref < InputEventKey >  k  =  p_ev ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( ! is_visible_in_tree ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-15 21:22:01 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-09-17 11:46:04 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( k . is_valid ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-13 16:31:57 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( k - > get_keycode ( )  = =  Key : : CTRL  | |  k - > get_keycode ( )  = =  Key : : ALT  | |  k - > get_keycode ( )  = =  Key : : SHIFT )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-13 23:21:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											viewport - > queue_redraw ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-17 11:46:04 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-06-08 23:24:00 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( k - > is_pressed ( )  & &  ! k - > is_command_or_control_pressed ( )  & &  ! k - > is_echo ( )  & &  ( grid_snap_active  | |  _is_grid_visible ( ) ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-09 17:53:39 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if  ( multiply_grid_step_shortcut . is_valid ( )  & &  multiply_grid_step_shortcut - > matches_event ( p_ev ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-17 11:46:04 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												// Multiply the grid size
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												grid_step_multiplier  =  MIN ( grid_step_multiplier  +  1 ,  12 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-13 23:21:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												viewport - > queue_redraw ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-09 17:53:39 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											}  else  if  ( divide_grid_step_shortcut . is_valid ( )  & &  divide_grid_step_shortcut - > matches_event ( p_ev ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-17 11:46:04 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												// Divide the grid size
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												Point2  new_grid_step  =  grid_step  *  Math : : pow ( 2.0 ,  grid_step_multiplier  -  1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												if  ( new_grid_step . x  > =  1.0  & &  new_grid_step . y  > =  1.0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													grid_step_multiplier - - ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-13 23:21:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												viewport - > queue_redraw ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2015-06-12 13:53:18 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								Object  * CanvasItemEditor : : _get_editor_data ( Object  * p_what )  {  
						 
					
						
							
								
									
										
										
										
											2017-08-24 22:58:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									CanvasItem  * ci  =  Object : : cast_to < CanvasItem > ( p_what ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( ! ci )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-04-02 01:20:12 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return  memnew ( CanvasItemEditorSelectedItem ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : _keying_changed ( )  {  
						 
					
						
							
								
									
										
										
										
											2023-04-24 12:46:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									AnimationTrackEditor  * te  =  AnimationPlayerEditor : : get_singleton ( ) - > get_track_editor ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( te  & &  te - > is_visible_in_tree ( )  & &  te - > get_current_animation ( ) . is_valid ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										animation_hb - > show ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										animation_hb - > hide ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2017-10-18 23:55:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-08-01 16:47:20 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Rect2  CanvasItemEditor : : _get_encompassing_rect_from_list ( const  List < CanvasItem  * >  & p_list )  {  
						 
					
						
							
								
									
										
										
										
											2020-12-15 12:04:21 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_COND_V ( p_list . is_empty ( ) ,  Rect2 ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-02-15 18:00:55 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// Handles the first element
 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									CanvasItem  * ci  =  p_list . front ( ) - > get ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Rect2  rect  =  Rect2 ( ci - > get_global_transform_with_canvas ( ) . xform ( ci - > _edit_get_rect ( ) . get_center ( ) ) ,  Size2 ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-02-15 18:00:55 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-03-08 21:35:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// Expand with the other ones
 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									for  ( CanvasItem  * ci2  :  p_list )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										Transform2D  xform  =  ci2 - > get_global_transform_with_canvas ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-08 21:35:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Rect2  current_rect  =  ci2 - > _edit_get_rect ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-07-29 23:09:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										rect . expand_to ( xform . xform ( current_rect . position ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										rect . expand_to ( xform . xform ( current_rect . position  +  Vector2 ( current_rect . size . x ,  0 ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										rect . expand_to ( xform . xform ( current_rect . position  +  current_rect . size ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										rect . expand_to ( xform . xform ( current_rect . position  +  Vector2 ( 0 ,  current_rect . size . y ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-29 21:50:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									return  rect ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2017-10-18 23:55:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-07-29 23:09:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : _expand_encompassing_rect_using_children ( Rect2  & r_rect ,  const  Node  * p_node ,  bool  & r_first ,  const  Transform2D  & p_parent_xform ,  const  Transform2D  & p_canvas_xform ,  bool  include_locked_nodes )  {  
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( ! p_node )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( Object : : cast_to < Viewport > ( p_node ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-19 18:29:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									const  CanvasItem  * ci  =  Object : : cast_to < CanvasItem > ( p_node ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-04-23 21:43:02 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-03-08 21:35:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									for  ( int  i  =  p_node - > get_child_count ( )  -  1 ;  i  > =  0 ;  i - - )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( ci  & &  ! ci - > is_set_as_top_level ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											_expand_encompassing_rect_using_children ( r_rect ,  p_node - > get_child ( i ) ,  r_first ,  p_parent_xform  *  ci - > get_transform ( ) ,  p_canvas_xform ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-08 21:35:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											const  CanvasLayer  * cl  =  Object : : cast_to < CanvasLayer > ( p_node ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											_expand_encompassing_rect_using_children ( r_rect ,  p_node - > get_child ( i ) ,  r_first ,  Transform2D ( ) ,  cl  ?  cl - > get_transform ( )  :  p_canvas_xform ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2016-09-07 11:10:00 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( ci  & &  ci - > is_visible_in_tree ( )  & &  ( include_locked_nodes  | |  ! _is_node_locked ( ci ) ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-17 15:03:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Transform2D  xform  =  p_canvas_xform ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( ! ci - > is_set_as_top_level ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-17 15:03:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											xform  * =  p_parent_xform ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										xform  * =  ci - > get_transform ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										Rect2  rect  =  ci - > _edit_get_rect ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-07-29 23:09:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( r_first )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-21 00:33:52 +05:45 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											r_rect  =  Rect2 ( xform . xform ( rect . get_center ( ) ) ,  Size2 ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-07-29 23:09:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											r_first  =  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2018-07-29 23:09:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										r_rect . expand_to ( xform . xform ( rect . position ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										r_rect . expand_to ( xform . xform ( rect . position  +  Point2 ( rect . size . x ,  0 ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										r_rect . expand_to ( xform . xform ( rect . position  +  Point2 ( 0 ,  rect . size . y ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										r_rect . expand_to ( xform . xform ( rect . position  +  rect . size ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-09-07 11:10:00 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-03-08 21:35:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Rect2  CanvasItemEditor : : _get_encompassing_rect ( const  Node  * p_node )  {  
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Rect2  rect ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									bool  first  =  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-08 21:35:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									_expand_encompassing_rect_using_children ( rect ,  p_node ,  first ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									return  rect ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-04-07 12:59:50 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-10-16 20:35:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : _find_canvas_items_at_pos ( const  Point2  & p_pos ,  Node  * p_node ,  Vector < _SelectResult >  & r_items ,  const  Transform2D  & p_parent_xform ,  const  Transform2D  & p_canvas_xform )  {  
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( ! p_node )  { 
							 
						 
					
						
							
								
									
										
										
										
											2015-11-04 22:39:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2015-11-04 22:39:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-08-23 17:59:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									const  real_t  grab_distance  =  EDITOR_GET ( " editors/polygon_editor/point_grab_radius " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									CanvasItem  * ci  =  Object : : cast_to < CanvasItem > ( p_node ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-11-04 22:39:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-11-18 17:16:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Transform2D  xform  =  p_canvas_xform ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( CanvasLayer  * cl  =  Object : : cast_to < CanvasLayer > ( p_node ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										xform  =  cl - > get_transform ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}  else  if  ( Viewport  * vp  =  Object : : cast_to < Viewport > ( p_node ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-12-02 15:36:17 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( ! vp - > is_visible_subviewport ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-18 17:16:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										xform  =  vp - > get_popup_base_transform ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-02-04 12:38:06 +11:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( ! vp - > get_visible_rect ( ) . has_point ( xform . affine_inverse ( ) . xform ( p_pos ) ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-18 17:16:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-05-04 00:27:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									for  ( int  i  =  p_node - > get_child_count ( )  -  1 ;  i  > =  0 ;  i - - )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( ci )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if  ( ! ci - > is_set_as_top_level ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-18 17:16:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												_find_canvas_items_at_pos ( p_pos ,  p_node - > get_child ( i ) ,  r_items ,  p_parent_xform  *  ci - > get_transform ( ) ,  xform ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-19 11:05:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-18 17:16:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												_find_canvas_items_at_pos ( p_pos ,  p_node - > get_child ( i ) ,  r_items ,  ci - > get_transform ( ) ,  xform ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-19 11:05:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2018-05-04 00:27:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-18 17:16:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											_find_canvas_items_at_pos ( p_pos ,  p_node - > get_child ( i ) ,  r_items ,  Transform2D ( ) ,  xform ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-11-04 22:39:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2018-05-04 00:27:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2015-11-04 22:39:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( ci  & &  ci - > is_visible_in_tree ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if  ( ! ci - > is_set_as_top_level ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-17 15:03:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											xform  * =  p_parent_xform ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										xform  =  ( xform  *  ci - > get_transform ( ) ) . affine_inverse ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-01-24 20:43:11 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										const  real_t  local_grab_distance  =  xform . basis_xform ( Vector2 ( grab_distance ,  0 ) ) . length ( )  /  zoom ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( ci - > _edit_is_selected_on_click ( xform . xform ( p_pos ) ,  local_grab_distance ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											Node2D  * node  =  Object : : cast_to < Node2D > ( ci ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-11-04 22:39:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-05-04 00:27:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											_SelectResult  res ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											res . item  =  ci ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-05-04 00:27:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											res . z_index  =  node  ?  node - > get_z_index ( )  :  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											res . has_z  =  node ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											r_items . push_back ( res ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-11-04 22:39:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-02-11 00:01:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : _get_canvas_items_at_pos ( const  Point2  & p_pos ,  Vector < _SelectResult >  & r_items ,  bool  p_allow_locked )  {  
						 
					
						
							
								
									
										
										
										
											2022-01-27 10:36:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Node  * scene  =  EditorNode : : get_singleton ( ) - > get_edited_scene ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-04-24 21:55:28 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-10-16 20:35:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									_find_canvas_items_at_pos ( p_pos ,  scene ,  r_items ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-04-24 21:55:28 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									//Remove invalid results
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									for  ( int  i  =  0 ;  i  <  r_items . size ( ) ;  i + + )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										Node  * node  =  r_items [ i ] . item ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-05-04 00:27:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										// Make sure the selected node is in the current scene, or editable
 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-21 09:19:48 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( node  & &  node  ! =  get_tree ( ) - > get_edited_scene_root ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											node  =  scene - > get_deepest_editable_node ( node ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2018-04-24 21:55:28 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										CanvasItem  * ci  =  Object : : cast_to < CanvasItem > ( node ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-11 00:01:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( ! p_allow_locked )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-10 13:59:24 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											// Replace the node by the group if grouped
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											while  ( node  & &  node  ! =  scene - > get_parent ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												CanvasItem  * ci_tmp  =  Object : : cast_to < CanvasItem > ( node ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												if  ( ci_tmp  & &  node - > has_meta ( " _edit_group_ " ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													ci  =  ci_tmp ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-10 13:59:24 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												node  =  node - > get_parent ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-04-24 21:55:28 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-05-15 09:37:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										// Check if the canvas item is already in the list (for groups or scenes)
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										bool  duplicate  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										for  ( int  j  =  0 ;  j  <  i ;  j + + )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if  ( r_items [ j ] . item  = =  ci )  { 
							 
						 
					
						
							
								
									
										
										
										
											2018-05-15 09:37:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												duplicate  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-04-24 21:55:28 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										//Remove the item if invalid
 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( ! ci  | |  duplicate  | |  ( ci  ! =  scene  & &  ci - > get_owner ( )  ! =  scene  & &  ! scene - > is_editable_instance ( ci - > get_owner ( ) ) )  | |  ( ! p_allow_locked  & &  _is_node_locked ( ci ) ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-03 16:17:03 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											r_items . remove_at ( i ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-04-24 21:55:28 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											i - - ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											r_items . write [ i ] . item  =  ci ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-04-24 21:55:28 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-03-08 21:35:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : _find_canvas_items_in_rect ( const  Rect2  & p_rect ,  Node  * p_node ,  List < CanvasItem  * >  * r_items ,  const  Transform2D  & p_parent_xform ,  const  Transform2D  & p_canvas_xform )  {  
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( ! p_node )  { 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									CanvasItem  * ci  =  Object : : cast_to < CanvasItem > ( p_node ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 10:36:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Node  * scene  =  EditorNode : : get_singleton ( ) - > get_edited_scene ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-03-30 15:56:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( p_node  ! =  scene  & &  ! p_node - > get_owner ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-21 09:19:48 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									bool  editable  =  p_node  = =  scene  | |  p_node - > get_owner ( )  = =  scene  | |  p_node  = =  scene - > get_deepest_editable_node ( p_node ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-01 20:30:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									bool  lock_children  =  p_node - > get_meta ( " _edit_group_ " ,  false ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-10-16 20:35:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									bool  locked  =  _is_node_locked ( p_node ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-11-18 17:16:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Transform2D  xform  =  p_canvas_xform ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( CanvasLayer  * cl  =  Object : : cast_to < CanvasLayer > ( p_node ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										xform  =  cl - > get_transform ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}  else  if  ( Viewport  * vp  =  Object : : cast_to < Viewport > ( p_node ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-12-02 15:36:17 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( ! vp - > is_visible_subviewport ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-18 17:16:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										xform  =  vp - > get_popup_base_transform ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-02-04 12:38:06 +11:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( ! vp - > get_visible_rect ( ) . intersects ( xform . affine_inverse ( ) . xform ( p_rect ) ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-18 17:16:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-05-04 00:27:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( ! lock_children  | |  ! editable )  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-12 22:43:31 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										for  ( int  i  =  p_node - > get_child_count ( )  -  1 ;  i  > =  0 ;  i - - )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if  ( ci )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												if  ( ! ci - > is_set_as_top_level ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-18 17:16:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													_find_canvas_items_in_rect ( p_rect ,  p_node - > get_child ( i ) ,  r_items ,  p_parent_xform  *  ci - > get_transform ( ) ,  xform ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-19 11:05:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-18 17:16:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													_find_canvas_items_in_rect ( p_rect ,  p_node - > get_child ( i ) ,  r_items ,  ci - > get_transform ( ) ,  xform ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-19 11:05:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												CanvasLayer  * cl  =  Object : : cast_to < CanvasLayer > ( p_node ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-18 17:16:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												_find_canvas_items_in_rect ( p_rect ,  p_node - > get_child ( i ) ,  r_items ,  Transform2D ( ) ,  cl  ?  cl - > get_transform ( )  :  xform ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-12 22:43:31 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( ci  & &  ci - > is_visible_in_tree ( )  & &  ! locked  & &  editable )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if  ( ! ci - > is_set_as_top_level ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-17 15:03:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											xform  * =  p_parent_xform ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										xform  * =  ci - > get_transform ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( ci - > _edit_use_rect ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											Rect2  rect  =  ci - > _edit_get_rect ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-08 21:35:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if  ( p_rect . has_point ( xform . xform ( rect . position ) )  & & 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													p_rect . has_point ( xform . xform ( rect . position  +  Vector2 ( rect . size . x ,  0 ) ) )  & & 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													p_rect . has_point ( xform . xform ( rect . position  +  Vector2 ( rect . size . x ,  rect . size . y ) ) )  & & 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													p_rect . has_point ( xform . xform ( rect . position  +  Vector2 ( 0 ,  rect . size . y ) ) ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												r_items - > push_back ( ci ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-08 21:35:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if  ( p_rect . has_point ( xform . xform ( Point2 ( ) ) ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												r_items - > push_back ( ci ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-08 21:35:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								bool  CanvasItemEditor : : _select_click_on_item ( CanvasItem  * item ,  Point2  p_click_pos ,  bool  p_append )  {  
						 
					
						
							
								
									
										
										
										
											2017-07-18 20:17:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									bool  still_selected  =  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-12-01 06:40:29 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									const  List < Node  * >  & top_node_list  =  editor_selection - > get_top_selected_node_list ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( p_append  & &  ! top_node_list . is_empty ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2015-11-04 22:39:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( editor_selection - > is_selected ( item ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-07-18 20:17:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											// Already in the selection, remove it from the selected nodes
 
							 
						 
					
						
							
								
									
										
										
										
											2015-11-04 22:39:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											editor_selection - > remove_node ( item ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-07-18 20:17:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											still_selected  =  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-13 18:09:53 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-12-01 06:40:29 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if  ( top_node_list . size ( )  = =  1 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												EditorNode : : get_singleton ( ) - > push_item ( top_node_list . front ( ) - > get ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-13 18:09:53 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2017-07-18 20:17:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											// Add the item to the selection
 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											editor_selection - > add_node ( item ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-11-04 22:39:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if  ( ! editor_selection - > is_selected ( item ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-07-18 20:17:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											// Select a new one and clear previous selection
 
							 
						 
					
						
							
								
									
										
										
										
											2015-11-04 22:39:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											editor_selection - > clear ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											editor_selection - > add_node ( item ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-07-18 20:17:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											// Reselect
 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-19 01:02:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if  ( Engine : : get_singleton ( ) - > is_editor_hint ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-11-19 16:02:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												selected_from_canvas  =  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-11-04 22:39:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2017-07-18 20:17:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-13 23:21:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									viewport - > queue_redraw ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-07-18 20:17:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									return  still_selected ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-11-04 22:39:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-06-27 18:41:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								List < CanvasItem  * >  CanvasItemEditor : : _get_edited_canvas_items ( bool  p_retrieve_locked ,  bool  p_remove_canvas_item_if_parent_in_selection ,  bool  * r_has_locked_items )  const  {  
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									List < CanvasItem  * >  selection ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-09 14:13:42 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									for  ( const  KeyValue < Node  * ,  Object  * >  & E  :  editor_selection - > get_selection ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										CanvasItem  * ci  =  Object : : cast_to < CanvasItem > ( E . key ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-27 18:41:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( ci )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-18 17:16:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if  ( ci - > is_visible_in_tree ( )  & &  ( p_retrieve_locked  | |  ! _is_node_locked ( ci ) ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-12-02 15:36:17 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												Viewport  * vp  =  ci - > get_viewport ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												if  ( vp  & &  ! vp - > is_visible_subviewport ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-27 18:41:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												CanvasItemEditorSelectedItem  * se  =  editor_selection - > get_node_editor_data < CanvasItemEditorSelectedItem > ( ci ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												if  ( se )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													selection . push_back ( ci ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											}  else  if  ( r_has_locked_items )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												// CanvasItem is selected, but can't be interacted with.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												* r_has_locked_items  =  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-06-27 18:41:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( p_remove_canvas_item_if_parent_in_selection )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										List < CanvasItem  * >  filtered_selection ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-15 23:45:57 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										for  ( CanvasItem  * E  :  selection )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if  ( ! selection . find ( E - > get_parent ( ) ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												filtered_selection . push_back ( E ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										return  filtered_selection ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										return  selection ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Vector2  CanvasItemEditor : : _anchor_to_position ( const  Control  * p_control ,  Vector2  anchor )  {  
						 
					
						
							
								
									
										
										
										
											2023-09-09 17:24:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_NULL_V ( p_control ,  Vector2 ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Transform2D  parent_transform  =  p_control - > get_transform ( ) . affine_inverse ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-05-05 16:59:00 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Rect2  parent_rect  =  p_control - > get_parent_anchorable_rect ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-09-03 14:22:16 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( p_control - > is_layout_rtl ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										return  parent_transform . xform ( parent_rect . position  +  Vector2 ( parent_rect . size . x  -  parent_rect . size . x  *  anchor . x ,  parent_rect . size . y  *  anchor . y ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										return  parent_transform . xform ( parent_rect . position  +  Vector2 ( parent_rect . size . x  *  anchor . x ,  parent_rect . size . y  *  anchor . y ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2017-07-11 00:14:22 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-09-07 23:30:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Vector2  CanvasItemEditor : : _position_to_anchor ( const  Control  * p_control ,  Vector2  position )  {  
						 
					
						
							
								
									
										
										
										
											2023-09-09 17:24:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_NULL_V ( p_control ,  Vector2 ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-07-29 16:57:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-05-05 16:59:00 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Rect2  parent_rect  =  p_control - > get_parent_anchorable_rect ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-11-14 18:21:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Vector2  output ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-03 14:22:16 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( p_control - > is_layout_rtl ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										output . x  =  ( parent_rect . size . x  = =  0 )  ?  0.0  :  ( parent_rect . size . x  -  p_control - > get_transform ( ) . xform ( position ) . x  -  parent_rect . position . x )  /  parent_rect . size . x ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										output . x  =  ( parent_rect . size . x  = =  0 )  ?  0.0  :  ( p_control - > get_transform ( ) . xform ( position ) . x  -  parent_rect . position . x )  /  parent_rect . size . x ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-27 17:44:06 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									output . y  =  ( parent_rect . size . y  = =  0 )  ?  0.0  :  ( p_control - > get_transform ( ) . xform ( position ) . y  -  parent_rect . position . y )  /  parent_rect . size . y ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return  output ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-07-29 16:57:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-08-01 16:47:20 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : _save_canvas_item_state ( const  List < CanvasItem  * >  & p_canvas_items ,  bool  save_bones )  {  
						 
					
						
							
								
									
										
										
										
											2022-07-05 13:06:12 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									original_transform  =  Transform2D ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									bool  transform_stored  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									for  ( CanvasItem  * ci  :  p_canvas_items )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										CanvasItemEditorSelectedItem  * se  =  editor_selection - > get_node_editor_data < CanvasItemEditorSelectedItem > ( ci ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( se )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-05 13:06:12 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if  ( ! transform_stored )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												original_transform  =  ci - > get_global_transform ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-05 13:06:12 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												transform_stored  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											se - > undo_state  =  ci - > _edit_get_state ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-18 17:16:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											se - > pre_drag_xform  =  ci - > get_screen_transform ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if  ( ci - > _edit_use_rect ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												se - > pre_drag_rect  =  ci - > _edit_get_rect ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-08 21:35:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												se - > pre_drag_rect  =  Rect2 ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2017-07-29 16:57:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-08-01 16:47:20 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : _restore_canvas_item_state ( const  List < CanvasItem  * >  & p_canvas_items ,  bool  restore_bones )  {  
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									for  ( CanvasItem  * ci  :  drag_selection )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										CanvasItemEditorSelectedItem  * se  =  editor_selection - > get_node_editor_data < CanvasItemEditorSelectedItem > ( ci ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										ci - > _edit_set_state ( se - > undo_state ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-02-15 13:25:58 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : _commit_canvas_item_state ( const  List < CanvasItem  * >  & p_canvas_items ,  const  String  & action_name ,  bool  commit_bones )  {  
						 
					
						
							
								
									
										
										
										
											2021-01-03 17:24:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									List < CanvasItem  * >  modified_canvas_items ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									for  ( CanvasItem  * ci  :  p_canvas_items )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										Dictionary  old_state  =  editor_selection - > get_node_editor_data < CanvasItemEditorSelectedItem > ( ci ) - > undo_state ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										Dictionary  new_state  =  ci - > _edit_get_state ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-03 17:24:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if  ( old_state . hash ( )  ! =  new_state . hash ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											modified_canvas_items . push_back ( ci ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-03 17:24:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( modified_canvas_items . is_empty ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-12-23 23:53:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									EditorUndoRedoManager  * undo_redo  =  EditorUndoRedoManager : : get_singleton ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-03 17:24:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									undo_redo - > create_action ( action_name ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									for  ( CanvasItem  * ci  :  modified_canvas_items )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										CanvasItemEditorSelectedItem  * se  =  editor_selection - > get_node_editor_data < CanvasItemEditorSelectedItem > ( ci ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-07 15:14:24 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( se )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											undo_redo - > add_do_method ( ci ,  " _edit_set_state " ,  ci - > _edit_get_state ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											undo_redo - > add_undo_method ( ci ,  " _edit_set_state " ,  se - > undo_state ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-07 15:14:24 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if  ( commit_bones )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-24 15:46:25 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												for  ( const  Dictionary  & F  :  se - > pre_drag_bones_undo_state )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													ci  =  Object : : cast_to < CanvasItem > ( ci - > get_parent ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													undo_redo - > add_do_method ( ci ,  " _edit_set_state " ,  ci - > _edit_get_state ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													undo_redo - > add_undo_method ( ci ,  " _edit_set_state " ,  F ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-07 15:14:24 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-13 23:21:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									undo_redo - > add_do_method ( viewport ,  " queue_redraw " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									undo_redo - > add_undo_method ( viewport ,  " queue_redraw " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									undo_redo - > commit_action ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-02-15 18:00:55 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : _snap_changed ( )  {  
						 
					
						
							
								
									
										
										
										
											2023-09-02 17:13:46 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									static_cast < SnapDialog  * > ( snap_dialog ) - > get_fields ( grid_offset ,  grid_step ,  primary_grid_step ,  snap_rotation_offset ,  snap_rotation_step ,  snap_scale_step ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-09 21:12:26 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									EditorSettings : : get_singleton ( ) - > set_project_metadata ( " 2d_editor " ,  " grid_offset " ,  grid_offset ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									EditorSettings : : get_singleton ( ) - > set_project_metadata ( " 2d_editor " ,  " grid_step " ,  grid_step ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-02 17:13:46 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									EditorSettings : : get_singleton ( ) - > set_project_metadata ( " 2d_editor " ,  " primary_grid_step " ,  primary_grid_step ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-09 21:12:26 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									EditorSettings : : get_singleton ( ) - > set_project_metadata ( " 2d_editor " ,  " snap_rotation_offset " ,  snap_rotation_offset ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									EditorSettings : : get_singleton ( ) - > set_project_metadata ( " 2d_editor " ,  " snap_rotation_step " ,  snap_rotation_step ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									EditorSettings : : get_singleton ( ) - > set_project_metadata ( " 2d_editor " ,  " snap_scale_step " ,  snap_scale_step ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-08-31 21:54:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									grid_step_multiplier  =  0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-13 23:21:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									viewport - > queue_redraw ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-02-15 18:00:55 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-11-04 22:39:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : _selection_result_pressed ( int  p_result )  {  
						 
					
						
							
								
									
										
										
										
											2023-02-24 21:17:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( selection_results_menu . size ( )  < =  p_result )  { 
							 
						 
					
						
							
								
									
										
										
										
											2015-11-04 22:39:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2015-11-04 22:39:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-02-24 21:17:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									CanvasItem  * item  =  selection_results_menu [ p_result ] . item ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-11-04 22:39:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( item )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										_select_click_on_item ( item ,  Point2 ( ) ,  selection_menu_additive_selection ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-24 21:17:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									selection_results_menu . clear ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-11-04 22:39:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : _selection_menu_hide ( )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									selection_results . clear ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									selection_menu - > clear ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-20 11:04:57 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									selection_menu - > reset_size ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-11-04 22:39:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-08-25 01:32:58 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : _add_node_pressed ( int  p_result )  {  
						 
					
						
							
								
									
										
										
										
											2022-01-18 16:35:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									List < Node  * >  nodes_to_move ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									switch  ( p_result )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case  ADD_NODE :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											SceneTreeDock : : get_singleton ( ) - > open_add_child_dialog ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}  break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case  ADD_INSTANCE :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											SceneTreeDock : : get_singleton ( ) - > open_instance_child_dialog ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}  break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case  ADD_PASTE :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											nodes_to_move  =  SceneTreeDock : : get_singleton ( ) - > paste_nodes ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											[[fallthrough]] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case  ADD_MOVE :  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-12-01 06:40:29 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											nodes_to_move  =  EditorNode : : get_singleton ( ) - > get_editor_selection ( ) - > get_top_selected_node_list ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-18 16:35:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if  ( nodes_to_move . is_empty ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-12-23 23:53:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											EditorUndoRedoManager  * undo_redo  =  EditorUndoRedoManager : : get_singleton ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-18 16:35:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											undo_redo - > create_action ( TTR ( " Move Node(s) to Position " ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											for  ( Node  * node  :  nodes_to_move )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												CanvasItem  * ci  =  Object : : cast_to < CanvasItem > ( node ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												if  ( ci )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													Transform2D  xform  =  ci - > get_global_transform_with_canvas ( ) . affine_inverse ( )  *  ci - > get_transform ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													undo_redo - > add_do_method ( ci ,  " _edit_set_position " ,  xform . xform ( node_create_position ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													undo_redo - > add_undo_method ( ci ,  " _edit_set_position " ,  ci - > _edit_get_position ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											undo_redo - > commit_action ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											_reset_create_position ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}  break ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-12-18 14:42:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										default :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if  ( p_result  > =  EditorContextMenuPlugin : : BASE_ID )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												TypedArray < Node >  nodes ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												nodes . resize ( selection_results . size ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												int  i  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												for  ( const  _SelectResult  & result  :  selection_results )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													nodes [ i ]  =  result . item ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													i + + ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												EditorContextMenuPluginManager : : get_singleton ( ) - > activate_custom_option ( EditorContextMenuPlugin : : CONTEXT_SLOT_2D_EDITOR ,  p_result ,  nodes ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-25 01:32:58 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 10:13:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : _adjust_new_node_position ( Node  * p_node )  {  
						 
					
						
							
								
									
										
										
										
											2020-08-25 01:32:58 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( node_create_position  = =  Point2 ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									CanvasItem  * c  =  Object : : cast_to < CanvasItem > ( p_node ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( c )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										Transform2D  xform  =  c - > get_global_transform_with_canvas ( ) . affine_inverse ( )  *  c - > get_transform ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										c - > _edit_set_position ( xform . xform ( node_create_position ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 15:46:56 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									callable_mp ( this ,  & CanvasItemEditor : : _reset_create_position ) . call_deferred ( ) ;  // Defer the call in case more than one node is added.
 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-25 01:32:58 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : _reset_create_position ( )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									node_create_position  =  Point2 ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-09 17:53:39 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								bool  CanvasItemEditor : : _is_grid_visible ( )  const  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									switch  ( grid_visibility )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case  GRID_VISIBILITY_SHOW : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case  GRID_VISIBILITY_SHOW_WHEN_SNAPPING : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											return  grid_snap_active ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case  GRID_VISIBILITY_HIDE : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_V_MSG ( true ,  " Unexpected grid_visibility value " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : _prepare_grid_menu ( )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									for  ( int  i  =  GRID_VISIBILITY_SHOW ;  i  < =  GRID_VISIBILITY_HIDE ;  i + + )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										grid_menu - > set_item_checked ( i ,  i  = =  grid_visibility ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : _on_grid_menu_id_pressed ( int  p_id )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									switch  ( p_id )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case  GRID_VISIBILITY_SHOW : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case  GRID_VISIBILITY_SHOW_WHEN_SNAPPING : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case  GRID_VISIBILITY_HIDE : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											grid_visibility  =  ( GridVisibility ) p_id ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-13 23:21:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											viewport - > queue_redraw ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-09 17:53:39 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											view_menu - > get_popup ( ) - > hide ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									// Toggle grid: go to the least restrictive option possible.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( grid_snap_active )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										switch  ( grid_visibility )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											case  GRID_VISIBILITY_SHOW : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											case  GRID_VISIBILITY_SHOW_WHEN_SNAPPING : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												grid_visibility  =  GRID_VISIBILITY_HIDE ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											case  GRID_VISIBILITY_HIDE : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												grid_visibility  =  GRID_VISIBILITY_SHOW_WHEN_SNAPPING ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										switch  ( grid_visibility )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											case  GRID_VISIBILITY_SHOW : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												grid_visibility  =  GRID_VISIBILITY_SHOW_WHEN_SNAPPING ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											case  GRID_VISIBILITY_SHOW_WHEN_SNAPPING : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											case  GRID_VISIBILITY_HIDE : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												grid_visibility  =  GRID_VISIBILITY_SHOW ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-13 23:21:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									viewport - > queue_redraw ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-09 17:53:39 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-06 16:11:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : _switch_theme_preview ( int  p_mode )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									view_menu - > get_popup ( ) - > hide ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( theme_preview  = =  p_mode )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									theme_preview  =  ( ThemePreviewMode ) p_mode ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									EditorSettings : : get_singleton ( ) - > set_project_metadata ( " 2d_editor " ,  " theme_preview " ,  theme_preview ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									for  ( int  i  =  0 ;  i  <  THEME_PREVIEW_MAX ;  i + + )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										theme_menu - > set_item_checked ( i ,  i  = =  theme_preview ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									EditorNode : : get_singleton ( ) - > update_preview_themes ( theme_preview ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								bool  CanvasItemEditor : : _gui_input_rulers_and_guides ( const  Ref < InputEvent >  & p_event )  {  
						 
					
						
							
								
									
										
										
										
											2022-12-23 23:53:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									EditorUndoRedoManager  * undo_redo  =  EditorUndoRedoManager : : get_singleton ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-18 23:55:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Ref < InputEventMouseButton >  b  =  p_event ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Ref < InputEventMouseMotion >  m  =  p_event ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( drag_type  = =  DRAG_NONE )  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-13 17:16:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( show_guides  & &  show_rulers  & &  EditorNode : : get_singleton ( ) - > get_edited_scene ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											Transform2D  xform  =  viewport_scrollable - > get_transform ( )  *  transform ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											// Retrieve the guide lists
 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-01 20:30:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											Array  vguides  =  EditorNode : : get_singleton ( ) - > get_edited_scene ( ) - > get_meta ( " _edit_vertical_guides_ " ,  Array ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											Array  hguides  =  EditorNode : : get_singleton ( ) - > get_edited_scene ( ) - > get_meta ( " _edit_horizontal_guides_ " ,  Array ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-13 17:16:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											// Hover over guides
 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-20 23:30:19 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											real_t  minimum  =  1e20 ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-13 17:16:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											is_hovering_h_guide  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											is_hovering_v_guide  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if  ( m . is_valid ( )  & &  m - > get_position ( ) . x  <  RULER_WIDTH )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												// Check if we are hovering an existing horizontal guide
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												for  ( int  i  =  0 ;  i  <  hguides . size ( ) ;  i + + )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-30 17:56:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													if  ( Math : : abs ( xform . xform ( Point2 ( 0 ,  hguides [ i ] ) ) . y  -  m - > get_position ( ) . y )  <  MIN ( minimum ,  8 ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-13 17:16:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														is_hovering_h_guide  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														is_hovering_v_guide  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													} 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-18 23:55:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-13 17:16:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											}  else  if  ( m . is_valid ( )  & &  m - > get_position ( ) . y  <  RULER_WIDTH )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												// Check if we are hovering an existing vertical guide
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												for  ( int  i  =  0 ;  i  <  vguides . size ( ) ;  i + + )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-30 17:56:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													if  ( Math : : abs ( xform . xform ( Point2 ( vguides [ i ] ,  0 ) ) . x  -  m - > get_position ( ) . x )  <  MIN ( minimum ,  8 ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-13 17:16:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														is_hovering_v_guide  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														is_hovering_h_guide  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													} 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-18 23:55:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-13 17:16:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											// Start dragging a guide
 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-13 16:31:57 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if  ( b . is_valid ( )  & &  b - > get_button_index ( )  = =  MouseButton : : LEFT  & &  b - > is_pressed ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-18 23:55:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												// Press button
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												if  ( b - > get_position ( ) . x  <  RULER_WIDTH  & &  b - > get_position ( ) . y  <  RULER_WIDTH )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													// Drag a new double guide
 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													drag_type  =  DRAG_DOUBLE_GUIDE ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													dragged_guide_index  =  - 1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													return  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-18 23:55:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												}  else  if  ( b - > get_position ( ) . x  <  RULER_WIDTH )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													// Check if we drag an existing horizontal guide
 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													dragged_guide_index  =  - 1 ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-18 23:55:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													for  ( int  i  =  0 ;  i  <  hguides . size ( ) ;  i + + )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-30 17:56:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														if  ( Math : : abs ( xform . xform ( Point2 ( 0 ,  hguides [ i ] ) ) . y  -  b - > get_position ( ) . y )  <  MIN ( minimum ,  8 ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
															dragged_guide_index  =  i ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-18 23:55:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													if  ( dragged_guide_index  > =  0 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-18 23:55:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														// Drag an existing horizontal guide
 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														drag_type  =  DRAG_H_GUIDE ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-18 23:55:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														// Drag a new vertical guide
 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														drag_type  =  DRAG_V_GUIDE ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-18 23:55:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													} 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													return  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-18 23:55:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												}  else  if  ( b - > get_position ( ) . y  <  RULER_WIDTH )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													// Check if we drag an existing vertical guide
 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													dragged_guide_index  =  - 1 ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-18 23:55:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													for  ( int  i  =  0 ;  i  <  vguides . size ( ) ;  i + + )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-30 17:56:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														if  ( Math : : abs ( xform . xform ( Point2 ( vguides [ i ] ,  0 ) ) . x  -  b - > get_position ( ) . x )  <  MIN ( minimum ,  8 ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
															dragged_guide_index  =  i ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-18 23:55:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													if  ( dragged_guide_index  > =  0 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-18 23:55:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														// Drag an existing vertical guide
 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														drag_type  =  DRAG_V_GUIDE ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-18 23:55:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														// Drag a new vertical guide
 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														drag_type  =  DRAG_H_GUIDE ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-18 23:55:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													} 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													drag_from  =  xform . affine_inverse ( ) . xform ( b - > get_position ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													return  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-18 23:55:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( drag_type  = =  DRAG_DOUBLE_GUIDE  | |  drag_type  = =  DRAG_V_GUIDE  | |  drag_type  = =  DRAG_H_GUIDE )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										// Move the guide
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if  ( m . is_valid ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											Transform2D  xform  =  viewport_scrollable - > get_transform ( )  *  transform ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											drag_to  =  xform . affine_inverse ( ) . xform ( m - > get_position ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-18 23:55:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											dragged_guide_pos  =  xform . xform ( snap_point ( drag_to ,  SNAP_GRID  |  SNAP_PIXEL  |  SNAP_OTHER_NODES ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-13 23:21:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											viewport - > queue_redraw ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										// Release confirms the guide move
 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-13 16:31:57 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( b . is_valid ( )  & &  b - > get_button_index ( )  = =  MouseButton : : LEFT  & &  ! b - > is_pressed ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-18 23:55:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if  ( show_guides  & &  EditorNode : : get_singleton ( ) - > get_edited_scene ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												Transform2D  xform  =  viewport_scrollable - > get_transform ( )  *  transform ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-01-18 21:37:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												// Retrieve the guide lists
 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-01 20:30:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												Array  vguides  =  EditorNode : : get_singleton ( ) - > get_edited_scene ( ) - > get_meta ( " _edit_vertical_guides_ " ,  Array ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												Array  hguides  =  EditorNode : : get_singleton ( ) - > get_edited_scene ( ) - > get_meta ( " _edit_horizontal_guides_ " ,  Array ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-18 23:55:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												Point2  edited  =  snap_point ( xform . affine_inverse ( ) . xform ( b - > get_position ( ) ) ,  SNAP_GRID  |  SNAP_PIXEL  |  SNAP_OTHER_NODES ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												if  ( drag_type  = =  DRAG_V_GUIDE )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-18 23:55:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													Array  prev_vguides  =  vguides . duplicate ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													if  ( b - > get_position ( ) . x  >  RULER_WIDTH )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														// Adds a new vertical guide
 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														if  ( dragged_guide_index  > =  0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															vguides [ dragged_guide_index ]  =  edited . x ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-13 17:16:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
															undo_redo - > create_action ( TTR ( " Move Vertical Guide " ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-18 23:55:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
															undo_redo - > add_do_method ( EditorNode : : get_singleton ( ) - > get_edited_scene ( ) ,  " set_meta " ,  " _edit_vertical_guides_ " ,  vguides ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															undo_redo - > add_undo_method ( EditorNode : : get_singleton ( ) - > get_edited_scene ( ) ,  " set_meta " ,  " _edit_vertical_guides_ " ,  prev_vguides ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-13 23:21:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
															undo_redo - > add_undo_method ( viewport ,  " queue_redraw " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-18 23:55:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
															undo_redo - > commit_action ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															vguides . push_back ( edited . x ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-13 17:16:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
															undo_redo - > create_action ( TTR ( " Create Vertical Guide " ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-18 23:55:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
															undo_redo - > add_do_method ( EditorNode : : get_singleton ( ) - > get_edited_scene ( ) ,  " set_meta " ,  " _edit_vertical_guides_ " ,  vguides ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-25 22:28:48 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
															if  ( prev_vguides . is_empty ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
																undo_redo - > add_undo_method ( EditorNode : : get_singleton ( ) - > get_edited_scene ( ) ,  " remove_meta " ,  " _edit_vertical_guides_ " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
																undo_redo - > add_undo_method ( EditorNode : : get_singleton ( ) - > get_edited_scene ( ) ,  " set_meta " ,  " _edit_vertical_guides_ " ,  prev_vguides ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															} 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-13 23:21:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
															undo_redo - > add_undo_method ( viewport ,  " queue_redraw " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-18 23:55:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
															undo_redo - > commit_action ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														if  ( dragged_guide_index  > =  0 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-03 16:17:03 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
															vguides . remove_at ( dragged_guide_index ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-13 17:16:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
															undo_redo - > create_action ( TTR ( " Remove Vertical Guide " ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-12-15 12:04:21 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
															if  ( vguides . is_empty ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-12-06 09:19:54 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
																undo_redo - > add_do_method ( EditorNode : : get_singleton ( ) - > get_edited_scene ( ) ,  " remove_meta " ,  " _edit_vertical_guides_ " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
																undo_redo - > add_do_method ( EditorNode : : get_singleton ( ) - > get_edited_scene ( ) ,  " set_meta " ,  " _edit_vertical_guides_ " ,  vguides ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															} 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-18 23:55:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
															undo_redo - > add_undo_method ( EditorNode : : get_singleton ( ) - > get_edited_scene ( ) ,  " set_meta " ,  " _edit_vertical_guides_ " ,  prev_vguides ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-13 23:21:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
															undo_redo - > add_undo_method ( viewport ,  " queue_redraw " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-18 23:55:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
															undo_redo - > commit_action ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													} 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												}  else  if  ( drag_type  = =  DRAG_H_GUIDE )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-18 23:55:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													Array  prev_hguides  =  hguides . duplicate ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													if  ( b - > get_position ( ) . y  >  RULER_WIDTH )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														// Adds a new horizontal guide
 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														if  ( dragged_guide_index  > =  0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															hguides [ dragged_guide_index ]  =  edited . y ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-13 17:16:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
															undo_redo - > create_action ( TTR ( " Move Horizontal Guide " ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-18 23:55:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
															undo_redo - > add_do_method ( EditorNode : : get_singleton ( ) - > get_edited_scene ( ) ,  " set_meta " ,  " _edit_horizontal_guides_ " ,  hguides ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															undo_redo - > add_undo_method ( EditorNode : : get_singleton ( ) - > get_edited_scene ( ) ,  " set_meta " ,  " _edit_horizontal_guides_ " ,  prev_hguides ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-13 23:21:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
															undo_redo - > add_undo_method ( viewport ,  " queue_redraw " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-18 23:55:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
															undo_redo - > commit_action ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															hguides . push_back ( edited . y ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-13 17:16:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
															undo_redo - > create_action ( TTR ( " Create Horizontal Guide " ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-18 23:55:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
															undo_redo - > add_do_method ( EditorNode : : get_singleton ( ) - > get_edited_scene ( ) ,  " set_meta " ,  " _edit_horizontal_guides_ " ,  hguides ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-25 22:28:48 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
															if  ( prev_hguides . is_empty ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
																undo_redo - > add_undo_method ( EditorNode : : get_singleton ( ) - > get_edited_scene ( ) ,  " remove_meta " ,  " _edit_horizontal_guides_ " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
																undo_redo - > add_undo_method ( EditorNode : : get_singleton ( ) - > get_edited_scene ( ) ,  " set_meta " ,  " _edit_horizontal_guides_ " ,  prev_hguides ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															} 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-13 23:21:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
															undo_redo - > add_undo_method ( viewport ,  " queue_redraw " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-18 23:55:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
															undo_redo - > commit_action ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														if  ( dragged_guide_index  > =  0 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-03 16:17:03 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
															hguides . remove_at ( dragged_guide_index ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-13 17:16:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
															undo_redo - > create_action ( TTR ( " Remove Horizontal Guide " ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-12-15 12:04:21 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
															if  ( hguides . is_empty ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-12-06 09:19:54 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
																undo_redo - > add_do_method ( EditorNode : : get_singleton ( ) - > get_edited_scene ( ) ,  " remove_meta " ,  " _edit_horizontal_guides_ " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
																undo_redo - > add_do_method ( EditorNode : : get_singleton ( ) - > get_edited_scene ( ) ,  " set_meta " ,  " _edit_horizontal_guides_ " ,  hguides ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															} 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-18 23:55:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
															undo_redo - > add_undo_method ( EditorNode : : get_singleton ( ) - > get_edited_scene ( ) ,  " set_meta " ,  " _edit_horizontal_guides_ " ,  prev_hguides ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-13 23:21:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
															undo_redo - > add_undo_method ( viewport ,  " queue_redraw " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-18 23:55:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
															undo_redo - > commit_action ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													} 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												}  else  if  ( drag_type  = =  DRAG_DOUBLE_GUIDE )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-18 23:55:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													Array  prev_hguides  =  hguides . duplicate ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													Array  prev_vguides  =  vguides . duplicate ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													if  ( b - > get_position ( ) . x  >  RULER_WIDTH  & &  b - > get_position ( ) . y  >  RULER_WIDTH )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														// Adds a new horizontal guide a new vertical guide
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														vguides . push_back ( edited . x ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														hguides . push_back ( edited . y ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-13 17:16:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														undo_redo - > create_action ( TTR ( " Create Horizontal and Vertical Guides " ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-18 23:55:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														undo_redo - > add_do_method ( EditorNode : : get_singleton ( ) - > get_edited_scene ( ) ,  " set_meta " ,  " _edit_vertical_guides_ " ,  vguides ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														undo_redo - > add_do_method ( EditorNode : : get_singleton ( ) - > get_edited_scene ( ) ,  " set_meta " ,  " _edit_horizontal_guides_ " ,  hguides ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-25 22:28:48 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														if  ( prev_vguides . is_empty ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															undo_redo - > add_undo_method ( EditorNode : : get_singleton ( ) - > get_edited_scene ( ) ,  " remove_meta " ,  " _edit_vertical_guides_ " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															undo_redo - > add_undo_method ( EditorNode : : get_singleton ( ) - > get_edited_scene ( ) ,  " set_meta " ,  " _edit_vertical_guides_ " ,  prev_vguides ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														if  ( prev_hguides . is_empty ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															undo_redo - > add_undo_method ( EditorNode : : get_singleton ( ) - > get_edited_scene ( ) ,  " remove_meta " ,  " _edit_horizontal_guides_ " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															undo_redo - > add_undo_method ( EditorNode : : get_singleton ( ) - > get_edited_scene ( ) ,  " set_meta " ,  " _edit_horizontal_guides_ " ,  prev_hguides ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														} 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-13 23:21:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														undo_redo - > add_undo_method ( viewport ,  " queue_redraw " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-18 23:55:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														undo_redo - > commit_action ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-12 14:37:20 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											snap_target [ 0 ]  =  SNAP_TARGET_NONE ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											snap_target [ 1 ]  =  SNAP_TARGET_NONE ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-14 14:51:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											_reset_drag ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-13 23:21:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											viewport - > queue_redraw ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											return  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-29 22:00:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									return  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-15 22:33:25 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-07-28 17:00:05 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								bool  CanvasItemEditor : : _gui_input_zoom_or_pan ( const  Ref < InputEvent >  & p_event ,  bool  p_already_accepted )  {  
						 
					
						
							
								
									
										
										
										
											2022-01-24 22:19:50 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									panner - > set_force_drag ( tool  = =  TOOL_PAN ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-03 10:39:22 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									bool  panner_active  =  panner - > gui_input ( p_event ,  viewport - > get_global_rect ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-19 19:59:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( panner - > is_panning ( )  ! =  pan_pressed )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										pan_pressed  =  panner - > is_panning ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-12 19:47:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										_update_cursor ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-19 19:59:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2018-04-22 23:27:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-19 19:59:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( panner_active )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										return  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-04-22 23:27:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Ref < InputEventKey >  k  =  p_event ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( k . is_valid ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-28 00:54:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( k - > is_pressed ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-15 16:26:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if  ( ED_IS_SHORTCUT ( " canvas_item_editor/zoom_3.125_percent " ,  p_event ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-15 16:48:55 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												_shortcut_zoom_set ( 1.0  /  32.0 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-15 16:26:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											}  else  if  ( ED_IS_SHORTCUT ( " canvas_item_editor/zoom_6.25_percent " ,  p_event ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-15 16:48:55 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												_shortcut_zoom_set ( 1.0  /  16.0 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-15 16:26:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											}  else  if  ( ED_IS_SHORTCUT ( " canvas_item_editor/zoom_12.5_percent " ,  p_event ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-15 16:48:55 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												_shortcut_zoom_set ( 1.0  /  8.0 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-15 16:26:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											}  else  if  ( ED_IS_SHORTCUT ( " canvas_item_editor/zoom_25_percent " ,  p_event ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-15 16:48:55 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												_shortcut_zoom_set ( 1.0  /  4.0 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-15 16:26:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											}  else  if  ( ED_IS_SHORTCUT ( " canvas_item_editor/zoom_50_percent " ,  p_event ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-15 16:48:55 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												_shortcut_zoom_set ( 1.0  /  2.0 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-15 16:26:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											}  else  if  ( ED_IS_SHORTCUT ( " canvas_item_editor/zoom_100_percent " ,  p_event ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-15 16:48:55 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												_shortcut_zoom_set ( 1.0 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-15 16:26:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											}  else  if  ( ED_IS_SHORTCUT ( " canvas_item_editor/zoom_200_percent " ,  p_event ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-15 16:48:55 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												_shortcut_zoom_set ( 2.0 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-15 16:26:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											}  else  if  ( ED_IS_SHORTCUT ( " canvas_item_editor/zoom_400_percent " ,  p_event ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-15 16:48:55 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												_shortcut_zoom_set ( 4.0 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-15 16:26:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											}  else  if  ( ED_IS_SHORTCUT ( " canvas_item_editor/zoom_800_percent " ,  p_event ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-15 16:48:55 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												_shortcut_zoom_set ( 8.0 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-15 16:26:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											}  else  if  ( ED_IS_SHORTCUT ( " canvas_item_editor/zoom_1600_percent " ,  p_event ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-15 16:48:55 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												_shortcut_zoom_set ( 16.0 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-28 00:54:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2015-12-28 09:38:15 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2014-07-06 11:49:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-01-19 17:50:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : _pan_callback ( Vector2  p_scroll_vec ,  Ref < InputEvent >  p_event )  {  
						 
					
						
							
								
									
										
										
										
											2022-01-19 19:59:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									view_offset . x  - =  p_scroll_vec . x  /  zoom ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									view_offset . y  - =  p_scroll_vec . y  /  zoom ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									update_viewport ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-01-19 17:50:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : _zoom_callback ( float  p_zoom_factor ,  Vector2  p_origin ,  Ref < InputEvent >  p_event )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Ref < InputEventMouseButton >  mb  =  p_event ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( mb . is_valid ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-07 12:59:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										// Special behavior for scroll events, as the zoom_by_increment method can smartly end up on powers of two.
 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-19 17:50:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										int  increment  =  p_zoom_factor  >  1.0  ?  1  :  - 1 ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-20 03:22:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										bool  by_integer  =  mb - > is_alt_pressed ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if  ( EDITOR_GET ( " editors/2d/use_integer_zoom_by_default " ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											by_integer  =  ! by_integer ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										zoom_widget - > set_zoom_by_increments ( increment ,  by_integer ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-19 17:50:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										zoom_widget - > set_zoom ( zoom_widget - > get_zoom ( )  *  p_zoom_factor ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-19 19:59:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-19 17:50:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-19 19:59:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									_zoom_on_position ( zoom_widget - > get_zoom ( ) ,  p_origin ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								bool  CanvasItemEditor : : _gui_input_pivot ( const  Ref < InputEvent >  & p_event )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Ref < InputEventMouseMotion >  m  =  p_event ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Ref < InputEventMouseButton >  b  =  p_event ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Ref < InputEventKey >  k  =  p_event ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-07-06 11:49:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// Drag the pivot (in pivot mode / with V key)
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( drag_type  = =  DRAG_NONE )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-21 01:22:11 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										bool  move_temp_pivot  =  ( ( b . is_valid ( )  & &  b - > is_shift_pressed ( ) )  | |  ( k . is_valid ( )  & &  k - > is_shift_pressed ( ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-08-13 16:31:57 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( ( b . is_valid ( )  & &  b - > is_pressed ( )  & &  b - > get_button_index ( )  = =  MouseButton : : LEFT  & &  tool  = =  TOOL_EDIT_PIVOT )  | | 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-21 01:22:11 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												( k . is_valid ( )  & &  k - > is_pressed ( )  & &  ! k - > is_echo ( )  & &  k - > get_keycode ( )  = =  Key : : V  & &  tool  = =  TOOL_SELECT  & &  ( k - > get_modifiers_mask ( ) . is_empty ( )  | |  move_temp_pivot ) ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											List < CanvasItem  * >  selection  =  _get_edited_canvas_items ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											// Filters the selection with nodes that allow setting the pivot
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											drag_selection  =  List < CanvasItem  * > ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											for  ( CanvasItem  * ci  :  selection )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-21 01:22:11 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												if  ( ci - > _edit_use_pivot ( )  | |  move_temp_pivot )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													drag_selection . push_back ( ci ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											// Start dragging if we still have nodes
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if  ( drag_selection . size ( )  >  0 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-21 01:22:11 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												Vector2  event_pos  =  ( b . is_valid ( ) )  ?  b - > get_position ( )  :  viewport - > get_local_mouse_position ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												if  ( move_temp_pivot )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													drag_type  =  DRAG_TEMP_PIVOT ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													temp_pivot  =  transform . affine_inverse ( ) . xform ( event_pos ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													viewport - > queue_redraw ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-11-05 05:59:03 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												_save_canvas_item_state ( drag_selection ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-21 01:22:11 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												drag_from  =  transform . affine_inverse ( ) . xform ( event_pos ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												Vector2  new_pos ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-05 10:18:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												if  ( drag_selection . size ( )  = =  1 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-15 15:18:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													new_pos  =  snap_point ( drag_from ,  SNAP_NODE_SIDES  |  SNAP_NODE_CENTER  |  SNAP_NODE_ANCHORS  |  SNAP_OTHER_NODES  |  SNAP_GRID  |  SNAP_PIXEL ,  0 ,  drag_selection . front ( ) - > get ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-05 10:18:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-04-02 01:20:12 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													new_pos  =  snap_point ( drag_from ,  SNAP_OTHER_NODES  |  SNAP_GRID  |  SNAP_PIXEL ,  0 ,  nullptr ,  drag_selection ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-05 10:18:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												for  ( CanvasItem  * ci  :  drag_selection )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-18 17:16:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													ci - > _edit_set_pivot ( ci - > get_screen_transform ( ) . affine_inverse ( ) . xform ( new_pos ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												drag_type  =  DRAG_PIVOT ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( drag_type  = =  DRAG_PIVOT )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										// Move the pivot
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if  ( m . is_valid ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											drag_to  =  transform . affine_inverse ( ) . xform ( m - > get_position ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											_restore_canvas_item_state ( drag_selection ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											Vector2  new_pos ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if  ( drag_selection . size ( )  = =  1 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-15 15:18:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												new_pos  =  snap_point ( drag_to ,  SNAP_NODE_SIDES  |  SNAP_NODE_CENTER  |  SNAP_NODE_ANCHORS  |  SNAP_OTHER_NODES  |  SNAP_GRID  |  SNAP_PIXEL ,  0 ,  drag_selection . front ( ) - > get ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												new_pos  =  snap_point ( drag_to ,  SNAP_OTHER_NODES  |  SNAP_GRID  |  SNAP_PIXEL ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											for  ( CanvasItem  * ci  :  drag_selection )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-18 17:16:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												ci - > _edit_set_pivot ( ci - > get_screen_transform ( ) . affine_inverse ( ) . xform ( new_pos ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										// Confirm the pivot move
 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-21 22:49:30 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( drag_selection . size ( )  > =  1  & & 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-13 16:31:57 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												( ( b . is_valid ( )  & &  ! b - > is_pressed ( )  & &  b - > get_button_index ( )  = =  MouseButton : : LEFT  & &  tool  = =  TOOL_EDIT_PIVOT )  | | 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														( k . is_valid ( )  & &  ! k - > is_pressed ( )  & &  k - > get_keycode ( )  = =  Key : : V ) ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-21 22:49:30 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											_commit_canvas_item_state ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													drag_selection , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													vformat ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															TTR ( " Set CanvasItem  \" %s \"  Pivot Offset to (%d, %d) " ) , 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-15 15:18:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
															drag_selection . front ( ) - > get ( ) - > get_name ( ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															drag_selection . front ( ) - > get ( ) - > _edit_get_pivot ( ) . x , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															drag_selection . front ( ) - > get ( ) - > _edit_get_pivot ( ) . y ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-14 14:51:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											_reset_drag ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										// Cancel a drag
 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-26 08:24:58 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( ED_IS_SHORTCUT ( " canvas_item_editor/cancel_transform " ,  p_event )  | |  ( b . is_valid ( )  & &  b - > get_button_index ( )  = =  MouseButton : : RIGHT  & &  b - > is_pressed ( ) ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											_restore_canvas_item_state ( drag_selection ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-14 14:51:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											_reset_drag ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-13 23:21:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											viewport - > queue_redraw ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-21 01:22:11 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( drag_type  = =  DRAG_TEMP_PIVOT )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if  ( m . is_valid ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											temp_pivot  =  transform . affine_inverse ( ) . xform ( m - > get_position ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											viewport - > queue_redraw ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if  ( ( b . is_valid ( )  & &  ! b - > is_pressed ( )  & &  b - > get_button_index ( )  = =  MouseButton : : LEFT  & &  tool  = =  TOOL_EDIT_PIVOT )  | | 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												( k . is_valid ( )  & &  ! k - > is_pressed ( )  & &  k - > get_keycode ( )  = =  Key : : V ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											drag_type  =  DRAG_NONE ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								bool  CanvasItemEditor : : _gui_input_rotate ( const  Ref < InputEvent >  & p_event )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Ref < InputEventMouseButton >  b  =  p_event ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Ref < InputEventMouseMotion >  m  =  p_event ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-07-06 11:49:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// Start rotation
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( drag_type  = =  DRAG_NONE )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-13 16:31:57 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( b . is_valid ( )  & &  b - > get_button_index ( )  = =  MouseButton : : LEFT  & &  b - > is_pressed ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-02 12:37:48 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if  ( ( b - > is_command_or_control_pressed ( )  & &  ! b - > is_alt_pressed ( )  & &  tool  = =  TOOL_SELECT )  | |  tool  = =  TOOL_ROTATE )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-27 18:41:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												bool  has_locked_items  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												List < CanvasItem  * >  selection  =  _get_edited_canvas_items ( false ,  true ,  & has_locked_items ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-10-16 20:35:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-10-25 19:08:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												// Remove not movable nodes
 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-23 08:54:45 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												for  ( List < CanvasItem  * > : : Element  * E  =  selection . front ( ) ;  E ; )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													List < CanvasItem  * > : : Element  * N  =  E - > next ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													if  ( ! _is_node_movable ( E - > get ( ) ,  true ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2018-10-25 19:08:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														selection . erase ( E ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													} 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-23 08:54:45 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													E  =  N ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-10-25 19:08:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2018-10-16 20:35:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-10-25 19:08:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												drag_selection  =  selection ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												if  ( drag_selection . size ( )  >  0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													drag_type  =  DRAG_ROTATE ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													drag_from  =  transform . affine_inverse ( ) . xform ( b - > get_position ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-15 15:18:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													CanvasItem  * ci  =  drag_selection . front ( ) - > get ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-21 01:22:11 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													if  ( ! Math : : is_inf ( temp_pivot . x )  | |  ! Math : : is_inf ( temp_pivot . y ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														drag_rotation_center  =  temp_pivot ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													}  else  if  ( ci - > _edit_use_pivot ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-18 17:16:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														drag_rotation_center  =  ci - > get_screen_transform ( ) . xform ( ci - > _edit_get_pivot ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-10-25 19:08:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-18 17:16:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														drag_rotation_center  =  ci - > get_screen_transform ( ) . get_origin ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-10-25 19:08:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													_save_canvas_item_state ( drag_selection ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													return  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-27 18:41:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													if  ( has_locked_items )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														EditorToaster : : get_singleton ( ) - > popup_str ( TTR ( locked_transform_warning ) ,  EditorToaster : : SEVERITY_WARNING ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													return  has_locked_items ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-07-06 11:49:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2014-07-06 11:49:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( drag_type  = =  DRAG_ROTATE )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										// Rotate the node
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if  ( m . is_valid ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											_restore_canvas_item_state ( drag_selection ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											for  ( CanvasItem  * ci  :  drag_selection )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												drag_to  =  transform . affine_inverse ( ) . xform ( m - > get_position ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-06 18:43:22 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												//Rotate the opposite way if the canvas item's compounded scale has an uneven number of negative elements
 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												bool  opposite  =  ( ci - > get_global_transform ( ) . get_scale ( ) . sign ( ) . dot ( ci - > get_transform ( ) . get_scale ( ) . sign ( ) )  = =  0 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-21 01:22:11 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												real_t  prev_rotation  =  ci - > _edit_get_rotation ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												real_t  new_rotation  =  snap_angle ( ci - > _edit_get_rotation ( )  +  ( opposite  ?  - 1  :  1 )  *  ( drag_from  -  drag_rotation_center ) . angle_to ( drag_to  -  drag_rotation_center ) ,  prev_rotation ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												ci - > _edit_set_rotation ( new_rotation ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												if  ( ! Math : : is_inf ( temp_pivot . x )  | |  ! Math : : is_inf ( temp_pivot . y ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-18 17:16:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													Transform2D  xform  =  ci - > get_screen_transform ( )  *  ci - > get_transform ( ) . affine_inverse ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-21 01:22:11 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													Vector2  radius  =  xform . xform ( ci - > _edit_get_position ( ) )  -  temp_pivot ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													radius  =  radius . rotated ( new_rotation  -  prev_rotation ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													ci - > _edit_set_position ( xform . affine_inverse ( ) . xform ( temp_pivot  +  radius ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-13 23:21:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												viewport - > queue_redraw ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2014-07-06 11:49:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										// Confirms the node rotation
 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-13 16:31:57 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( b . is_valid ( )  & &  b - > get_button_index ( )  = =  MouseButton : : LEFT  & &  ! b - > is_pressed ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-21 22:49:30 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if  ( drag_selection . size ( )  ! =  1 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												_commit_canvas_item_state ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														drag_selection , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														vformat ( TTR ( " Rotate %d CanvasItems " ) ,  drag_selection . size ( ) ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												_commit_canvas_item_state ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														drag_selection , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														vformat ( TTR ( " Rotate CanvasItem  \" %s \"  to %d degrees " ) , 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-15 15:18:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
																drag_selection . front ( ) - > get ( ) - > get_name ( ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
																Math : : rad_to_deg ( drag_selection . front ( ) - > get ( ) - > _edit_get_rotation ( ) ) ) , 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-21 22:49:30 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-04-15 00:49:03 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if  ( key_auto_insert_button - > is_pressed ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												_insert_animation_keys ( false ,  true ,  false ,  true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-14 14:51:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											_reset_drag ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2014-07-06 11:49:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										// Cancel a drag
 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-26 08:24:58 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( ED_IS_SHORTCUT ( " canvas_item_editor/cancel_transform " ,  p_event )  | |  ( b . is_valid ( )  & &  b - > get_button_index ( )  = =  MouseButton : : RIGHT  & &  b - > is_pressed ( ) ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											_restore_canvas_item_state ( drag_selection ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-14 14:51:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											_reset_drag ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-13 23:21:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											viewport - > queue_redraw ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2014-07-06 11:49:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								bool  CanvasItemEditor : : _gui_input_open_scene_on_double_click ( const  Ref < InputEvent >  & p_event )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Ref < InputEventMouseButton >  b  =  p_event ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-07-06 11:49:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// Open a sub-scene on double-click
 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-13 16:31:57 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( b . is_valid ( )  & &  b - > get_button_index ( )  = =  MouseButton : : LEFT  & &  b - > is_pressed ( )  & &  b - > is_double_click ( )  & &  tool  = =  TOOL_SELECT )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										List < CanvasItem  * >  selection  =  _get_edited_canvas_items ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if  ( selection . size ( )  = =  1 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-15 15:18:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											CanvasItem  * ci  =  selection . front ( ) - > get ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if  ( ! ci - > get_scene_file_path ( ) . is_empty ( )  & &  ci  ! =  EditorNode : : get_singleton ( ) - > get_edited_scene ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-12-28 17:40:50 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												EditorNode : : get_singleton ( ) - > load_scene ( ci - > get_scene_file_path ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2014-07-06 11:49:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								bool  CanvasItemEditor : : _gui_input_anchors ( const  Ref < InputEvent >  & p_event )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Ref < InputEventMouseButton >  b  =  p_event ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Ref < InputEventMouseMotion >  m  =  p_event ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-07-06 11:49:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// Starts anchor dragging if needed
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( drag_type  = =  DRAG_NONE )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-13 16:31:57 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( b . is_valid ( )  & &  b - > get_button_index ( )  = =  MouseButton : : LEFT  & &  b - > is_pressed ( )  & &  tool  = =  TOOL_SELECT )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											List < CanvasItem  * >  selection  =  _get_edited_canvas_items ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if  ( selection . size ( )  = =  1 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-15 15:18:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												Control  * control  =  Object : : cast_to < Control > ( selection . front ( ) - > get ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-10-16 20:35:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												if  ( control  & &  _is_node_movable ( control ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													Vector2  anchor_pos [ 4 ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-12-22 16:24:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													anchor_pos [ 0 ]  =  Vector2 ( control - > get_anchor ( SIDE_LEFT ) ,  control - > get_anchor ( SIDE_TOP ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													anchor_pos [ 1 ]  =  Vector2 ( control - > get_anchor ( SIDE_RIGHT ) ,  control - > get_anchor ( SIDE_TOP ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													anchor_pos [ 2 ]  =  Vector2 ( control - > get_anchor ( SIDE_RIGHT ) ,  control - > get_anchor ( SIDE_BOTTOM ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													anchor_pos [ 3 ]  =  Vector2 ( control - > get_anchor ( SIDE_LEFT ) ,  control - > get_anchor ( SIDE_BOTTOM ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-07-06 11:49:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													Rect2  anchor_rects [ 4 ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													for  ( int  i  =  0 ;  i  <  4 ;  i + + )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-18 17:16:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														anchor_pos [ i ]  =  ( transform  *  control - > get_screen_transform ( ) ) . xform ( _anchor_to_position ( control ,  anchor_pos [ i ] ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														anchor_rects [ i ]  =  Rect2 ( anchor_pos [ i ] ,  anchor_handle - > get_size ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-03 14:22:16 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														if  ( control - > is_layout_rtl ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-20 23:30:19 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
															anchor_rects [ i ] . position  - =  anchor_handle - > get_size ( )  *  Vector2 ( real_t ( i  = =  1  | |  i  = =  2 ) ,  real_t ( i  < =  1 ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-03 14:22:16 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-20 23:30:19 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
															anchor_rects [ i ] . position  - =  anchor_handle - > get_size ( )  *  Vector2 ( real_t ( i  = =  0  | |  i  = =  3 ) ,  real_t ( i  < =  1 ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-03 14:22:16 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														} 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													} 
							 
						 
					
						
							
								
									
										
										
										
											2014-07-06 11:49:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-04-05 13:40:26 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													const  DragType  dragger [ ]  =  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														DRAG_ANCHOR_TOP_LEFT , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														DRAG_ANCHOR_TOP_RIGHT , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														DRAG_ANCHOR_BOTTOM_RIGHT , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														DRAG_ANCHOR_BOTTOM_LEFT , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													} ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-07-06 11:49:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													for  ( int  i  =  0 ;  i  <  4 ;  i + + )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														if  ( anchor_rects [ i ] . has_point ( b - > get_position ( ) ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															if  ( ( anchor_pos [ 0 ]  = =  anchor_pos [ 2 ] )  & &  ( anchor_pos [ 0 ] . distance_to ( b - > get_position ( ) )  <  anchor_handle - > get_size ( ) . length ( )  /  3.0 ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
																drag_type  =  DRAG_ANCHOR_ALL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
																drag_type  =  dragger [ i ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															drag_from  =  transform . affine_inverse ( ) . xform ( b - > get_position ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															drag_selection  =  List < CanvasItem  * > ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															drag_selection . push_back ( control ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															_save_canvas_item_state ( drag_selection ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															return  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-07-06 11:49:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2014-07-06 11:49:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( drag_type  = =  DRAG_ANCHOR_TOP_LEFT  | |  drag_type  = =  DRAG_ANCHOR_TOP_RIGHT  | |  drag_type  = =  DRAG_ANCHOR_BOTTOM_RIGHT  | |  drag_type  = =  DRAG_ANCHOR_BOTTOM_LEFT  | |  drag_type  = =  DRAG_ANCHOR_ALL )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										// Drag the anchor
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if  ( m . is_valid ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											_restore_canvas_item_state ( drag_selection ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-15 15:18:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											Control  * control  =  Object : : cast_to < Control > ( drag_selection . front ( ) - > get ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-07-29 16:57:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											drag_to  =  transform . affine_inverse ( ) . xform ( m - > get_position ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-11-18 17:16:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											Transform2D  xform  =  control - > get_screen_transform ( ) . affine_inverse ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											Point2  previous_anchor ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-12-22 16:24:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											previous_anchor . x  =  ( drag_type  = =  DRAG_ANCHOR_TOP_LEFT  | |  drag_type  = =  DRAG_ANCHOR_BOTTOM_LEFT )  ?  control - > get_anchor ( SIDE_LEFT )  :  control - > get_anchor ( SIDE_RIGHT ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											previous_anchor . y  =  ( drag_type  = =  DRAG_ANCHOR_TOP_LEFT  | |  drag_type  = =  DRAG_ANCHOR_TOP_RIGHT )  ?  control - > get_anchor ( SIDE_TOP )  :  control - > get_anchor ( SIDE_BOTTOM ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											previous_anchor  =  xform . affine_inverse ( ) . xform ( _anchor_to_position ( control ,  previous_anchor ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-04-05 10:18:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											Vector2  new_anchor  =  xform . xform ( snap_point ( previous_anchor  +  ( drag_to  -  drag_from ) ,  SNAP_GRID  |  SNAP_OTHER_NODES ,  SNAP_NODE_PARENT  |  SNAP_NODE_SIDES  |  SNAP_NODE_CENTER ,  control ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-03 14:37:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											new_anchor  =  _position_to_anchor ( control ,  new_anchor ) . snappedf ( 0.001 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-07-18 20:17:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 14:33:50 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											bool  use_single_axis  =  m - > is_shift_pressed ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											Vector2  drag_vector  =  xform . xform ( drag_to )  -  xform . xform ( drag_from ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											bool  use_y  =  Math : : abs ( drag_vector . y )  >  Math : : abs ( drag_vector . x ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-07-06 11:49:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											switch  ( drag_type )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												case  DRAG_ANCHOR_TOP_LEFT : 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													if  ( ! use_single_axis  | |  ! use_y )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-12-22 16:24:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														control - > set_anchor ( SIDE_LEFT ,  new_anchor . x ,  false ,  false ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													if  ( ! use_single_axis  | |  use_y )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-12-22 16:24:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														control - > set_anchor ( SIDE_TOP ,  new_anchor . y ,  false ,  false ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													} 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												case  DRAG_ANCHOR_TOP_RIGHT : 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													if  ( ! use_single_axis  | |  ! use_y )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-12-22 16:24:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														control - > set_anchor ( SIDE_RIGHT ,  new_anchor . x ,  false ,  false ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													if  ( ! use_single_axis  | |  use_y )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-12-22 16:24:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														control - > set_anchor ( SIDE_TOP ,  new_anchor . y ,  false ,  false ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													} 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												case  DRAG_ANCHOR_BOTTOM_RIGHT : 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													if  ( ! use_single_axis  | |  ! use_y )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-12-22 16:24:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														control - > set_anchor ( SIDE_RIGHT ,  new_anchor . x ,  false ,  false ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													if  ( ! use_single_axis  | |  use_y )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-12-22 16:24:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														control - > set_anchor ( SIDE_BOTTOM ,  new_anchor . y ,  false ,  false ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													} 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												case  DRAG_ANCHOR_BOTTOM_LEFT : 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													if  ( ! use_single_axis  | |  ! use_y )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-12-22 16:24:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														control - > set_anchor ( SIDE_LEFT ,  new_anchor . x ,  false ,  false ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													if  ( ! use_single_axis  | |  use_y )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-12-22 16:24:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														control - > set_anchor ( SIDE_BOTTOM ,  new_anchor . y ,  false ,  false ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													} 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												case  DRAG_ANCHOR_ALL : 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-04 22:00:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													if  ( ! use_single_axis  | |  ! use_y )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-12-22 16:24:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														control - > set_anchor ( SIDE_LEFT ,  new_anchor . x ,  false ,  true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														control - > set_anchor ( SIDE_RIGHT ,  new_anchor . x ,  false ,  true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-04 22:00:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													if  ( ! use_single_axis  | |  use_y )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-12-22 16:24:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														control - > set_anchor ( SIDE_TOP ,  new_anchor . y ,  false ,  true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														control - > set_anchor ( SIDE_BOTTOM ,  new_anchor . y ,  false ,  true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-04 22:00:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													} 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												default : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													break ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											return  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										// Confirms new anchor position
 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-13 16:31:57 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( drag_selection . size ( )  > =  1  & &  b . is_valid ( )  & &  b - > get_button_index ( )  = =  MouseButton : : LEFT  & &  ! b - > is_pressed ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-21 22:49:30 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											_commit_canvas_item_state ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													drag_selection , 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-15 15:18:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													vformat ( TTR ( " Move CanvasItem  \" %s \"  Anchor " ) ,  drag_selection . front ( ) - > get ( ) - > get_name ( ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-23 21:05:33 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											snap_target [ 0 ]  =  SNAP_TARGET_NONE ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											snap_target [ 1 ]  =  SNAP_TARGET_NONE ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-14 14:51:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											_reset_drag ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-23 21:05:33 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											viewport - > queue_redraw ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											return  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-08 07:13:17 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										// Cancel a drag
 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-26 08:24:58 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( ED_IS_SHORTCUT ( " canvas_item_editor/cancel_transform " ,  p_event )  | |  ( b . is_valid ( )  & &  b - > get_button_index ( )  = =  MouseButton : : RIGHT  & &  b - > is_pressed ( ) ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											_restore_canvas_item_state ( drag_selection ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-23 21:05:33 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											snap_target [ 0 ]  =  SNAP_TARGET_NONE ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											snap_target [ 1 ]  =  SNAP_TARGET_NONE ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-14 14:51:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											_reset_drag ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-13 23:21:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											viewport - > queue_redraw ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											return  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-07-18 20:17:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								bool  CanvasItemEditor : : _gui_input_resize ( const  Ref < InputEvent >  & p_event )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Ref < InputEventMouseButton >  b  =  p_event ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-05-20 12:38:03 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Ref < InputEventMouseMotion >  m  =  p_event ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// Drag resize handles
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( drag_type  = =  DRAG_NONE )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-13 16:31:57 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( b . is_valid ( )  & &  b - > get_button_index ( )  = =  MouseButton : : LEFT  & &  b - > is_pressed ( )  & &  tool  = =  TOOL_SELECT )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											List < CanvasItem  * >  selection  =  _get_edited_canvas_items ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if  ( selection . size ( )  = =  1 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-15 15:18:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												CanvasItem  * ci  =  selection . front ( ) - > get ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												if  ( ci - > _edit_use_rect ( )  & &  _is_node_movable ( ci ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													Rect2  rect  =  ci - > _edit_get_rect ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-18 17:16:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													Transform2D  xform  =  transform  *  ci - > get_screen_transform ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-08 21:35:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-04-05 13:40:26 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													const  Vector2  endpoints [ 4 ]  =  { 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-08 21:35:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														xform . xform ( rect . position ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														xform . xform ( rect . position  +  Vector2 ( rect . size . x ,  0 ) ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														xform . xform ( rect . position  +  rect . size ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														xform . xform ( rect . position  +  Vector2 ( 0 ,  rect . size . y ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													} ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-04-05 13:40:26 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													const  DragType  dragger [ ]  =  { 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-08 21:35:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														DRAG_TOP_LEFT , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														DRAG_TOP , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														DRAG_TOP_RIGHT , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														DRAG_RIGHT , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														DRAG_BOTTOM_RIGHT , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														DRAG_BOTTOM , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														DRAG_BOTTOM_LEFT , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														DRAG_LEFT 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													} ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-03-08 21:35:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													DragType  resize_drag  =  DRAG_NONE ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-20 23:30:19 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													real_t  radius  =  ( select_handle - > get_size ( ) . width  /  2 )  *  1.5 ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-03-08 21:35:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													for  ( int  i  =  0 ;  i  <  4 ;  i + + )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														int  prev  =  ( i  +  3 )  %  4 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														int  next  =  ( i  +  1 )  %  4 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														Vector2  ofs  =  ( ( endpoints [ i ]  -  endpoints [ prev ] ) . normalized ( )  +  ( ( endpoints [ i ]  -  endpoints [ next ] ) . normalized ( ) ) ) . normalized ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														ofs  * =  ( select_handle - > get_size ( ) . width  /  2 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														ofs  + =  endpoints [ i ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														if  ( ofs . distance_to ( b - > get_position ( ) )  <  radius )  { 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-08 21:35:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
															resize_drag  =  dragger [ i  *  2 ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														} 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-08 21:35:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														ofs  =  ( endpoints [ i ]  +  endpoints [ next ] )  /  2 ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-12-06 18:16:06 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														ofs  + =  ( endpoints [ next ]  -  endpoints [ i ] ) . orthogonal ( ) . normalized ( )  *  ( select_handle - > get_size ( ) . width  /  2 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														if  ( ofs . distance_to ( b - > get_position ( ) )  <  radius )  { 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-08 21:35:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
															resize_drag  =  dragger [ i  *  2  +  1 ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														} 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-08 21:35:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													} 
							 
						 
					
						
							
								
									
										
										
										
											2017-03-22 21:18:47 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-03-08 21:35:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													if  ( resize_drag  ! =  DRAG_NONE )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														drag_type  =  resize_drag ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														drag_from  =  transform . affine_inverse ( ) . xform ( b - > get_position ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														drag_selection  =  List < CanvasItem  * > ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														drag_selection . push_back ( ci ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-08 21:35:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														_save_canvas_item_state ( drag_selection ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													} 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( drag_type  = =  DRAG_LEFT  | |  drag_type  = =  DRAG_RIGHT  | |  drag_type  = =  DRAG_TOP  | |  drag_type  = =  DRAG_BOTTOM  | | 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											drag_type  = =  DRAG_TOP_LEFT  | |  drag_type  = =  DRAG_TOP_RIGHT  | |  drag_type  = =  DRAG_BOTTOM_LEFT  | |  drag_type  = =  DRAG_BOTTOM_RIGHT )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										// Resize the node
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if  ( m . is_valid ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-15 15:18:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											CanvasItem  * ci  =  drag_selection . front ( ) - > get ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											CanvasItemEditorSelectedItem  * se  =  editor_selection - > get_node_editor_data < CanvasItemEditorSelectedItem > ( ci ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											//Reset state
 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											ci - > _edit_set_state ( se - > undo_state ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 14:33:50 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											bool  uniform  =  m - > is_shift_pressed ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											bool  symmetric  =  m - > is_alt_pressed ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											Rect2  local_rect  =  ci - > _edit_get_rect ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-30 01:58:11 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											real_t  aspect  =  local_rect . has_area ( )  ?  ( local_rect . get_size ( ) . y  /  local_rect . get_size ( ) . x )  :  ( local_rect . get_size ( ) . y  +  1.0 )  /  ( local_rect . get_size ( ) . x  +  1.0 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											Point2  current_begin  =  local_rect . get_position ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											Point2  current_end  =  local_rect . get_position ( )  +  local_rect . get_size ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											Point2  max_begin  =  ( symmetric )  ?  ( current_begin  +  current_end  -  ci - > _edit_get_minimum_size ( ) )  /  2.0  :  current_end  -  ci - > _edit_get_minimum_size ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											Point2  min_end  =  ( symmetric )  ?  ( current_begin  +  current_end  +  ci - > _edit_get_minimum_size ( ) )  /  2.0  :  current_begin  +  ci - > _edit_get_minimum_size ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											Point2  center  =  ( current_begin  +  current_end )  /  2.0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											drag_to  =  transform . affine_inverse ( ) . xform ( m - > get_position ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-27 10:47:51 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-11-18 17:16:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											Transform2D  xform  =  ci - > get_screen_transform ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-27 10:47:51 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-01-20 07:49:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											Point2  drag_to_snapped_begin ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											Point2  drag_to_snapped_end ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-11-03 23:57:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											drag_to_snapped_end  =  snap_point ( xform . xform ( current_end )  +  ( drag_to  -  drag_from ) ,  SNAP_NODE_ANCHORS  |  SNAP_NODE_PARENT  |  SNAP_OTHER_NODES  |  SNAP_GRID  |  SNAP_PIXEL ,  0 ,  ci ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											drag_to_snapped_begin  =  snap_point ( xform . xform ( current_begin )  +  ( drag_to  -  drag_from ) ,  SNAP_NODE_ANCHORS  |  SNAP_NODE_PARENT  |  SNAP_OTHER_NODES  |  SNAP_GRID  |  SNAP_PIXEL ,  0 ,  ci ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-20 07:49:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-11-03 23:57:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											Point2  drag_begin  =  xform . affine_inverse ( ) . xform ( drag_to_snapped_begin ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											Point2  drag_end  =  xform . affine_inverse ( ) . xform ( drag_to_snapped_end ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											// Horizontal resize
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if  ( drag_type  = =  DRAG_LEFT  | |  drag_type  = =  DRAG_TOP_LEFT  | |  drag_type  = =  DRAG_BOTTOM_LEFT )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												current_begin . x  =  MIN ( drag_begin . x ,  max_begin . x ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											}  else  if  ( drag_type  = =  DRAG_RIGHT  | |  drag_type  = =  DRAG_TOP_RIGHT  | |  drag_type  = =  DRAG_BOTTOM_RIGHT )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												current_end . x  =  MAX ( drag_end . x ,  min_end . x ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											// Vertical resize
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if  ( drag_type  = =  DRAG_TOP  | |  drag_type  = =  DRAG_TOP_LEFT  | |  drag_type  = =  DRAG_TOP_RIGHT )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												current_begin . y  =  MIN ( drag_begin . y ,  max_begin . y ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											}  else  if  ( drag_type  = =  DRAG_BOTTOM  | |  drag_type  = =  DRAG_BOTTOM_LEFT  | |  drag_type  = =  DRAG_BOTTOM_RIGHT )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												current_end . y  =  MAX ( drag_end . y ,  min_end . y ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-31 23:27:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											// Uniform resize
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if  ( uniform )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												if  ( drag_type  = =  DRAG_LEFT  | |  drag_type  = =  DRAG_RIGHT )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													current_end . y  =  current_begin . y  +  aspect  *  ( current_end . x  -  current_begin . x ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												}  else  if  ( drag_type  = =  DRAG_TOP  | |  drag_type  = =  DRAG_BOTTOM )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													current_end . x  =  current_begin . x  +  ( current_end . y  -  current_begin . y )  /  aspect ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													if  ( aspect  > =  1.0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														if  ( drag_type  = =  DRAG_TOP_LEFT  | |  drag_type  = =  DRAG_TOP_RIGHT )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															current_begin . y  =  current_end . y  -  aspect  *  ( current_end . x  -  current_begin . x ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-31 23:27:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
															current_end . y  =  current_begin . y  +  aspect  *  ( current_end . x  -  current_begin . x ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														if  ( drag_type  = =  DRAG_TOP_LEFT  | |  drag_type  = =  DRAG_BOTTOM_LEFT )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															current_begin . x  =  current_end . x  -  ( current_end . y  -  current_begin . y )  /  aspect ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															current_end . x  =  current_begin . x  +  ( current_end . y  -  current_begin . y )  /  aspect ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-31 23:27:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													} 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-31 23:27:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											// Symmetric resize
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if  ( symmetric )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												if  ( drag_type  = =  DRAG_LEFT  | |  drag_type  = =  DRAG_TOP_LEFT  | |  drag_type  = =  DRAG_BOTTOM_LEFT )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													current_end . x  =  2.0  *  center . x  -  current_begin . x ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												}  else  if  ( drag_type  = =  DRAG_RIGHT  | |  drag_type  = =  DRAG_TOP_RIGHT  | |  drag_type  = =  DRAG_BOTTOM_RIGHT )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													current_begin . x  =  2.0  *  center . x  -  current_end . x ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												if  ( drag_type  = =  DRAG_TOP  | |  drag_type  = =  DRAG_TOP_LEFT  | |  drag_type  = =  DRAG_TOP_RIGHT )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													current_end . y  =  2.0  *  center . y  -  current_begin . y ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												}  else  if  ( drag_type  = =  DRAG_BOTTOM  | |  drag_type  = =  DRAG_BOTTOM_LEFT  | |  drag_type  = =  DRAG_BOTTOM_RIGHT )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													current_begin . y  =  2.0  *  center . y  -  current_end . y ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											ci - > _edit_set_rect ( Rect2 ( current_begin ,  current_end  -  current_begin ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-07 23:30:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										// Confirm resize
 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-13 16:31:57 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( drag_selection . size ( )  > =  1  & &  b . is_valid ( )  & &  b - > get_button_index ( )  = =  MouseButton : : LEFT  & &  ! b - > is_pressed ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-15 15:18:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											const  Node2D  * node2d  =  Object : : cast_to < Node2D > ( drag_selection . front ( ) - > get ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-21 22:49:30 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if  ( node2d )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												// Extends from Node2D.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												// Node2D doesn't have an actual stored rect size, unlike Controls.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												_commit_canvas_item_state ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														drag_selection , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														vformat ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
																TTR ( " Scale Node2D  \" %s \"  to (%s, %s) " ) , 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-15 15:18:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
																drag_selection . front ( ) - > get ( ) - > get_name ( ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
																Math : : snapped ( drag_selection . front ( ) - > get ( ) - > _edit_get_scale ( ) . x ,  0.01 ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
																Math : : snapped ( drag_selection . front ( ) - > get ( ) - > _edit_get_scale ( ) . y ,  0.01 ) ) , 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-21 22:49:30 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												// Extends from Control.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												_commit_canvas_item_state ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														drag_selection , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														vformat ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
																TTR ( " Resize Control  \" %s \"  to (%d, %d) " ) , 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-15 15:18:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
																drag_selection . front ( ) - > get ( ) - > get_name ( ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
																drag_selection . front ( ) - > get ( ) - > _edit_get_rect ( ) . size . x , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
																drag_selection . front ( ) - > get ( ) - > _edit_get_rect ( ) . size . y ) , 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-21 22:49:30 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-04-15 00:49:03 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if  ( key_auto_insert_button - > is_pressed ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												_insert_animation_keys ( false ,  false ,  true ,  true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2019-09-25 16:56:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											snap_target [ 0 ]  =  SNAP_TARGET_NONE ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											snap_target [ 1 ]  =  SNAP_TARGET_NONE ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-14 14:51:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											_reset_drag ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-13 23:21:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											viewport - > queue_redraw ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-07 23:30:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										// Cancel a drag
 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-26 08:24:58 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( ED_IS_SHORTCUT ( " canvas_item_editor/cancel_transform " ,  p_event )  | |  ( b . is_valid ( )  & &  b - > get_button_index ( )  = =  MouseButton : : RIGHT  & &  b - > is_pressed ( ) ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											_restore_canvas_item_state ( drag_selection ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-09-25 16:56:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											snap_target [ 0 ]  =  SNAP_TARGET_NONE ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											snap_target [ 1 ]  =  SNAP_TARGET_NONE ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-14 14:51:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											_reset_drag ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-13 23:21:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											viewport - > queue_redraw ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2017-09-07 23:30:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-09-10 14:39:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								bool  CanvasItemEditor : : _gui_input_scale ( const  Ref < InputEvent >  & p_event )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Ref < InputEventMouseButton >  b  =  p_event ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Ref < InputEventMouseMotion >  m  =  p_event ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									// Drag resize handles
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( drag_type  = =  DRAG_NONE )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-25 16:34:32 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( b . is_valid ( )  & &  b - > get_button_index ( )  = =  MouseButton : : LEFT  & &  b - > is_pressed ( )  & & 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												( ( tool  = =  TOOL_SELECT  & &  b - > is_alt_pressed ( )  & &  b - > is_command_or_control_pressed ( ) )  | |  tool  = =  TOOL_SCALE ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-27 18:41:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											bool  has_locked_items  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											List < CanvasItem  * >  selection  =  _get_edited_canvas_items ( false ,  true ,  & has_locked_items ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-25 16:34:32 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											// Remove non-movable nodes.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											for  ( CanvasItem  * ci  :  selection )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												if  ( ! _is_node_movable ( ci ,  true ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													selection . erase ( ci ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if  ( ! selection . is_empty ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-15 15:18:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												CanvasItem  * ci  =  selection . front ( ) - > get ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-10 14:39:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-10-25 16:34:32 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												Transform2D  edit_transform ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												if  ( ! Math : : is_inf ( temp_pivot . x )  | |  ! Math : : is_inf ( temp_pivot . y ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													edit_transform  =  Transform2D ( ci - > _edit_get_rotation ( ) ,  temp_pivot ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													edit_transform  =  ci - > _edit_get_transform ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-20 15:22:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-11-18 17:16:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												Transform2D  xform  =  transform  *  ci - > get_screen_transform ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-25 16:34:32 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												Transform2D  unscaled_transform  =  ( xform  *  ci - > get_transform ( ) . affine_inverse ( )  *  edit_transform ) . orthonormalized ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												Transform2D  simple_xform  =  viewport - > get_transform ( )  *  unscaled_transform ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-20 15:22:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-10-25 16:34:32 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												drag_type  =  DRAG_SCALE_BOTH ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-10-16 20:35:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-10-25 16:34:32 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												if  ( show_transformation_gizmos )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													Size2  scale_factor  =  Size2 ( SCALE_HANDLE_DISTANCE ,  SCALE_HANDLE_DISTANCE ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													Rect2  x_handle_rect  =  Rect2 ( scale_factor . x  *  EDSCALE ,  - 5  *  EDSCALE ,  10  *  EDSCALE ,  10  *  EDSCALE ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													if  ( x_handle_rect . has_point ( simple_xform . affine_inverse ( ) . xform ( b - > get_position ( ) ) ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														drag_type  =  DRAG_SCALE_X ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													Rect2  y_handle_rect  =  Rect2 ( - 5  *  EDSCALE ,  scale_factor . y  *  EDSCALE ,  10  *  EDSCALE ,  10  *  EDSCALE ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													if  ( y_handle_rect . has_point ( simple_xform . affine_inverse ( ) . xform ( b - > get_position ( ) ) ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														drag_type  =  DRAG_SCALE_Y ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													} 
							 
						 
					
						
							
								
									
										
										
										
											2018-10-16 20:35:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-25 16:34:32 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												drag_from  =  transform . affine_inverse ( ) . xform ( b - > get_position ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												drag_selection  =  selection ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												_save_canvas_item_state ( drag_selection ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												return  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-27 18:41:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												if  ( has_locked_items )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													EditorToaster : : get_singleton ( ) - > popup_str ( TTR ( locked_transform_warning ) ,  EditorToaster : : SEVERITY_WARNING ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												return  has_locked_items ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-10 14:39:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-25 16:34:32 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									}  else  if  ( drag_type  = =  DRAG_SCALE_BOTH  | |  drag_type  = =  DRAG_SCALE_X  | |  drag_type  = =  DRAG_SCALE_Y )  { 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-10 14:39:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										// Resize the node
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if  ( m . is_valid ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-20 22:33:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											_restore_canvas_item_state ( drag_selection ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-10 14:39:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											drag_to  =  transform . affine_inverse ( ) . xform ( m - > get_position ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-10-25 16:34:32 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											Size2  scale_max ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if  ( drag_type  ! =  DRAG_SCALE_BOTH )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												for  ( CanvasItem  * ci  :  drag_selection )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													scale_max  =  scale_max . max ( ci - > _edit_get_scale ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-20 15:22:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-11-21 20:23:24 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											Transform2D  edit_transform ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											bool  using_temp_pivot  =  ! Math : : is_inf ( temp_pivot . x )  | |  ! Math : : is_inf ( temp_pivot . y ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if  ( using_temp_pivot )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												edit_transform  =  Transform2D ( drag_selection . front ( ) - > get ( ) - > _edit_get_rotation ( ) ,  temp_pivot ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												edit_transform  =  drag_selection . front ( ) - > get ( ) - > _edit_get_transform ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-25 16:34:32 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											for  ( CanvasItem  * ci  :  drag_selection )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-18 17:16:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												Transform2D  parent_xform  =  ci - > get_screen_transform ( )  *  ci - > get_transform ( ) . affine_inverse ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-25 16:34:32 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												Transform2D  unscaled_transform  =  ( transform  *  parent_xform  *  edit_transform ) . orthonormalized ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												Transform2D  simple_xform  =  ( viewport - > get_transform ( )  *  unscaled_transform ) . affine_inverse ( )  *  transform ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												bool  uniform  =  m - > is_shift_pressed ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												bool  is_ctrl  =  m - > is_command_or_control_pressed ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												Point2  drag_from_local  =  simple_xform . xform ( drag_from ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												Point2  drag_to_local  =  simple_xform . xform ( drag_to ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												Point2  offset  =  drag_to_local  -  drag_from_local ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												Size2  scale  =  ci - > _edit_get_scale ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												Size2  original_scale  =  scale ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												real_t  ratio  =  scale . y  /  scale . x ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												if  ( drag_type  = =  DRAG_SCALE_BOTH )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													Size2  scale_factor  =  drag_to_local  /  drag_from_local ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-20 15:22:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													if  ( uniform )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-25 16:34:32 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														scale  * =  ( scale_factor . x  +  scale_factor . y )  /  2.0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														scale  * =  scale_factor ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-20 15:22:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													} 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-25 16:34:32 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													Size2  scale_factor  =  Vector2 ( offset . x ,  - offset . y )  /  SCALE_HANDLE_DISTANCE ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													Size2  parent_scale  =  parent_xform . get_scale ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													// Take into account the biggest scale, so all nodes are scaled uniformly.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													scale_factor  * =  Vector2 ( 1.0  /  parent_scale . x ,  1.0  /  parent_scale . y )  /  ( scale_max  /  original_scale ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													if  ( drag_type  = =  DRAG_SCALE_X )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														scale . x  + =  scale_factor . x ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														if  ( uniform )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															scale . y  =  scale . x  *  ratio ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													}  else  if  ( drag_type  = =  DRAG_SCALE_Y )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														scale . y  - =  scale_factor . y ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														if  ( uniform )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															scale . x  =  scale . y  /  ratio ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														} 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-20 15:22:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													} 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-10 14:39:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-30 15:18:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-10-25 16:34:32 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												if  ( snap_scale  & &  ! is_ctrl )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													if  ( snap_relative )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														scale . x  =  original_scale . x  *  ( Math : : round ( ( scale . x  /  original_scale . x )  /  snap_scale_step )  *  snap_scale_step ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														scale . y  =  original_scale . y  *  ( Math : : round ( ( scale . y  /  original_scale . y )  /  snap_scale_step )  *  snap_scale_step ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														scale . x  =  Math : : round ( scale . x  /  snap_scale_step )  *  snap_scale_step ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														scale . y  =  Math : : round ( scale . y  /  snap_scale_step )  *  snap_scale_step ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												ci - > _edit_set_scale ( scale ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												if  ( using_temp_pivot )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													Point2  ci_origin  =  ci - > _edit_get_transform ( ) . get_origin ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													ci - > _edit_set_position ( ci_origin  +  ( ci_origin  -  temp_pivot )  *  ( ( scale  -  original_scale )  /  original_scale ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-04-12 11:19:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-30 15:18:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-09-20 15:22:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											return  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-10 14:39:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										// Confirm resize
 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-13 16:31:57 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( b . is_valid ( )  & &  b - > get_button_index ( )  = =  MouseButton : : LEFT  & &  ! b - > is_pressed ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-21 22:49:30 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if  ( drag_selection . size ( )  ! =  1 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												_commit_canvas_item_state ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														drag_selection , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														vformat ( TTR ( " Scale %d CanvasItems " ) ,  drag_selection . size ( ) ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												_commit_canvas_item_state ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														drag_selection , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														vformat ( TTR ( " Scale CanvasItem  \" %s \"  to (%s, %s) " ) , 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-15 15:18:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
																drag_selection . front ( ) - > get ( ) - > get_name ( ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
																Math : : snapped ( drag_selection . front ( ) - > get ( ) - > _edit_get_scale ( ) . x ,  0.01 ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
																Math : : snapped ( drag_selection . front ( ) - > get ( ) - > _edit_get_scale ( ) . y ,  0.01 ) ) , 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-21 22:49:30 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-15 00:49:03 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if  ( key_auto_insert_button - > is_pressed ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												_insert_animation_keys ( false ,  false ,  true ,  true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-14 14:51:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											_reset_drag ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-13 23:21:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											viewport - > queue_redraw ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-10 14:39:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										// Cancel a drag
 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-26 08:24:58 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( ED_IS_SHORTCUT ( " canvas_item_editor/cancel_transform " ,  p_event )  | |  ( b . is_valid ( )  & &  b - > get_button_index ( )  = =  MouseButton : : RIGHT  & &  b - > is_pressed ( ) ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-10 14:39:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											_restore_canvas_item_state ( drag_selection ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-14 14:51:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											_reset_drag ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-13 23:21:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											viewport - > queue_redraw ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-10 14:39:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								bool  CanvasItemEditor : : _gui_input_move ( const  Ref < InputEvent >  & p_event )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Ref < InputEventMouseButton >  b  =  p_event ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Ref < InputEventMouseMotion >  m  =  p_event ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Ref < InputEventKey >  k  =  p_event ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-07-29 16:57:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( drag_type  = =  DRAG_NONE )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										//Start moving the nodes
 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-13 16:31:57 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( b . is_valid ( )  & &  b - > get_button_index ( )  = =  MouseButton : : LEFT  & &  b - > is_pressed ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-25 16:34:32 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if  ( ( tool  = =  TOOL_SELECT  & &  b - > is_alt_pressed ( )  & &  ! b - > is_command_or_control_pressed ( ) )  | |  tool  = =  TOOL_MOVE )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-27 18:41:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												bool  has_locked_items  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												List < CanvasItem  * >  selection  =  _get_edited_canvas_items ( false ,  true ,  & has_locked_items ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-10-16 20:35:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-01-04 17:57:59 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												if  ( selection . size ( )  >  0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													drag_selection . clear ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-15 15:18:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													for  ( CanvasItem  * E  :  selection )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														if  ( _is_node_movable ( E ,  true ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															drag_selection . push_back ( E ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-04 17:57:59 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														} 
							 
						 
					
						
							
								
									
										
										
										
											2018-10-25 19:08:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													} 
							 
						 
					
						
							
								
									
										
										
										
											2018-10-16 20:35:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													drag_type  =  DRAG_MOVE ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-11-08 15:48:26 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-04-15 15:18:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													CanvasItem  * ci  =  selection . front ( ) - > get ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-18 17:16:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													Transform2D  parent_xform  =  ci - > get_screen_transform ( )  *  ci - > get_transform ( ) . affine_inverse ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													Transform2D  unscaled_transform  =  ( transform  *  parent_xform  *  ci - > _edit_get_transform ( ) ) . orthonormalized ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-11-08 15:48:26 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													Transform2D  simple_xform  =  viewport - > get_transform ( )  *  unscaled_transform ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-11-10 10:07:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													if  ( show_transformation_gizmos )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														Size2  move_factor  =  Size2 ( MOVE_HANDLE_DISTANCE ,  MOVE_HANDLE_DISTANCE ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														Rect2  x_handle_rect  =  Rect2 ( move_factor . x  *  EDSCALE ,  - 5  *  EDSCALE ,  10  *  EDSCALE ,  10  *  EDSCALE ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														if  ( x_handle_rect . has_point ( simple_xform . affine_inverse ( ) . xform ( b - > get_position ( ) ) ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															drag_type  =  DRAG_MOVE_X ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														} 
							 
						 
					
						
							
								
									
										
										
										
											2019-11-12 11:05:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														Rect2  y_handle_rect  =  Rect2 ( - 5  *  EDSCALE ,  move_factor . y  *  EDSCALE ,  10  *  EDSCALE ,  10  *  EDSCALE ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-11-10 10:07:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														if  ( y_handle_rect . has_point ( simple_xform . affine_inverse ( ) . xform ( b - > get_position ( ) ) ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															drag_type  =  DRAG_MOVE_Y ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														} 
							 
						 
					
						
							
								
									
										
										
										
											2019-11-08 15:48:26 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-10-16 20:35:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													drag_from  =  transform . affine_inverse ( ) . xform ( b - > get_position ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													_save_canvas_item_state ( drag_selection ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-04 17:57:59 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													return  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-27 18:41:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													if  ( has_locked_items )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														EditorToaster : : get_singleton ( ) - > popup_str ( TTR ( locked_transform_warning ) ,  EditorToaster : : SEVERITY_WARNING ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													return  has_locked_items ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-10-16 20:35:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2017-07-29 16:57:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2017-07-29 16:57:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-11-08 15:48:26 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( drag_type  = =  DRAG_MOVE  | |  drag_type  = =  DRAG_MOVE_X  | |  drag_type  = =  DRAG_MOVE_Y )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										// Move the nodes
 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-16 14:11:09 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( m . is_valid ( )  & &  ! drag_selection . is_empty ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											_restore_canvas_item_state ( drag_selection ,  true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											drag_to  =  transform . affine_inverse ( ) . xform ( m - > get_position ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											Point2  previous_pos ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-16 14:11:09 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if  ( drag_selection . size ( )  = =  1 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-18 17:16:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												Transform2D  parent_xform  =  drag_selection . front ( ) - > get ( ) - > get_screen_transform ( )  *  drag_selection . front ( ) - > get ( ) - > get_transform ( ) . affine_inverse ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-15 15:18:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												previous_pos  =  parent_xform . xform ( drag_selection . front ( ) - > get ( ) - > _edit_get_position ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-16 14:11:09 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												previous_pos  =  _get_encompassing_rect_from_list ( drag_selection ) . position ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2019-11-08 15:48:26 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-16 14:11:09 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											Point2  drag_delta  =  drag_to  -  drag_from ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-25 16:34:32 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if  ( drag_type  = =  DRAG_MOVE_X  | |  drag_type  = =  DRAG_MOVE_Y )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-16 14:11:09 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												const  CanvasItem  * selected  =  drag_selection . front ( ) - > get ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-18 17:16:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												Transform2D  parent_xform  =  selected - > get_screen_transform ( )  *  selected - > get_transform ( ) . affine_inverse ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-02 10:40:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												Transform2D  unscaled_transform  =  ( transform  *  parent_xform  *  selected - > _edit_get_transform ( ) ) . orthonormalized ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												Transform2D  simple_xform  =  viewport - > get_transform ( )  *  unscaled_transform ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-11-08 15:48:26 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-10-02 10:40:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												drag_delta  =  simple_xform . affine_inverse ( ) . basis_xform ( drag_delta ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-16 14:11:09 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												if  ( drag_type  = =  DRAG_MOVE_X )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													drag_delta . y  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													drag_delta . x  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-02 10:40:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												drag_delta  =  simple_xform . basis_xform ( drag_delta ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-11-08 15:48:26 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-16 14:11:09 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											Point2  new_pos  =  snap_point ( previous_pos  +  drag_delta ,  SNAP_GRID  |  SNAP_GUIDES  |  SNAP_PIXEL  |  SNAP_NODE_PARENT  |  SNAP_NODE_ANCHORS  |  SNAP_OTHER_NODES ,  0 ,  nullptr ,  drag_selection ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-11-08 15:48:26 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 14:33:50 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											bool  single_axis  =  m - > is_shift_pressed ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if  ( single_axis )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-30 17:56:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												if  ( Math : : abs ( new_pos . x  -  previous_pos . x )  >  Math : : abs ( new_pos . y  -  previous_pos . y ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													new_pos . y  =  previous_pos . y ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													new_pos . x  =  previous_pos . x ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-01-06 00:13:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											for  ( CanvasItem  * ci  :  drag_selection )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-18 17:16:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												Transform2D  parent_xform_inv  =  ci - > get_transform ( )  *  ci - > get_screen_transform ( ) . affine_inverse ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-02 10:40:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												ci - > _edit_set_position ( ci - > _edit_get_position ( )  +  parent_xform_inv . basis_xform ( new_pos  -  previous_pos ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2017-03-23 00:47:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										// Confirm the move (only if it was moved)
 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-13 16:31:57 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( b . is_valid ( )  & &  ! b - > is_pressed ( )  & &  b - > get_button_index ( )  = =  MouseButton : : LEFT )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if  ( transform . affine_inverse ( ) . xform ( b - > get_position ( ) )  ! =  drag_from )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-21 22:49:30 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												if  ( drag_selection . size ( )  ! =  1 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													_commit_canvas_item_state ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															drag_selection , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															vformat ( TTR ( " Move %d CanvasItems " ) ,  drag_selection . size ( ) ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													_commit_canvas_item_state ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															drag_selection , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															vformat ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
																	TTR ( " Move CanvasItem  \" %s \"  to (%d, %d) " ) , 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-15 15:18:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
																	drag_selection . front ( ) - > get ( ) - > get_name ( ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
																	drag_selection . front ( ) - > get ( ) - > _edit_get_position ( ) . x , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
																	drag_selection . front ( ) - > get ( ) - > _edit_get_position ( ) . y ) , 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-21 22:49:30 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
															true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-04-15 00:49:03 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if  ( key_auto_insert_button - > is_pressed ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												_insert_animation_keys ( true ,  false ,  false ,  true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2019-09-20 22:26:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											//Make sure smart snapping lines disappear.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											snap_target [ 0 ]  =  SNAP_TARGET_NONE ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											snap_target [ 1 ]  =  SNAP_TARGET_NONE ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-14 14:51:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											_reset_drag ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-13 23:21:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											viewport - > queue_redraw ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										// Cancel a drag
 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-26 08:24:58 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( ED_IS_SHORTCUT ( " canvas_item_editor/cancel_transform " ,  p_event )  | |  ( b . is_valid ( )  & &  b - > get_button_index ( )  = =  MouseButton : : RIGHT  & &  b - > is_pressed ( ) ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											_restore_canvas_item_state ( drag_selection ,  true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-09-20 22:26:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											snap_target [ 0 ]  =  SNAP_TARGET_NONE ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											snap_target [ 1 ]  =  SNAP_TARGET_NONE ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-14 14:51:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											_reset_drag ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-13 23:21:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											viewport - > queue_redraw ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									// Move the canvas items with the arrow keys
 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-10 21:39:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( k . is_valid ( )  & &  k - > is_pressed ( )  & &  ( tool  = =  TOOL_SELECT  | |  tool  = =  TOOL_MOVE )  & & 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-13 16:31:57 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											( k - > get_keycode ( )  = =  Key : : UP  | |  k - > get_keycode ( )  = =  Key : : DOWN  | |  k - > get_keycode ( )  = =  Key : : LEFT  | |  k - > get_keycode ( )  = =  Key : : RIGHT ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( ! k - > is_echo ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-24 20:31:21 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											// Start moving the canvas items with the keyboard, if they are movable
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											List < CanvasItem  * >  selection  =  _get_edited_canvas_items ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											drag_selection . clear ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											for  ( CanvasItem  * item  :  selection )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												if  ( _is_node_movable ( item ,  true ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													drag_selection . push_back ( item ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											drag_type  =  DRAG_KEY_MOVE ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											drag_from  =  Vector2 ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											drag_to  =  Vector2 ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											_save_canvas_item_state ( drag_selection ,  true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-03-08 21:35:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( drag_selection . size ( )  >  0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											_restore_canvas_item_state ( drag_selection ,  true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 14:33:50 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											bool  move_local_base  =  k - > is_alt_pressed ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											bool  move_local_base_rotated  =  k - > is_ctrl_pressed ( )  | |  k - > is_meta_pressed ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-08 21:35:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											Vector2  dir ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-13 16:31:57 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if  ( k - > get_keycode ( )  = =  Key : : UP )  { 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-08 21:35:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												dir  + =  Vector2 ( 0 ,  - 1 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-13 16:31:57 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											}  else  if  ( k - > get_keycode ( )  = =  Key : : DOWN )  { 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-08 21:35:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												dir  + =  Vector2 ( 0 ,  1 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-13 16:31:57 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											}  else  if  ( k - > get_keycode ( )  = =  Key : : LEFT )  { 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-08 21:35:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												dir  + =  Vector2 ( - 1 ,  0 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-13 16:31:57 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											}  else  if  ( k - > get_keycode ( )  = =  Key : : RIGHT )  { 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-08 21:35:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												dir  + =  Vector2 ( 1 ,  0 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 14:33:50 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if  ( k - > is_shift_pressed ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-08 21:35:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												dir  * =  grid_step  *  Math : : pow ( 2.0 ,  grid_step_multiplier ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-08 21:35:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											drag_to  + =  dir ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 14:33:50 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if  ( k - > is_shift_pressed ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-08 21:35:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												drag_to  =  drag_to . snapped ( grid_step  *  Math : : pow ( 2.0 ,  grid_step_multiplier ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-03-08 21:35:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											Point2  previous_pos ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if  ( drag_selection . size ( )  = =  1 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-15 15:18:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												Transform2D  xform  =  drag_selection . front ( ) - > get ( ) - > get_global_transform_with_canvas ( )  *  drag_selection . front ( ) - > get ( ) - > get_transform ( ) . affine_inverse ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												previous_pos  =  xform . xform ( drag_selection . front ( ) - > get ( ) - > _edit_get_position ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-08 21:35:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												previous_pos  =  _get_encompassing_rect_from_list ( drag_selection ) . position ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-03-08 21:35:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											Point2  new_pos ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if  ( drag_selection . size ( )  = =  1 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-15 15:18:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												Node2D  * node_2d  =  Object : : cast_to < Node2D > ( drag_selection . front ( ) - > get ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-08 21:35:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												if  ( node_2d  & &  move_local_base_rotated )  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-02-12 21:10:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													Transform2D  m2 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													m2 . rotate ( node_2d - > get_rotation ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													new_pos  + =  m2 . xform ( drag_to ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-08 21:35:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												}  else  if  ( move_local_base )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													new_pos  + =  drag_to ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													new_pos  =  previous_pos  +  ( drag_to  -  drag_from ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												new_pos  =  previous_pos  +  ( drag_to  -  drag_from ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2014-07-06 11:49:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											for  ( CanvasItem  * ci  :  drag_selection )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												Transform2D  xform  =  ci - > get_global_transform_with_canvas ( ) . affine_inverse ( )  *  ci - > get_transform ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												ci - > _edit_set_position ( ci - > _edit_get_position ( )  +  xform . xform ( new_pos )  -  xform . xform ( previous_pos ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-21 14:50:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( k . is_valid ( )  & &  ! k - > is_pressed ( )  & &  drag_type  = =  DRAG_KEY_MOVE  & &  ( tool  = =  TOOL_SELECT  | |  tool  = =  TOOL_MOVE )  & & 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-13 16:31:57 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											( k - > get_keycode ( )  = =  Key : : UP  | |  k - > get_keycode ( )  = =  Key : : DOWN  | |  k - > get_keycode ( )  = =  Key : : LEFT  | |  k - > get_keycode ( )  = =  Key : : RIGHT ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										// Confirm canvas items move by arrow keys
 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-13 16:31:57 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( ( ! Input : : get_singleton ( ) - > is_key_pressed ( Key : : UP ) )  & & 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												( ! Input : : get_singleton ( ) - > is_key_pressed ( Key : : DOWN ) )  & & 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												( ! Input : : get_singleton ( ) - > is_key_pressed ( Key : : LEFT ) )  & & 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												( ! Input : : get_singleton ( ) - > is_key_pressed ( Key : : RIGHT ) ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-12-09 16:47:12 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if  ( drag_selection . size ( )  >  1 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-21 22:49:30 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												_commit_canvas_item_state ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														drag_selection , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														vformat ( TTR ( " Move %d CanvasItems " ) ,  drag_selection . size ( ) ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-12-09 16:47:12 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											}  else  if  ( drag_selection . size ( )  = =  1 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-21 22:49:30 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												_commit_canvas_item_state ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														drag_selection , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														vformat ( TTR ( " Move CanvasItem  \" %s \"  to (%d, %d) " ) , 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-15 15:18:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
																drag_selection . front ( ) - > get ( ) - > get_name ( ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
																drag_selection . front ( ) - > get ( ) - > _edit_get_position ( ) . x , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
																drag_selection . front ( ) - > get ( ) - > _edit_get_position ( ) . y ) , 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-21 22:49:30 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-14 14:51:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											_reset_drag ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-13 23:21:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										viewport - > queue_redraw ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2014-07-06 11:49:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-08-13 16:31:57 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									return  ( k . is_valid ( )  & &  ( k - > get_keycode ( )  = =  Key : : UP  | |  k - > get_keycode ( )  = =  Key : : DOWN  | |  k - > get_keycode ( )  = =  Key : : LEFT  | |  k - > get_keycode ( )  = =  Key : : RIGHT ) ) ;  // Accept the key event in any case
 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2014-07-06 11:49:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								bool  CanvasItemEditor : : _gui_input_select ( const  Ref < InputEvent >  & p_event )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Ref < InputEventMouseButton >  b  =  p_event ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Ref < InputEventMouseMotion >  m  =  p_event ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Ref < InputEventKey >  k  =  p_event ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-07-06 11:49:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 00:03:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( drag_type  = =  DRAG_NONE  | |  ( drag_type  = =  DRAG_BOX_SELECTION  & &  b . is_valid ( )  & &  ! b - > is_pressed ( ) ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-15 20:04:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( b . is_valid ( )  & &  b - > is_pressed ( )  & & 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-27 19:34:40 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												( ( b - > get_button_index ( )  = =  MouseButton : : RIGHT  & &  b - > is_alt_pressed ( ) )  | | 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-13 16:31:57 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														( b - > get_button_index ( )  = =  MouseButton : : LEFT  & &  tool  = =  TOOL_LIST_SELECT ) ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											// Popup the selection menu list
 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-07 21:39:55 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											Point2  click  =  transform . affine_inverse ( ) . xform ( b - > get_position ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-11-27 19:34:40 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											_get_canvas_items_at_pos ( click ,  selection_results ,  b - > is_alt_pressed ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-07-06 11:49:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if  ( selection_results . size ( )  = =  1 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												CanvasItem  * item  =  selection_results [ 0 ] . item ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												selection_results . clear ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-07-06 11:49:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 14:33:50 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												_select_click_on_item ( item ,  click ,  b - > is_shift_pressed ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-07-06 11:49:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												return  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-12-15 12:04:21 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											}  else  if  ( ! selection_results . is_empty ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-08 21:35:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												// Sorts items according the their z-index
 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												selection_results . sort ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-07-06 11:49:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												NodePath  root_path  =  get_tree ( ) - > get_edited_scene_root ( ) - > get_path ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												StringName  root_name  =  root_path . get_name ( root_path . get_name_count ( )  -  1 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-03 15:43:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												int  icon_max_width  =  EditorNode : : get_singleton ( ) - > get_editor_theme ( ) - > get_constant ( SNAME ( " class_icon_size " ) ,  EditorStringName ( Editor ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-07-06 11:49:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												for  ( int  i  =  0 ;  i  <  selection_results . size ( ) ;  i + + )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													CanvasItem  * item  =  selection_results [ i ] . item ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-07-06 11:49:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-06-11 15:43:37 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													Ref < Texture2D >  icon  =  EditorNode : : get_singleton ( ) - > get_object_icon ( item ,  " Node " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													String  node_path  =  " / "  +  root_name  +  " / "  +  root_path . rel_path_to ( item - > get_path ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-07-06 11:49:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-02-10 13:59:24 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													int  locked  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													if  ( _is_node_locked ( item ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														locked  =  1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 10:36:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														Node  * scene  =  EditorNode : : get_singleton ( ) - > get_edited_scene ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-10 13:59:24 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														Node  * node  =  item ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														while  ( node  & &  node  ! =  scene - > get_parent ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
															CanvasItem  * ci_tmp  =  Object : : cast_to < CanvasItem > ( node ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															if  ( ci_tmp  & &  node - > has_meta ( " _edit_group_ " ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-10 13:59:24 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
																locked  =  2 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															node  =  node - > get_parent ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-11-14 18:21:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													String  suffix ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-10 13:59:24 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													if  ( locked  = =  1 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														suffix  =  "  ( "  +  TTR ( " Locked " )  +  " ) " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													}  else  if  ( locked  = =  2 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														suffix  =  "  ( "  +  TTR ( " Grouped " )  +  " ) " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													selection_menu - > add_item ( ( String ) item - > get_name ( )  +  suffix ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													selection_menu - > set_item_icon ( i ,  icon ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-03 15:43:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													selection_menu - > set_item_icon_max_width ( i ,  icon_max_width ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													selection_menu - > set_item_metadata ( i ,  node_path ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													selection_menu - > set_item_tooltip ( i ,  String ( item - > get_name ( ) )  +  " \n Type:  "  +  item - > get_class ( )  +  " \n Path:  "  +  node_path ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2014-07-06 11:49:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-02-24 21:17:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												selection_results_menu  =  selection_results ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 14:33:50 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												selection_menu_additive_selection  =  b - > is_shift_pressed ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 15:44:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												selection_menu - > set_position ( viewport - > get_screen_transform ( ) . xform ( b - > get_position ( ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-31 17:43:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												selection_menu - > reset_size ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												selection_menu - > popup ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2014-07-06 11:49:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-08-13 16:31:57 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( b . is_valid ( )  & &  b - > is_pressed ( )  & &  b - > get_button_index ( )  = =  MouseButton : : RIGHT )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-18 16:35:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											add_node_menu - > clear ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-13 02:33:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											add_node_menu - > add_icon_item ( get_editor_theme_icon ( SNAME ( " Add " ) ) ,  TTR ( " Add Node Here... " ) ,  ADD_NODE ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											add_node_menu - > add_icon_item ( get_editor_theme_icon ( SNAME ( " Instance " ) ) ,  TTR ( " Instantiate Scene Here... " ) ,  ADD_INSTANCE ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-18 16:35:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											for  ( Node  * node  :  SceneTreeDock : : get_singleton ( ) - > get_node_clipboard ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												if  ( Object : : cast_to < CanvasItem > ( node ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-13 02:33:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													add_node_menu - > add_icon_item ( get_editor_theme_icon ( SNAME ( " ActionPaste " ) ) ,  TTR ( " Paste Node(s) Here " ) ,  ADD_PASTE ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-18 16:35:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2024-12-01 06:40:29 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											for  ( Node  * node  :  EditorNode : : get_singleton ( ) - > get_editor_selection ( ) - > get_top_selected_node_list ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-18 16:35:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												if  ( Object : : cast_to < CanvasItem > ( node ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-13 02:33:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													add_node_menu - > add_icon_item ( get_editor_theme_icon ( SNAME ( " ToolMove " ) ) ,  TTR ( " Move Node(s) Here " ) ,  ADD_MOVE ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-18 16:35:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-12-18 14:42:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											// Context menu plugin receives paths of nodes under cursor. It's a complex operation, so perform it only when necessary.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if  ( EditorContextMenuPluginManager : : get_singleton ( ) - > has_plugins_for_slot ( EditorContextMenuPlugin : : CONTEXT_SLOT_2D_EDITOR ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												selection_results . clear ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												_get_canvas_items_at_pos ( transform . affine_inverse ( ) . xform ( viewport - > get_local_mouse_position ( ) ) ,  selection_results ,  true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												PackedStringArray  paths ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												paths . resize ( selection_results . size ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												String  * paths_write  =  paths . ptrw ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												for  ( int  i  =  0 ;  i  <  paths . size ( ) ;  i + + )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													paths_write [ i ]  =  selection_results [ i ] . item - > get_path ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												EditorContextMenuPluginManager : : get_singleton ( ) - > add_options_from_plugins ( add_node_menu ,  EditorContextMenuPlugin : : CONTEXT_SLOT_2D_EDITOR ,  paths ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-20 11:04:57 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											add_node_menu - > reset_size ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-08 17:09:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											add_node_menu - > set_position ( viewport - > get_screen_transform ( ) . xform ( b - > get_position ( ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-25 01:32:58 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											add_node_menu - > popup ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-18 16:35:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											node_create_position  =  transform . affine_inverse ( ) . xform ( b - > get_position ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-25 01:32:58 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 00:03:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Point2  click ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										bool  can_select  =  b . is_valid ( )  & &  b - > get_button_index ( )  = =  MouseButton : : LEFT  & &  ! panner - > is_panning ( )  & &  ( tool  = =  TOOL_SELECT  | |  tool  = =  TOOL_MOVE  | |  tool  = =  TOOL_SCALE  | |  tool  = =  TOOL_ROTATE ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if  ( can_select )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											click  =  transform . affine_inverse ( ) . xform ( b - > get_position ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											// Allow selecting on release when performed very small box selection (necessary when Shift is pressed, see below).
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											can_select  =  b - > is_pressed ( )  | |  ( drag_type  = =  DRAG_BOX_SELECTION  & &  click . distance_to ( drag_from )  < =  DRAG_THRESHOLD ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2014-07-06 11:49:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 00:03:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( can_select )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											// Single item selection.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 10:36:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											Node  * scene  =  EditorNode : : get_singleton ( ) - > get_edited_scene ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if  ( ! scene )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												return  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2014-07-06 11:49:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 00:03:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											// Find the item to select.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											CanvasItem  * ci  =  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-04 14:05:58 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-01-09 20:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											Vector < _SelectResult >  selection  =  Vector < _SelectResult > ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 00:03:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											// Retrieve the canvas items.
 
							 
						 
					
						
							
								
									
										
											 
										
											
												New and improved IK system for Skeleton2D
This PR and commit adds a new IK system for 2D with the Skeleton2D node
that adds several new IK solvers, a way to control bones in a Skeleton2D
node similar to that in Skeleton3D. It also adds additional changes
and functionality.
This work was sponsored by GSoC 2020 and TwistedTwigleg.
Full list of changes:
* Adds a SkeletonModifier2D resource
  * This resource is the base where all IK code is written and executed
  * Has a function for clamping angles, since it is so commonly used
  * Modifiers are unique when duplicated so it works with instancing
* Adds a SkeletonModifierStack2D resource
  * This resource manages a series of SkeletonModification2Ds
  * This is what the Skeleton2D directly interfaces with to make IK possible
* Adds SkeletonModifier2D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
  * Each modification is in its own file
  * There is also a SkeletonModifier2D resource that acts as a stack for using multiple stacks together
* Adds a PhysicalBone2D node
  * Works similar to the PhysicalBone3D node, but uses a RigidBody2D node
* Changes to Skeleton2D listed below:
  * Skeleton2D now holds a single SkeletonModificationStack2D for IK
  * Skeleton2D now has a local_pose_override, which overrides the Bone2D position similar to how the overrides work in Skeleton3D
* Changes to Bone2D listed below:
  * The default_length property has been changed to length. Length is the length of the bone to its child bone node
  * New bone_angle property, which is the angle the bone has to its first child bone node
  * Bone2D caches its transform when not modified by IK for IK interpolation purposes
  * Bone2D draws its own editor gizmo, though this is stated to change in the future
* Changes to CanvasItemEditor listed below:
  * Bone2D gizmo drawing code removed
  * The 2D IK code is removed. Now Bone2D is the only bone system for 2D
* Transform2D now has a looking_at function for rotating to face a position
* Two new node notifications: NOTIFICATION_EDITOR_PRE_SAVE and NOTIFICATION_EDITOR_POST_SAVE
  * These notifications only are called in the editor right before and after saving a scene
  * Needed for not saving the IK position when executing IK in the editor
* Documentation for all the changes listed above.
											 
										 
										
											2020-08-03 14:02:24 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											_get_canvas_items_at_pos ( click ,  selection ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-12-15 12:04:21 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if  ( ! selection . is_empty ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												ci  =  selection [ 0 ] . item ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-11 20:58:01 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2014-07-06 11:49:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 00:03:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											// Shift also allows forcing box selection when item was clicked.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if  ( ! ci  | |  ( b - > is_shift_pressed ( )  & &  b - > is_pressed ( ) ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												// Start a box selection.
 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 14:33:50 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												if  ( ! b - > is_shift_pressed ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 00:03:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													// Clear the selection if not additive.
 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													editor_selection - > clear ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-13 23:21:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													viewport - > queue_redraw ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-11-27 21:07:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													selected_from_canvas  =  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												} ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-07-06 11:49:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 00:03:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												if  ( b - > is_pressed ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													drag_from  =  click ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													drag_type  =  DRAG_BOX_SELECTION ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													box_selecting_to  =  drag_from ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												bool  still_selected  =  _select_click_on_item ( ci ,  click ,  b - > is_shift_pressed ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 00:03:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												// Start dragging.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												if  ( still_selected  & &  ( tool  = =  TOOL_SELECT  | |  tool  = =  TOOL_MOVE )  & &  b - > is_pressed ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													// Drag the node(s) if requested.
 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-04 11:39:46 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													drag_start_origin  =  click ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													drag_type  =  DRAG_QUEUED ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 00:03:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												}  else  if  ( ! b - > is_pressed ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													_reset_drag ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-04 11:39:46 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 00:03:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												// Select the item.
 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-04 11:39:46 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-06-04 11:39:46 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( drag_type  = =  DRAG_QUEUED )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if  ( b . is_valid ( )  & &  ! b - > is_pressed ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-14 14:51:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											_reset_drag ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-04 11:39:46 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if  ( m . is_valid ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											Point2  click  =  transform . affine_inverse ( ) . xform ( m - > get_position ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-16 06:17:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											bool  movement_threshold_passed  =  drag_start_origin . distance_to ( click )  >  ( 8  *  MAX ( 1 ,  EDSCALE ) )  /  zoom ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-04 11:39:46 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if  ( m . is_valid ( )  & &  movement_threshold_passed )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												List < CanvasItem  * >  selection2  =  _get_edited_canvas_items ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-10-16 20:35:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-06-04 11:39:46 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												drag_selection . clear ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-15 15:18:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												for  ( CanvasItem  * E  :  selection2 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													if  ( _is_node_movable ( E ,  true ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														drag_selection . push_back ( E ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-10-16 20:35:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													} 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-04 11:39:46 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												if  ( selection2 . size ( )  >  0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													drag_type  =  DRAG_MOVE ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-26 00:53:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													drag_from  =  drag_start_origin ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-04 11:39:46 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													_save_canvas_item_state ( drag_selection ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2014-07-06 11:49:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( drag_type  = =  DRAG_BOX_SELECTION )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-13 16:31:57 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( b . is_valid ( )  & &  ! b - > is_pressed ( )  & &  b - > get_button_index ( )  = =  MouseButton : : LEFT )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-30 15:56:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											// Confirms box selection.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 10:36:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											Node  * scene  =  EditorNode : : get_singleton ( ) - > get_edited_scene ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if  ( scene )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												List < CanvasItem  * >  selitems ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-07-06 11:49:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												Point2  bsfrom  =  drag_from ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												Point2  bsto  =  box_selecting_to ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												if  ( bsfrom . x  >  bsto . x )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													SWAP ( bsfrom . x ,  bsto . x ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												if  ( bsfrom . y  >  bsto . y )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													SWAP ( bsfrom . y ,  bsto . y ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2014-07-06 11:49:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-03-08 21:35:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												_find_canvas_items_in_rect ( Rect2 ( bsfrom ,  bsto  -  bsfrom ) ,  scene ,  & selitems ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-12-01 06:40:29 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												if  ( selitems . size ( )  = =  1  & &  editor_selection - > get_top_selected_node_list ( ) . is_empty ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-15 15:18:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													EditorNode : : get_singleton ( ) - > push_item ( selitems . front ( ) - > get ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-13 18:09:53 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-15 23:45:57 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												for  ( CanvasItem  * E  :  selitems )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													editor_selection - > add_node ( E ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-07-06 11:49:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2014-07-06 11:49:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-14 14:51:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											_reset_drag ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-13 23:21:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											viewport - > queue_redraw ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2014-07-06 11:49:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-08-13 16:31:57 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( b . is_valid ( )  & &  b - > is_pressed ( )  & &  b - > get_button_index ( )  = =  MouseButton : : RIGHT )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-30 15:56:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											// Cancel box selection.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-14 14:51:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											_reset_drag ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-13 23:21:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											viewport - > queue_redraw ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2014-07-06 11:49:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( m . is_valid ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-30 15:56:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											// Update box selection.
 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											box_selecting_to  =  transform . affine_inverse ( ) . xform ( m - > get_position ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-13 23:21:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											viewport - > queue_redraw ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2014-07-06 11:49:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-01-04 18:07:31 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( k . is_valid ( )  & &  k - > is_action_pressed ( SNAME ( " ui_cancel " ) ,  false ,  true )  & &  drag_type  = =  DRAG_NONE )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										// Unselect everything
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										editor_selection - > clear ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-13 23:21:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										viewport - > queue_redraw ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2014-07-06 11:49:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-08-30 22:49:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								bool  CanvasItemEditor : : _gui_input_ruler_tool ( const  Ref < InputEvent >  & p_event )  {  
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( tool  ! =  TOOL_RULER )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-15 10:35:53 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										ruler_tool_active  =  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-08-30 22:49:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										return  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2019-08-30 22:49:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Ref < InputEventMouseButton >  b  =  p_event ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Ref < InputEventMouseMotion >  m  =  p_event ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Point2  previous_origin  =  ruler_tool_origin ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( ! ruler_tool_active )  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-25 04:19:11 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										ruler_tool_origin  =  snap_point ( viewport - > get_local_mouse_position ( )  /  zoom  +  view_offset ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2019-08-30 22:49:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-06-14 12:10:04 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( ruler_tool_active  & &  b . is_valid ( )  & &  b - > get_button_index ( )  = =  MouseButton : : RIGHT )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										ruler_tool_active  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										viewport - > queue_redraw ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-08-13 16:31:57 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( b . is_valid ( )  & &  b - > get_button_index ( )  = =  MouseButton : : LEFT )  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-08-30 22:49:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( b - > is_pressed ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											ruler_tool_active  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											ruler_tool_active  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-13 23:21:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										viewport - > queue_redraw ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-08-30 22:49:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-10-24 22:31:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( m . is_valid ( )  & &  ( ruler_tool_active  | |  ( grid_snap_active  & &  previous_origin  ! =  ruler_tool_origin ) ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-13 23:21:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										viewport - > queue_redraw ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-08-30 22:49:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-03-12 23:32:25 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								bool  CanvasItemEditor : : _gui_input_hover ( const  Ref < InputEvent >  & p_event )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Ref < InputEventMouseMotion >  m  =  p_event ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( m . is_valid ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2018-06-12 11:01:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Point2  click  =  transform . affine_inverse ( ) . xform ( m - > get_position ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-12 23:32:25 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-13 23:21:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										// Checks if the hovered items changed, redraw the viewport if so
 
							 
						 
					
						
							
								
									
										
										
										
											2018-06-12 11:01:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Vector < _SelectResult >  hovering_results_items ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										_get_canvas_items_at_pos ( click ,  hovering_results_items ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										hovering_results_items . sort ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										// Compute the nodes names and icon position
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										Vector < _HoverResult >  hovering_results_tmp ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										for  ( int  i  =  0 ;  i  <  hovering_results_items . size ( ) ;  i + + )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											CanvasItem  * ci  =  hovering_results_items [ i ] . item ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-06-12 11:01:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if  ( ci - > _edit_use_rect ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2018-06-12 11:01:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												continue ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2018-06-12 11:01:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											_HoverResult  hover_result ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-18 17:16:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											hover_result . position  =  ci - > get_screen_transform ( ) . get_origin ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											hover_result . icon  =  EditorNode : : get_singleton ( ) - > get_object_icon ( ci ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											hover_result . name  =  ci - > get_name ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-06-12 11:01:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											hovering_results_tmp . push_back ( hover_result ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-13 23:21:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										// Check if changed, if so, redraw.
 
							 
						 
					
						
							
								
									
										
										
										
											2018-06-12 11:01:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										bool  changed  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if  ( hovering_results_tmp . size ( )  = =  hovering_results . size ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											for  ( int  i  =  0 ;  i  <  hovering_results_tmp . size ( ) ;  i + + )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												_HoverResult  a  =  hovering_results_tmp [ i ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												_HoverResult  b  =  hovering_results [ i ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												if  ( a . icon  ! =  b . icon  | |  a . name  ! =  b . name  | |  a . position  ! =  b . position )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													changed  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-12 23:32:25 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2018-06-12 11:01:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											changed  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-12 23:32:25 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-06-12 11:01:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( changed )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											hovering_results  =  hovering_results_tmp ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-13 23:21:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											viewport - > queue_redraw ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-12 23:32:25 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2018-06-12 11:01:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										return  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-12 23:32:25 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : _gui_input_viewport ( const  Ref < InputEvent >  & p_event )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									bool  accepted  =  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-03-31 18:53:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-19 19:59:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Ref < InputEventMouseButton >  mb  =  p_event ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									bool  release_lmb  =  ( mb . is_valid ( )  & &  ! mb - > is_pressed ( )  & &  mb - > get_button_index ( )  = =  MouseButton : : LEFT ) ;  // Required to properly release some stuff (e.g. selection box) while panning.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-10-18 16:43:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( EDITOR_GET ( " editors/panning/simple_panning " )  | |  ! pan_pressed  | |  release_lmb )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-28 15:59:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										accepted  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if  ( _gui_input_rulers_and_guides ( p_event ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-19 19:59:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											// print_line("Rulers and guides");
 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-28 15:59:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}  else  if  ( EditorNode : : get_singleton ( ) - > get_editor_plugins_over ( ) - > forward_gui_input ( p_event ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-19 19:59:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											// print_line("Plugin");
 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-28 15:59:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}  else  if  ( _gui_input_open_scene_on_double_click ( p_event ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-19 19:59:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											// print_line("Open scene on double click");
 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-28 15:59:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}  else  if  ( _gui_input_scale ( p_event ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-19 19:59:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											// print_line("Set scale");
 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-28 15:59:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}  else  if  ( _gui_input_pivot ( p_event ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-19 19:59:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											// print_line("Set pivot");
 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-28 15:59:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}  else  if  ( _gui_input_resize ( p_event ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-19 19:59:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											// print_line("Resize");
 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-28 15:59:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}  else  if  ( _gui_input_rotate ( p_event ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-19 19:59:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											// print_line("Rotate");
 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-28 15:59:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}  else  if  ( _gui_input_move ( p_event ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-19 19:59:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											// print_line("Move");
 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-28 15:59:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}  else  if  ( _gui_input_anchors ( p_event ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-19 19:59:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											// print_line("Anchors");
 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-28 15:59:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}  else  if  ( _gui_input_ruler_tool ( p_event ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-19 19:59:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											// print_line("Measure");
 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-14 12:10:04 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}  else  if  ( _gui_input_select ( p_event ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											// print_line("Selection");
 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-07 16:43:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-19 19:59:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											// print_line("Not accepted");
 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-28 15:59:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											accepted  =  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-07 16:43:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-07-28 17:00:05 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									accepted  =  ( _gui_input_zoom_or_pan ( p_event ,  accepted )  | |  accepted ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-07 16:43:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( accepted )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										accept_event ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-03-12 23:32:25 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// Handles the mouse hovering
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									_gui_input_hover ( p_event ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-04-06 08:42:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( mb . is_valid ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										// Update the default cursor.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										_update_cursor ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-26 21:35:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									// Grab focus
 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-03 11:59:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( ! viewport - > has_focus ( )  & &  ( ! get_viewport ( ) - > gui_get_focus_owner ( )  | |  ! get_viewport ( ) - > gui_get_focus_owner ( ) - > is_text_field ( ) ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 15:46:56 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										callable_mp ( ( Control  * ) viewport ,  & Control : : grab_focus ) . call_deferred ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-26 21:35:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : _update_cursor ( )  {  
						 
					
						
							
								
									
										
										
										
											2022-04-06 08:42:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// Choose the correct default cursor.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									CursorShape  c  =  CURSOR_ARROW ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									switch  ( tool )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case  TOOL_MOVE : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											c  =  CURSOR_MOVE ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case  TOOL_EDIT_PIVOT : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											c  =  CURSOR_CROSS ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case  TOOL_PAN : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											c  =  CURSOR_DRAG ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case  TOOL_RULER : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											c  =  CURSOR_CROSS ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										default : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( pan_pressed )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										c  =  CURSOR_DRAG ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									set_default_cursor_shape ( c ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-03-04 15:00:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : _update_lock_and_group_button ( )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									bool  all_locked  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									bool  all_group  =  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-06 17:51:14 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									bool  has_canvas_item  =  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-12-01 06:40:29 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									List < Node  * >  selection  =  editor_selection - > get_top_selected_node_list ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-04 15:00:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( selection . is_empty ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										all_locked  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										all_group  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										for  ( Node  * E  :  selection )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											CanvasItem  * item  =  Object : : cast_to < CanvasItem > ( E ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if  ( item )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												if  ( all_locked  & &  ! item - > has_meta ( " _edit_lock_ " ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													all_locked  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												if  ( all_group  & &  ! item - > has_meta ( " _edit_group_ " ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													all_group  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-06 17:51:14 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												has_canvas_item  =  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-04 15:00:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if  ( ! all_locked  & &  ! all_group )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-03-06 17:51:14 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									all_locked  =  all_locked  & &  has_canvas_item ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									all_group  =  all_group  & &  has_canvas_item ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-03-04 15:00:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									lock_button - > set_visible ( ! all_locked ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-06 17:51:14 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									lock_button - > set_disabled ( ! has_canvas_item ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-04 15:00:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									unlock_button - > set_visible ( all_locked ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-06 17:51:14 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									unlock_button - > set_disabled ( ! has_canvas_item ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-04 15:00:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									group_button - > set_visible ( ! all_group ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-06 17:51:14 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									group_button - > set_disabled ( ! has_canvas_item ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-04 15:00:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									ungroup_button - > set_visible ( all_group ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-06 17:51:14 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									ungroup_button - > set_disabled ( ! has_canvas_item ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-04 15:00:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-04-06 08:42:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Control : : CursorShape  CanvasItemEditor : : get_cursor_shape ( const  Point2  & p_pos )  const  {  
						 
					
						
							
								
									
										
										
										
											2020-10-01 12:19:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// Compute an eventual rotation of the cursor
 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-05 13:40:26 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									const  CursorShape  rotation_array [ 4 ]  =  {  CURSOR_HSIZE ,  CURSOR_BDIAGSIZE ,  CURSOR_VSIZE ,  CURSOR_FDIAGSIZE  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-01 12:19:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									int  rotation_array_index  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									List < CanvasItem  * >  selection  =  _get_edited_canvas_items ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( selection . size ( )  = =  1 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-15 15:18:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										const  double  angle  =  Math : : fposmod ( ( double ) selection . front ( ) - > get ( ) - > get_global_transform_with_canvas ( ) . get_rotation ( ) ,  Math_PI ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-01 12:19:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( angle  >  Math_PI  *  7.0  /  8.0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											rotation_array_index  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}  else  if  ( angle  >  Math_PI  *  5.0  /  8.0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											rotation_array_index  =  1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}  else  if  ( angle  >  Math_PI  *  3.0  /  8.0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											rotation_array_index  =  2 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}  else  if  ( angle  >  Math_PI  *  1.0  /  8.0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											rotation_array_index  =  3 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											rotation_array_index  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-06 18:56:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-01 12:19:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									// Choose the correct cursor
 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-06 08:42:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									CursorShape  c  =  get_default_cursor_shape ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									switch  ( drag_type )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case  DRAG_LEFT : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case  DRAG_RIGHT : 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-01 12:19:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											c  =  rotation_array [ rotation_array_index ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											break ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-13 17:16:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										case  DRAG_V_GUIDE : 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-01 12:19:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											c  =  CURSOR_HSIZE ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case  DRAG_TOP : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case  DRAG_BOTTOM : 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-01 12:19:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											c  =  rotation_array [ ( rotation_array_index  +  2 )  %  4 ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											break ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-13 17:16:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										case  DRAG_H_GUIDE : 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-01 12:19:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											c  =  CURSOR_VSIZE ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case  DRAG_TOP_LEFT : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case  DRAG_BOTTOM_RIGHT : 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-01 12:19:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											c  =  rotation_array [ ( rotation_array_index  +  3 )  %  4 ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											break ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-13 17:16:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										case  DRAG_DOUBLE_GUIDE : 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-01 12:19:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											c  =  CURSOR_FDIAGSIZE ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case  DRAG_TOP_RIGHT : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case  DRAG_BOTTOM_LEFT : 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-01 12:19:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											c  =  rotation_array [ ( rotation_array_index  +  1 )  %  4 ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											break ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-09 22:17:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										case  DRAG_MOVE : 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											c  =  CURSOR_MOVE ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										default : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-13 17:16:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( is_hovering_h_guide )  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-13 17:16:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										c  =  CURSOR_VSIZE ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									}  else  if  ( is_hovering_v_guide )  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-13 17:16:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										c  =  CURSOR_HSIZE ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-13 17:16:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-10-06 14:11:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( pan_pressed )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										c  =  CURSOR_DRAG ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-06 08:42:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									return  c ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-02-15 13:25:58 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : _draw_text_at_position ( Point2  p_position ,  const  String  & p_string ,  Side  p_side )  {  
						 
					
						
							
								
									
										
										
										
											2024-05-14 15:57:29 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Color  color  =  get_theme_color ( SceneStringName ( font_color ) ,  EditorStringName ( Editor ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-20 19:29:52 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									color . a  =  0.8 ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-14 15:57:29 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Ref < Font >  font  =  get_theme_font ( SceneStringName ( font ) ,  SNAME ( " Label " ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									int  font_size  =  get_theme_font_size ( SceneStringName ( font_size ) ,  SNAME ( " Label " ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-05-09 12:47:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Size2  text_size  =  font - > get_string_size ( p_string ,  HORIZONTAL_ALIGNMENT_LEFT ,  - 1 ,  font_size ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-18 00:42:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									switch  ( p_side )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-12-22 16:24:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										case  SIDE_LEFT : 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-18 00:42:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											p_position  + =  Vector2 ( - text_size . x  -  5 ,  text_size . y  /  2 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											break ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-12-22 16:24:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										case  SIDE_TOP : 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-18 00:42:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											p_position  + =  Vector2 ( - text_size . x  /  2 ,  - 5 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											break ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-12-22 16:24:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										case  SIDE_RIGHT : 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-18 00:42:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											p_position  + =  Vector2 ( 5 ,  text_size . y  /  2 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											break ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-12-22 16:24:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										case  SIDE_BOTTOM : 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-18 00:42:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											p_position  + =  Vector2 ( - text_size . x  /  2 ,  text_size . y  +  5 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-24 20:58:47 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									viewport - > draw_string ( font ,  p_position ,  p_string ,  HORIZONTAL_ALIGNMENT_LEFT ,  - 1 ,  font_size ,  color ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-18 00:42:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-12-22 16:24:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : _draw_margin_at_position ( int  p_value ,  Point2  p_position ,  Side  p_side )  {  
						 
					
						
							
								
									
										
										
										
											2020-09-03 14:22:16 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									String  str  =  TS - > format_number ( vformat ( " %d  "  +  TTR ( " px " ) ,  p_value ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-18 00:42:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( p_value  ! =  0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										_draw_text_at_position ( p_position ,  str ,  p_side ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-06-20 23:30:19 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : _draw_percentage_at_position ( real_t  p_value ,  Point2  p_position ,  Side  p_side )  {  
						 
					
						
							
								
									
										
										
										
											2020-09-03 14:22:16 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									String  str  =  TS - > format_number ( vformat ( " %.1f  " ,  p_value  *  100.0 ) )  +  TS - > percent_sign ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-02 18:33:06 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( p_value  ! =  0 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-18 00:42:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										_draw_text_at_position ( p_position ,  str ,  p_side ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-02 18:33:06 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-10-18 23:55:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : _draw_focus ( )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									// Draw the focus around the base viewport
 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( viewport - > has_focus ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-13 02:33:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										get_theme_stylebox ( SNAME ( " FocusViewport " ) ,  EditorStringName ( EditorStyles ) ) - > draw ( viewport - > get_canvas_item ( ) ,  Rect2 ( Point2 ( ) ,  viewport - > get_size ( ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-18 23:55:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : _draw_guides ( )  {  
						 
					
						
							
								
									
										
										
										
											2022-10-18 16:43:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Color  guide_color  =  EDITOR_GET ( " editors/2d/guides_color " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-18 23:55:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Transform2D  xform  =  viewport_scrollable - > get_transform ( )  *  transform ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-04-01 20:30:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// Guides already there.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( Node  * scene  =  EditorNode : : get_singleton ( ) - > get_edited_scene ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										Array  vguides  =  scene - > get_meta ( " _edit_vertical_guides_ " ,  Array ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-18 23:55:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										for  ( int  i  =  0 ;  i  <  vguides . size ( ) ;  i + + )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if  ( drag_type  = =  DRAG_V_GUIDE  & &  i  = =  dragged_guide_index )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-18 23:55:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												continue ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-20 23:30:19 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											real_t  x  =  xform . xform ( Point2 ( vguides [ i ] ,  0 ) ) . x ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-09 01:49:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											viewport - > draw_line ( Point2 ( x ,  0 ) ,  Point2 ( x ,  viewport - > get_size ( ) . y ) ,  guide_color ,  Math : : round ( EDSCALE ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-18 23:55:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-04-01 20:30:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Array  hguides  =  scene - > get_meta ( " _edit_horizontal_guides_ " ,  Array ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-18 23:55:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										for  ( int  i  =  0 ;  i  <  hguides . size ( ) ;  i + + )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if  ( drag_type  = =  DRAG_H_GUIDE  & &  i  = =  dragged_guide_index )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-18 23:55:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												continue ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-20 23:30:19 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											real_t  y  =  xform . xform ( Point2 ( 0 ,  hguides [ i ] ) ) . y ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-09 01:49:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											viewport - > draw_line ( Point2 ( 0 ,  y ) ,  Point2 ( viewport - > get_size ( ) . x ,  y ) ,  guide_color ,  Math : : round ( EDSCALE ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-18 23:55:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-04-01 20:30:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// Dragged guide.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-14 15:57:29 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Color  text_color  =  get_theme_color ( SceneStringName ( font_color ) ,  EditorStringName ( Editor ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-26 01:44:36 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Color  outline_color  =  text_color . inverted ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									const  float  outline_size  =  2 ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( drag_type  = =  DRAG_DOUBLE_GUIDE  | |  drag_type  = =  DRAG_V_GUIDE )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-03 14:22:16 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										String  str  =  TS - > format_number ( vformat ( " %d px " ,  Math : : round ( xform . affine_inverse ( ) . xform ( dragged_guide_pos ) . x ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-13 02:33:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Ref < Font >  font  =  get_theme_font ( SNAME ( " bold " ) ,  EditorStringName ( EditorFonts ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										int  font_size  =  1.3  *  get_theme_font_size ( SNAME ( " bold_size " ) ,  EditorStringName ( EditorFonts ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-05-09 12:47:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Size2  text_size  =  font - > get_string_size ( str ,  HORIZONTAL_ALIGNMENT_LEFT ,  - 1 ,  font_size ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										viewport - > draw_string_outline ( font ,  Point2 ( dragged_guide_pos . x  +  10 ,  RULER_WIDTH  +  text_size . y  /  2  +  10 ) ,  str ,  HORIZONTAL_ALIGNMENT_LEFT ,  - 1 ,  font_size ,  outline_size ,  outline_color ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										viewport - > draw_string ( font ,  Point2 ( dragged_guide_pos . x  +  10 ,  RULER_WIDTH  +  text_size . y  /  2  +  10 ) ,  str ,  HORIZONTAL_ALIGNMENT_LEFT ,  - 1 ,  font_size ,  text_color ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-09 01:49:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										viewport - > draw_line ( Point2 ( dragged_guide_pos . x ,  0 ) ,  Point2 ( dragged_guide_pos . x ,  viewport - > get_size ( ) . y ) ,  guide_color ,  Math : : round ( EDSCALE ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-18 23:55:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( drag_type  = =  DRAG_DOUBLE_GUIDE  | |  drag_type  = =  DRAG_H_GUIDE )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-03 14:22:16 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										String  str  =  TS - > format_number ( vformat ( " %d px " ,  Math : : round ( xform . affine_inverse ( ) . xform ( dragged_guide_pos ) . y ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-13 02:33:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Ref < Font >  font  =  get_theme_font ( SNAME ( " bold " ) ,  EditorStringName ( EditorFonts ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										int  font_size  =  1.3  *  get_theme_font_size ( SNAME ( " bold_size " ) ,  EditorStringName ( EditorFonts ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-05-09 12:47:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Size2  text_size  =  font - > get_string_size ( str ,  HORIZONTAL_ALIGNMENT_LEFT ,  - 1 ,  font_size ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										viewport - > draw_string_outline ( font ,  Point2 ( RULER_WIDTH  +  10 ,  dragged_guide_pos . y  +  text_size . y  /  2  +  10 ) ,  str ,  HORIZONTAL_ALIGNMENT_LEFT ,  - 1 ,  font_size ,  outline_size ,  outline_color ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										viewport - > draw_string ( font ,  Point2 ( RULER_WIDTH  +  10 ,  dragged_guide_pos . y  +  text_size . y  /  2  +  10 ) ,  str ,  HORIZONTAL_ALIGNMENT_LEFT ,  - 1 ,  font_size ,  text_color ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-09 01:49:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										viewport - > draw_line ( Point2 ( 0 ,  dragged_guide_pos . y ) ,  Point2 ( viewport - > get_size ( ) . x ,  dragged_guide_pos . y ) ,  guide_color ,  Math : : round ( EDSCALE ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-18 23:55:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-04-05 10:18:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : _draw_smart_snapping ( )  {  
						 
					
						
							
								
									
										
										
										
											2022-10-18 16:43:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Color  line_color  =  EDITOR_GET ( " editors/2d/smart_snapping_line_color " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-05 10:18:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( snap_target [ 0 ]  ! =  SNAP_TARGET_NONE  & &  snap_target [ 0 ]  ! =  SNAP_TARGET_GRID )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										viewport - > draw_set_transform_matrix ( viewport - > get_transform ( )  *  transform  *  snap_transform ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										viewport - > draw_line ( Point2 ( 0 ,  - 1.0e+10 F ) ,  Point2 ( 0 ,  1.0e+10 F ) ,  line_color ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										viewport - > draw_set_transform_matrix ( viewport - > get_transform ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( snap_target [ 1 ]  ! =  SNAP_TARGET_NONE  & &  snap_target [ 1 ]  ! =  SNAP_TARGET_GRID )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										viewport - > draw_set_transform_matrix ( viewport - > get_transform ( )  *  transform  *  snap_transform ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										viewport - > draw_line ( Point2 ( - 1.0e+10 F ,  0 ) ,  Point2 ( 1.0e+10 F ,  0 ) ,  line_color ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										viewport - > draw_set_transform_matrix ( viewport - > get_transform ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-08-29 21:50:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : _draw_rulers ( )  {  
						 
					
						
							
								
									
										
										
										
											2023-08-13 02:33:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Color  bg_color  =  get_theme_color ( SNAME ( " dark_color_2 " ) ,  EditorStringName ( Editor ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-14 15:57:29 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Color  graduation_color  =  get_theme_color ( SceneStringName ( font_color ) ,  EditorStringName ( Editor ) ) . lerp ( bg_color ,  0.5 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Color  font_color  =  get_theme_color ( SceneStringName ( font_color ) ,  EditorStringName ( Editor ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-20 19:29:52 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									font_color . a  =  0.8 ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-13 02:33:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Ref < Font >  font  =  get_theme_font ( SNAME ( " rulers " ) ,  EditorStringName ( EditorFonts ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									int  font_size  =  get_theme_font_size ( SNAME ( " rulers_size " ) ,  EditorStringName ( EditorFonts ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-29 21:50:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									// The rule transform
 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-14 18:21:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Transform2D  ruler_transform ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-09 17:53:39 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( grid_snap_active  | |  _is_grid_visible ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										List < CanvasItem  * >  selection  =  _get_edited_canvas_items ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if  ( snap_relative  & &  selection . size ( )  >  0 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-16 11:47:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											ruler_transform . translate_local ( _get_encompassing_rect_from_list ( selection ) . position ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-31 21:54:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											ruler_transform . scale_basis ( grid_step  *  Math : : pow ( 2.0 ,  grid_step_multiplier ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-29 21:50:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-16 11:47:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											ruler_transform . translate_local ( grid_offset ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-31 21:54:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											ruler_transform . scale_basis ( grid_step  *  Math : : pow ( 2.0 ,  grid_step_multiplier ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-29 21:50:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										while  ( ( transform  *  ruler_transform ) . get_scale ( ) . x  <  50  | |  ( transform  *  ruler_transform ) . get_scale ( ) . y  <  50 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											ruler_transform . scale_basis ( Point2 ( 2 ,  2 ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-20 23:30:19 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										real_t  basic_rule  =  100 ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-29 21:50:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										for  ( int  i  =  0 ;  basic_rule  *  zoom  >  100 ;  i + + )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											basic_rule  / =  ( i  %  2 )  ?  5.0  :  2.0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										for  ( int  i  =  0 ;  basic_rule  *  zoom  <  100 ;  i + + )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											basic_rule  * =  ( i  %  2 )  ?  2.0  :  5.0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										ruler_transform . scale ( Size2 ( basic_rule ,  basic_rule ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									// Subdivisions
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									int  major_subdivision  =  2 ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-14 18:21:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Transform2D  major_subdivide ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-29 21:50:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									major_subdivide . scale ( Size2 ( 1.0  /  major_subdivision ,  1.0  /  major_subdivision ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									int  minor_subdivision  =  5 ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-14 18:21:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Transform2D  minor_subdivide ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-29 21:50:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									minor_subdivide . scale ( Size2 ( 1.0  /  minor_subdivision ,  1.0  /  minor_subdivision ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									// First and last graduations to draw (in the ruler space)
 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Point2  first  =  ( transform  *  ruler_transform  *  major_subdivide  *  minor_subdivide ) . affine_inverse ( ) . xform ( Point2 ( RULER_WIDTH ,  RULER_WIDTH ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-29 21:50:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Point2  last  =  ( transform  *  ruler_transform  *  major_subdivide  *  minor_subdivide ) . affine_inverse ( ) . xform ( viewport - > get_size ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									// Draw top ruler
 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									viewport - > draw_rect ( Rect2 ( Point2 ( RULER_WIDTH ,  0 ) ,  Size2 ( viewport - > get_size ( ) . x ,  RULER_WIDTH ) ) ,  bg_color ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-29 21:50:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									for  ( int  i  =  Math : : ceil ( first . x ) ;  i  <  last . x ;  i + + )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-12-17 13:22:04 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Point2  position  =  ( transform  *  ruler_transform  *  major_subdivide  *  minor_subdivide ) . xform ( Point2 ( i ,  0 ) ) . round ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-29 21:50:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( i  %  ( major_subdivision  *  minor_subdivision )  = =  0 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-09 01:49:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											viewport - > draw_line ( Point2 ( position . x ,  0 ) ,  Point2 ( position . x ,  RULER_WIDTH ) ,  graduation_color ,  Math : : round ( EDSCALE ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-20 23:30:19 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											real_t  val  =  ( ruler_transform  *  major_subdivide  *  minor_subdivide ) . xform ( Point2 ( i ,  0 ) ) . x ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-24 20:58:47 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											viewport - > draw_string ( font ,  Point2 ( position . x  +  2 ,  font - > get_height ( font_size ) ) ,  TS - > format_number ( vformat ( ( ( int ) val  = =  val )  ?  " %d "  :  " %.1f " ,  val ) ) ,  HORIZONTAL_ALIGNMENT_LEFT ,  - 1 ,  font_size ,  font_color ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-29 21:50:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if  ( i  %  minor_subdivision  = =  0 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-09 01:49:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												viewport - > draw_line ( Point2 ( position . x ,  RULER_WIDTH  *  0.33 ) ,  Point2 ( position . x ,  RULER_WIDTH ) ,  graduation_color ,  Math : : round ( EDSCALE ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-29 21:50:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-09 01:49:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												viewport - > draw_line ( Point2 ( position . x ,  RULER_WIDTH  *  0.75 ) ,  Point2 ( position . x ,  RULER_WIDTH ) ,  graduation_color ,  Math : : round ( EDSCALE ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-29 21:50:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									// Draw left ruler
 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									viewport - > draw_rect ( Rect2 ( Point2 ( 0 ,  RULER_WIDTH ) ,  Size2 ( RULER_WIDTH ,  viewport - > get_size ( ) . y ) ) ,  bg_color ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-29 21:50:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									for  ( int  i  =  Math : : ceil ( first . y ) ;  i  <  last . y ;  i + + )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-12-17 13:22:04 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Point2  position  =  ( transform  *  ruler_transform  *  major_subdivide  *  minor_subdivide ) . xform ( Point2 ( 0 ,  i ) ) . round ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-29 21:50:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( i  %  ( major_subdivision  *  minor_subdivision )  = =  0 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-09 01:49:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											viewport - > draw_line ( Point2 ( 0 ,  position . y ) ,  Point2 ( RULER_WIDTH ,  position . y ) ,  graduation_color ,  Math : : round ( EDSCALE ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-20 23:30:19 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											real_t  val  =  ( ruler_transform  *  major_subdivide  *  minor_subdivide ) . xform ( Point2 ( 0 ,  i ) ) . y ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-27 16:50:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-09-03 14:22:16 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											Transform2D  text_xform  =  Transform2D ( - Math_PI  /  2.0 ,  Point2 ( font - > get_height ( font_size ) ,  position . y  -  2 ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-27 16:50:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											viewport - > draw_set_transform_matrix ( viewport - > get_transform ( )  *  text_xform ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-24 20:58:47 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											viewport - > draw_string ( font ,  Point2 ( ) ,  TS - > format_number ( vformat ( ( ( int ) val  = =  val )  ?  " %d "  :  " %.1f " ,  val ) ) ,  HORIZONTAL_ALIGNMENT_LEFT ,  - 1 ,  font_size ,  font_color ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-27 16:50:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											viewport - > draw_set_transform_matrix ( viewport - > get_transform ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-08-29 21:50:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if  ( i  %  minor_subdivision  = =  0 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-09 01:49:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												viewport - > draw_line ( Point2 ( RULER_WIDTH  *  0.33 ,  position . y ) ,  Point2 ( RULER_WIDTH ,  position . y ) ,  graduation_color ,  Math : : round ( EDSCALE ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-29 21:50:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-09 01:49:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												viewport - > draw_line ( Point2 ( RULER_WIDTH  *  0.75 ,  position . y ) ,  Point2 ( RULER_WIDTH ,  position . y ) ,  graduation_color ,  Math : : round ( EDSCALE ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-29 21:50:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-05 10:18:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									// Draw the top left corner
 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									viewport - > draw_rect ( Rect2 ( Point2 ( ) ,  Size2 ( RULER_WIDTH ,  RULER_WIDTH ) ) ,  graduation_color ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-29 21:50:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-08-28 21:51:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : _draw_grid ( )  {  
						 
					
						
							
								
									
										
										
										
											2022-02-09 17:53:39 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( _is_grid_visible ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-15 10:23:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										// Draw the grid
 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-29 21:50:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Vector2  real_grid_offset ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-15 10:23:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										const  List < CanvasItem  * >  selection  =  _get_edited_canvas_items ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( snap_relative  & &  selection . size ( )  >  0 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-15 10:23:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											const  Vector2  topleft  =  _get_encompassing_rect_from_list ( selection ) . position ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-19 19:41:36 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											real_grid_offset . x  =  fmod ( topleft . x ,  grid_step . x  *  ( real_t ) Math : : pow ( 2.0 ,  grid_step_multiplier ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											real_grid_offset . y  =  fmod ( topleft . y ,  grid_step . y  *  ( real_t ) Math : : pow ( 2.0 ,  grid_step_multiplier ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-07-25 21:09:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-29 21:50:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											real_grid_offset  =  grid_offset ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-07-25 21:09:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-10-15 10:23:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										// Draw a "primary" line every several lines to make measurements easier.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										// The step is configurable in the Configure Snap dialog.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-18 16:43:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										const  Color  secondary_grid_color  =  EDITOR_GET ( " editors/2d/grid_color " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-15 10:23:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										const  Color  primary_grid_color  = 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												Color ( secondary_grid_color . r ,  secondary_grid_color . g ,  secondary_grid_color . b ,  secondary_grid_color . a  *  2.5 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										const  Size2  viewport_size  =  viewport - > get_size ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										const  Transform2D  xform  =  transform . affine_inverse ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										int  last_cell  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-08-29 21:50:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( grid_step . x  ! =  0 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-15 10:23:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											for  ( int  i  =  0 ;  i  <  viewport_size . width ;  i + + )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												const  int  cell  = 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														Math : : fast_ftoi ( Math : : floor ( ( xform . xform ( Vector2 ( i ,  0 ) ) . x  -  real_grid_offset . x )  /  ( grid_step . x  *  Math : : pow ( 2.0 ,  grid_step_multiplier ) ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												if  ( i  = =  0 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2015-02-15 18:00:55 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													last_cell  =  cell ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-15 10:23:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												if  ( last_cell  ! =  cell )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													Color  grid_color ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-02 17:13:46 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													if  ( primary_grid_step . x  < =  1 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-15 10:23:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														grid_color  =  secondary_grid_color ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-02 17:13:46 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														grid_color  =  cell  %  primary_grid_step . x  = =  0  ?  primary_grid_color  :  secondary_grid_color ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-15 10:23:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													viewport - > draw_line ( Point2 ( i ,  0 ) ,  Point2 ( i ,  viewport_size . height ) ,  grid_color ,  Math : : round ( EDSCALE ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												last_cell  =  cell ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-02-15 18:00:55 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-08-29 21:50:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( grid_step . y  ! =  0 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-15 10:23:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											for  ( int  i  =  0 ;  i  <  viewport_size . height ;  i + + )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												const  int  cell  = 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														Math : : fast_ftoi ( Math : : floor ( ( xform . xform ( Vector2 ( 0 ,  i ) ) . y  -  real_grid_offset . y )  /  ( grid_step . y  *  Math : : pow ( 2.0 ,  grid_step_multiplier ) ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												if  ( i  = =  0 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2015-02-15 18:00:55 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													last_cell  =  cell ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-15 10:23:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												if  ( last_cell  ! =  cell )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													Color  grid_color ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-02 17:13:46 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													if  ( primary_grid_step . y  < =  1 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-15 10:23:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														grid_color  =  secondary_grid_color ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-02 17:13:46 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														grid_color  =  cell  %  primary_grid_step . y  = =  0  ?  primary_grid_color  :  secondary_grid_color ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-15 10:23:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													viewport - > draw_line ( Point2 ( 0 ,  i ) ,  Point2 ( viewport_size . width ,  i ) ,  grid_color ,  Math : : round ( EDSCALE ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												last_cell  =  cell ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-02-15 18:00:55 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-28 21:51:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-08-30 22:49:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : _draw_ruler_tool ( )  {  
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( tool  ! =  TOOL_RULER )  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-08-30 22:49:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2019-08-30 22:49:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-26 20:08:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									const  Ref < Texture2D >  position_icon  =  get_editor_theme_icon ( SNAME ( " EditorPosition " ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-08-30 22:49:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( ruler_tool_active )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-13 02:33:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Color  ruler_primary_color  =  get_theme_color ( SNAME ( " accent_color " ) ,  EditorStringName ( Editor ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-08-30 22:49:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Color  ruler_secondary_color  =  ruler_primary_color ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										ruler_secondary_color . a  =  0.5 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-10-25 04:19:11 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Point2  begin  =  ( ruler_tool_origin  -  view_offset )  *  zoom ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-08-30 22:49:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Point2  end  =  snap_point ( viewport - > get_local_mouse_position ( )  /  zoom  +  view_offset )  *  zoom  -  view_offset  *  zoom ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										Point2  corner  =  Point2 ( begin . x ,  end . y ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										Vector2  length_vector  =  ( begin  -  end ) . abs ( )  /  zoom ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-22 15:14:35 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										const  real_t  horizontal_angle_rad  =  length_vector . angle ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										const  real_t  vertical_angle_rad  =  Math_PI  /  2.0  -  horizontal_angle_rad ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-13 02:33:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Ref < Font >  font  =  get_theme_font ( SNAME ( " bold " ) ,  EditorStringName ( EditorFonts ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										int  font_size  =  1.3  *  get_theme_font_size ( SNAME ( " bold_size " ) ,  EditorStringName ( EditorFonts ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-14 15:57:29 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Color  font_color  =  get_theme_color ( SceneStringName ( font_color ) ,  EditorStringName ( Editor ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-08-30 22:49:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Color  font_secondary_color  =  font_color ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-27 17:23:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										font_secondary_color . set_v ( font_secondary_color . get_v ( )  >  0.5  ?  0.7  :  0.3 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										Color  outline_color  =  font_color . inverted ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-03 14:22:16 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										float  text_height  =  font - > get_height ( font_size ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-27 17:23:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-01-03 22:42:53 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										const  float  outline_size  =  4 ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-08-30 22:49:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										const  float  text_width  =  76 ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-06 17:19:13 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										const  float  angle_text_width  =  54 ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-08-30 22:49:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										Point2  text_pos  =  ( begin  +  end )  /  2  -  Vector2 ( text_width  /  2 ,  text_height  /  2 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										text_pos . x  =  CLAMP ( text_pos . x ,  text_width  /  2 ,  viewport - > get_rect ( ) . size . x  -  text_width  *  1.5 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										text_pos . y  =  CLAMP ( text_pos . y ,  text_height  *  1.5 ,  viewport - > get_rect ( ) . size . y  -  text_height  *  1.5 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-07 00:00:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-22 15:14:35 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										// Draw lines.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										viewport - > draw_line ( begin ,  end ,  ruler_primary_color ,  Math : : round ( EDSCALE  *  3 ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										bool  draw_secondary_lines  =  ! ( Math : : is_equal_approx ( begin . y ,  corner . y )  | |  Math : : is_equal_approx ( end . x ,  corner . x ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if  ( draw_secondary_lines )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											viewport - > draw_line ( begin ,  corner ,  ruler_secondary_color ,  Math : : round ( EDSCALE ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											viewport - > draw_line ( corner ,  end ,  ruler_secondary_color ,  Math : : round ( EDSCALE ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											// Angle arcs.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											int  arc_point_count  =  8 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											real_t  arc_radius_max_length_percent  =  0.1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											real_t  ruler_length  =  length_vector . length ( )  *  zoom ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											real_t  arc_max_radius  =  50.0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											real_t  arc_line_width  =  2.0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											const  Vector2  end_to_begin  =  ( end  -  begin ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											real_t  arc_1_start_angle  =  end_to_begin . x  <  0 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													?  ( end_to_begin . y  <  0  ?  3.0  *  Math_PI  /  2.0  -  vertical_angle_rad  :  Math_PI  /  2.0 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													:  ( end_to_begin . y  <  0  ?  3.0  *  Math_PI  /  2.0  :  Math_PI  /  2.0  -  vertical_angle_rad ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											real_t  arc_1_end_angle  =  arc_1_start_angle  +  vertical_angle_rad ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											// Constrain arc to triangle height & max size.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-30 17:56:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											real_t  arc_1_radius  =  MIN ( MIN ( arc_radius_max_length_percent  *  ruler_length ,  Math : : abs ( end_to_begin . y ) ) ,  arc_max_radius ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-22 15:14:35 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											real_t  arc_2_start_angle  =  end_to_begin . x  <  0 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													?  ( end_to_begin . y  <  0  ?  0.0  :  - horizontal_angle_rad ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													:  ( end_to_begin . y  <  0  ?  Math_PI  -  horizontal_angle_rad  :  Math_PI ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											real_t  arc_2_end_angle  =  arc_2_start_angle  +  horizontal_angle_rad ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											// Constrain arc to triangle width & max size.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-30 17:56:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											real_t  arc_2_radius  =  MIN ( MIN ( arc_radius_max_length_percent  *  ruler_length ,  Math : : abs ( end_to_begin . x ) ) ,  arc_max_radius ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-22 15:14:35 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											viewport - > draw_arc ( begin ,  arc_1_radius ,  arc_1_start_angle ,  arc_1_end_angle ,  arc_point_count ,  ruler_primary_color ,  Math : : round ( EDSCALE  *  arc_line_width ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											viewport - > draw_arc ( end ,  arc_2_radius ,  arc_2_start_angle ,  arc_2_end_angle ,  arc_point_count ,  ruler_primary_color ,  Math : : round ( EDSCALE  *  arc_line_width ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										// Draw text.
 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-07 00:00:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( begin . is_equal_approx ( end ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-05-09 12:47:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											viewport - > draw_string_outline ( font ,  text_pos ,  ( String ) ruler_tool_origin ,  HORIZONTAL_ALIGNMENT_LEFT ,  - 1 ,  font_size ,  outline_size ,  outline_color ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											viewport - > draw_string ( font ,  text_pos ,  ( String ) ruler_tool_origin ,  HORIZONTAL_ALIGNMENT_LEFT ,  - 1 ,  font_size ,  font_color ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-26 20:08:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											viewport - > draw_texture ( position_icon ,  ( ruler_tool_origin  -  view_offset )  *  zoom  -  position_icon - > get_size ( )  /  2 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-07 00:00:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-05-09 12:47:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										viewport - > draw_string_outline ( font ,  text_pos ,  TS - > format_number ( vformat ( " %.1f px " ,  length_vector . length ( ) ) ) ,  HORIZONTAL_ALIGNMENT_LEFT ,  - 1 ,  font_size ,  outline_size ,  outline_color ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										viewport - > draw_string ( font ,  text_pos ,  TS - > format_number ( vformat ( " %.1f px " ,  length_vector . length ( ) ) ) ,  HORIZONTAL_ALIGNMENT_LEFT ,  - 1 ,  font_size ,  font_color ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-08-30 22:49:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if  ( draw_secondary_lines )  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-15 16:47:58 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											const  int  horizontal_angle  =  round ( 180  *  horizontal_angle_rad  /  Math_PI ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											const  int  vertical_angle  =  round ( 180  *  vertical_angle_rad  /  Math_PI ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-08-30 22:49:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											Point2  text_pos2  =  text_pos ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											text_pos2 . x  =  begin . x  <  text_pos . x  ?  MIN ( text_pos . x  -  text_width ,  begin . x  -  text_width  /  2 )  :  MAX ( text_pos . x  +  text_width ,  begin . x  -  text_width  /  2 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-05-09 12:47:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											viewport - > draw_string_outline ( font ,  text_pos2 ,  TS - > format_number ( vformat ( " %.1f px " ,  length_vector . y ) ) ,  HORIZONTAL_ALIGNMENT_LEFT ,  - 1 ,  font_size ,  outline_size ,  outline_color ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											viewport - > draw_string ( font ,  text_pos2 ,  TS - > format_number ( vformat ( " %.1f px " ,  length_vector . y ) ) ,  HORIZONTAL_ALIGNMENT_LEFT ,  - 1 ,  font_size ,  font_secondary_color ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-08-30 22:49:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-11-14 18:21:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											Point2  v_angle_text_pos ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-06 17:19:13 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											v_angle_text_pos . x  =  CLAMP ( begin . x  -  angle_text_width  /  2 ,  angle_text_width  /  2 ,  viewport - > get_rect ( ) . size . x  -  angle_text_width ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											v_angle_text_pos . y  =  begin . y  <  end . y  ?  MIN ( text_pos2 . y  -  2  *  text_height ,  begin . y  -  text_height  *  0.5 )  :  MAX ( text_pos2 . y  +  text_height  *  3 ,  begin . y  +  text_height  *  1.5 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-07 10:37:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											viewport - > draw_string_outline ( font ,  v_angle_text_pos ,  TS - > format_number ( vformat ( U " %d° " ,  vertical_angle ) ) ,  HORIZONTAL_ALIGNMENT_LEFT ,  - 1 ,  font_size ,  outline_size ,  outline_color ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											viewport - > draw_string ( font ,  v_angle_text_pos ,  TS - > format_number ( vformat ( U " %d° " ,  vertical_angle ) ) ,  HORIZONTAL_ALIGNMENT_LEFT ,  - 1 ,  font_size ,  font_secondary_color ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-06 17:19:13 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-08-30 22:49:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											text_pos2  =  text_pos ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											text_pos2 . y  =  end . y  <  text_pos . y  ?  MIN ( text_pos . y  -  text_height  *  2 ,  end . y  -  text_height  /  2 )  :  MAX ( text_pos . y  +  text_height  *  2 ,  end . y  -  text_height  /  2 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-05-09 12:47:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											viewport - > draw_string_outline ( font ,  text_pos2 ,  TS - > format_number ( vformat ( " %.1f px " ,  length_vector . x ) ) ,  HORIZONTAL_ALIGNMENT_LEFT ,  - 1 ,  font_size ,  outline_size ,  outline_color ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											viewport - > draw_string ( font ,  text_pos2 ,  TS - > format_number ( vformat ( " %.1f px " ,  length_vector . x ) ) ,  HORIZONTAL_ALIGNMENT_LEFT ,  - 1 ,  font_size ,  font_secondary_color ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-06 17:19:13 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-11-14 18:21:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											Point2  h_angle_text_pos ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-06 17:19:13 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											h_angle_text_pos . x  =  CLAMP ( end . x  -  angle_text_width  /  2 ,  angle_text_width  /  2 ,  viewport - > get_rect ( ) . size . x  -  angle_text_width ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if  ( begin . y  <  end . y )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												h_angle_text_pos . y  =  end . y  +  text_height  *  1.5 ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-30 17:56:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												if  ( Math : : abs ( text_pos2 . x  -  h_angle_text_pos . x )  <  text_width )  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-24 22:31:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													int  height_multiplier  =  1.5  +  ( int ) grid_snap_active ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-06 17:19:13 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													h_angle_text_pos . y  =  MAX ( text_pos . y  +  height_multiplier  *  text_height ,  MAX ( end . y  +  text_height  *  1.5 ,  text_pos2 . y  +  height_multiplier  *  text_height ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												h_angle_text_pos . y  =  end . y  -  text_height  *  0.5 ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-30 17:56:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												if  ( Math : : abs ( text_pos2 . x  -  h_angle_text_pos . x )  <  text_width )  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-24 22:31:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													int  height_multiplier  =  1  +  ( int ) grid_snap_active ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-06 17:19:13 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													h_angle_text_pos . y  =  MIN ( text_pos . y  -  height_multiplier  *  text_height ,  MIN ( end . y  -  text_height  *  0.5 ,  text_pos2 . y  -  height_multiplier  *  text_height ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-07 10:37:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											viewport - > draw_string_outline ( font ,  h_angle_text_pos ,  TS - > format_number ( vformat ( U " %d° " ,  horizontal_angle ) ) ,  HORIZONTAL_ALIGNMENT_LEFT ,  - 1 ,  font_size ,  outline_size ,  outline_color ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											viewport - > draw_string ( font ,  h_angle_text_pos ,  TS - > format_number ( vformat ( U " %d° " ,  horizontal_angle ) ) ,  HORIZONTAL_ALIGNMENT_LEFT ,  - 1 ,  font_size ,  font_secondary_color ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-08-30 22:49:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-10-24 22:31:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( grid_snap_active )  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-08-30 22:49:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											text_pos  =  ( begin  +  end )  /  2  +  Vector2 ( - text_width  /  2 ,  text_height  /  2 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											text_pos . x  =  CLAMP ( text_pos . x ,  text_width  /  2 ,  viewport - > get_rect ( ) . size . x  -  text_width  *  1.5 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											text_pos . y  =  CLAMP ( text_pos . y ,  text_height  *  2.5 ,  viewport - > get_rect ( ) . size . y  -  text_height  /  2 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if  ( draw_secondary_lines )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-05-09 12:47:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												viewport - > draw_string_outline ( font ,  text_pos ,  TS - > format_number ( vformat ( " %.2f  "  +  TTR ( " units " ) ,  ( length_vector  /  grid_step ) . length ( ) ) ) ,  HORIZONTAL_ALIGNMENT_LEFT ,  - 1 ,  font_size ,  outline_size ,  outline_color ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												viewport - > draw_string ( font ,  text_pos ,  TS - > format_number ( vformat ( " %.2f  "  +  TTR ( " units " ) ,  ( length_vector  /  grid_step ) . length ( ) ) ) ,  HORIZONTAL_ALIGNMENT_LEFT ,  - 1 ,  font_size ,  font_color ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-08-30 22:49:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												Point2  text_pos2  =  text_pos ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												text_pos2 . x  =  begin . x  <  text_pos . x  ?  MIN ( text_pos . x  -  text_width ,  begin . x  -  text_width  /  2 )  :  MAX ( text_pos . x  +  text_width ,  begin . x  -  text_width  /  2 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-05-09 12:47:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												viewport - > draw_string_outline ( font ,  text_pos2 ,  TS - > format_number ( vformat ( " %d  "  +  TTR ( " units " ) ,  roundf ( length_vector . y  /  grid_step . y ) ) ) ,  HORIZONTAL_ALIGNMENT_LEFT ,  - 1 ,  font_size ,  outline_size ,  outline_color ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												viewport - > draw_string ( font ,  text_pos2 ,  TS - > format_number ( vformat ( " %d  "  +  TTR ( " units " ) ,  roundf ( length_vector . y  /  grid_step . y ) ) ) ,  HORIZONTAL_ALIGNMENT_LEFT ,  - 1 ,  font_size ,  font_secondary_color ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-08-30 22:49:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												text_pos2  =  text_pos ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												text_pos2 . y  =  end . y  <  text_pos . y  ?  MIN ( text_pos . y  -  text_height  *  2 ,  end . y  +  text_height  /  2 )  :  MAX ( text_pos . y  +  text_height  *  2 ,  end . y  +  text_height  /  2 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-05-09 12:47:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												viewport - > draw_string_outline ( font ,  text_pos2 ,  TS - > format_number ( vformat ( " %d  "  +  TTR ( " units " ) ,  roundf ( length_vector . x  /  grid_step . x ) ) ) ,  HORIZONTAL_ALIGNMENT_LEFT ,  - 1 ,  font_size ,  outline_size ,  outline_color ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												viewport - > draw_string ( font ,  text_pos2 ,  TS - > format_number ( vformat ( " %d  "  +  TTR ( " units " ) ,  roundf ( length_vector . x  /  grid_step . x ) ) ) ,  HORIZONTAL_ALIGNMENT_LEFT ,  - 1 ,  font_size ,  font_secondary_color ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-08-30 22:49:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-05-09 12:47:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												viewport - > draw_string_outline ( font ,  text_pos ,  TS - > format_number ( vformat ( " %d  "  +  TTR ( " units " ) ,  roundf ( ( length_vector  /  grid_step ) . length ( ) ) ) ) ,  HORIZONTAL_ALIGNMENT_LEFT ,  - 1 ,  font_size ,  outline_size ,  outline_color ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												viewport - > draw_string ( font ,  text_pos ,  TS - > format_number ( vformat ( " %d  "  +  TTR ( " units " ) ,  roundf ( ( length_vector  /  grid_step ) . length ( ) ) ) ) ,  HORIZONTAL_ALIGNMENT_LEFT ,  - 1 ,  font_size ,  font_color ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-08-30 22:49:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-24 22:31:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( grid_snap_active )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-21 01:22:11 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											viewport - > draw_texture ( position_icon ,  ( ruler_tool_origin  -  view_offset )  *  zoom  -  position_icon - > get_size ( )  /  2 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-08-30 22:49:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-03-31 18:53:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : _draw_control_anchors ( Control  * control )  {  
						 
					
						
							
								
									
										
										
										
											2024-11-18 17:16:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Transform2D  xform  =  transform  *  control - > get_screen_transform ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-10 14:39:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									RID  ci  =  viewport - > get_canvas_item ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-03-31 18:53:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( tool  = =  TOOL_SELECT  & &  ! Object : : cast_to < Container > ( control - > get_parent ( ) ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										// Compute the anchors
 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-20 23:30:19 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										real_t  anchors_values [ 4 ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-12-22 16:24:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										anchors_values [ 0 ]  =  control - > get_anchor ( SIDE_LEFT ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										anchors_values [ 1 ]  =  control - > get_anchor ( SIDE_TOP ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										anchors_values [ 2 ]  =  control - > get_anchor ( SIDE_RIGHT ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										anchors_values [ 3 ]  =  control - > get_anchor ( SIDE_BOTTOM ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-03-31 18:53:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										Vector2  anchors_pos [ 4 ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										for  ( int  i  =  0 ;  i  <  4 ;  i + + )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											Vector2  value  =  Vector2 ( ( i  %  2  = =  0 )  ?  anchors_values [ i ]  :  anchors_values [ ( i  +  1 )  %  4 ] ,  ( i  %  2  = =  1 )  ?  anchors_values [ i ]  :  anchors_values [ ( i  +  1 )  %  4 ] ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											anchors_pos [ i ]  =  xform . xform ( _anchor_to_position ( control ,  value ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										// Draw the anchors handles
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										Rect2  anchor_rects [ 4 ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-03 14:22:16 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( control - > is_layout_rtl ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											anchor_rects [ 0 ]  =  Rect2 ( anchors_pos [ 0 ]  -  Vector2 ( 0.0 ,  anchor_handle - > get_size ( ) . y ) ,  Point2 ( - anchor_handle - > get_size ( ) . x ,  anchor_handle - > get_size ( ) . y ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											anchor_rects [ 1 ]  =  Rect2 ( anchors_pos [ 1 ]  -  anchor_handle - > get_size ( ) ,  anchor_handle - > get_size ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											anchor_rects [ 2 ]  =  Rect2 ( anchors_pos [ 2 ]  -  Vector2 ( anchor_handle - > get_size ( ) . x ,  0.0 ) ,  Point2 ( anchor_handle - > get_size ( ) . x ,  - anchor_handle - > get_size ( ) . y ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											anchor_rects [ 3 ]  =  Rect2 ( anchors_pos [ 3 ] ,  - anchor_handle - > get_size ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											anchor_rects [ 0 ]  =  Rect2 ( anchors_pos [ 0 ]  -  anchor_handle - > get_size ( ) ,  anchor_handle - > get_size ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											anchor_rects [ 1 ]  =  Rect2 ( anchors_pos [ 1 ]  -  Vector2 ( 0.0 ,  anchor_handle - > get_size ( ) . y ) ,  Point2 ( - anchor_handle - > get_size ( ) . x ,  anchor_handle - > get_size ( ) . y ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											anchor_rects [ 2 ]  =  Rect2 ( anchors_pos [ 2 ] ,  - anchor_handle - > get_size ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											anchor_rects [ 3 ]  =  Rect2 ( anchors_pos [ 3 ]  -  Vector2 ( anchor_handle - > get_size ( ) . x ,  0.0 ) ,  Point2 ( anchor_handle - > get_size ( ) . x ,  - anchor_handle - > get_size ( ) . y ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2019-03-31 18:53:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										for  ( int  i  =  0 ;  i  <  4 ;  i + + )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											anchor_handle - > draw_rect ( ci ,  anchor_rects [ i ] ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : _draw_control_helpers ( Control  * control )  {  
						 
					
						
							
								
									
										
										
										
											2024-11-18 17:16:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Transform2D  xform  =  transform  *  control - > get_screen_transform ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-10 14:39:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( tool  = =  TOOL_SELECT  & &  show_helpers  & &  ! Object : : cast_to < Container > ( control - > get_parent ( ) ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										// Draw the helpers
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										Color  color_base  =  Color ( 0.8 ,  0.8 ,  0.8 ,  0.5 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-03-31 18:53:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										// Compute the anchors
 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-20 23:30:19 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										real_t  anchors_values [ 4 ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-12-22 16:24:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										anchors_values [ 0 ]  =  control - > get_anchor ( SIDE_LEFT ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										anchors_values [ 1 ]  =  control - > get_anchor ( SIDE_TOP ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										anchors_values [ 2 ]  =  control - > get_anchor ( SIDE_RIGHT ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										anchors_values [ 3 ]  =  control - > get_anchor ( SIDE_BOTTOM ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-10 14:39:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										Vector2  anchors [ 4 ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										Vector2  anchors_pos [ 4 ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										for  ( int  i  =  0 ;  i  <  4 ;  i + + )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											anchors [ i ]  =  Vector2 ( ( i  %  2  = =  0 )  ?  anchors_values [ i ]  :  anchors_values [ ( i  +  1 )  %  4 ] ,  ( i  %  2  = =  1 )  ?  anchors_values [ i ]  :  anchors_values [ ( i  +  1 )  %  4 ] ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											anchors_pos [ i ]  =  xform . xform ( _anchor_to_position ( control ,  anchors [ i ] ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										// Get which anchor is dragged
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										int  dragged_anchor  =  - 1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										switch  ( drag_type )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											case  DRAG_ANCHOR_ALL : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											case  DRAG_ANCHOR_TOP_LEFT : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												dragged_anchor  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											case  DRAG_ANCHOR_TOP_RIGHT : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												dragged_anchor  =  1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											case  DRAG_ANCHOR_BOTTOM_RIGHT : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												dragged_anchor  =  2 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											case  DRAG_ANCHOR_BOTTOM_LEFT : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												dragged_anchor  =  3 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											default : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if  ( dragged_anchor  > =  0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											// Draw the 4 lines when dragged
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											Color  color_snapped  =  Color ( 0.64 ,  0.93 ,  0.67 ,  0.5 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											Vector2  corners_pos [ 4 ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											for  ( int  i  =  0 ;  i  <  4 ;  i + + )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												corners_pos [ i ]  =  xform . xform ( _anchor_to_position ( control ,  Vector2 ( ( i  = =  0  | |  i  = =  3 )  ?  ANCHOR_BEGIN  :  ANCHOR_END ,  ( i  < =  1 )  ?  ANCHOR_BEGIN  :  ANCHOR_END ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											Vector2  line_starts [ 4 ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											Vector2  line_ends [ 4 ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											for  ( int  i  =  0 ;  i  <  4 ;  i + + )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-20 23:30:19 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												real_t  anchor_val  =  ( i  > =  2 )  ?  ANCHOR_END  -  anchors_values [ i ]  :  anchors_values [ i ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-16 05:07:33 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												line_starts [ i ]  =  corners_pos [ i ] . lerp ( corners_pos [ ( i  +  1 )  %  4 ] ,  anchor_val ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												line_ends [ i ]  =  corners_pos [ ( i  +  3 )  %  4 ] . lerp ( corners_pos [ ( i  +  2 )  %  4 ] ,  anchor_val ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-05 13:40:26 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												bool  anchor_snapped  =  anchors_values [ i ]  = =  0.0  | |  anchors_values [ i ]  = =  0.5  | |  anchors_values [ i ]  = =  1.0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-05 10:18:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												viewport - > draw_line ( line_starts [ i ] ,  line_ends [ i ] ,  anchor_snapped  ?  color_snapped  :  color_base ,  ( i  = =  dragged_anchor  | |  ( i  +  3 )  %  4  = =  dragged_anchor )  ?  2  :  1 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-10 14:39:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											// Display the percentages next to the lines
 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-20 23:30:19 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											real_t  percent_val ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-10 14:39:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											percent_val  =  anchors_values [ ( dragged_anchor  +  2 )  %  4 ]  -  anchors_values [ dragged_anchor ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											percent_val  =  ( dragged_anchor  > =  2 )  ?  - percent_val  :  percent_val ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-12-22 16:24:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											_draw_percentage_at_position ( percent_val ,  ( anchors_pos [ dragged_anchor ]  +  anchors_pos [ ( dragged_anchor  +  1 )  %  4 ] )  /  2 ,  ( Side ) ( ( dragged_anchor  +  1 )  %  4 ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-10 14:39:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											percent_val  =  anchors_values [ ( dragged_anchor  +  3 )  %  4 ]  -  anchors_values [ ( dragged_anchor  +  1 )  %  4 ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											percent_val  =  ( ( dragged_anchor  +  1 )  %  4  > =  2 )  ?  - percent_val  :  percent_val ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-12-22 16:24:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											_draw_percentage_at_position ( percent_val ,  ( anchors_pos [ dragged_anchor ]  +  anchors_pos [ ( dragged_anchor  +  3 )  %  4 ] )  /  2 ,  ( Side ) ( dragged_anchor ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-10 14:39:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											percent_val  =  anchors_values [ ( dragged_anchor  +  1 )  %  4 ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											percent_val  =  ( ( dragged_anchor  +  1 )  %  4  > =  2 )  ?  ANCHOR_END  -  percent_val  :  percent_val ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-12-22 16:24:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											_draw_percentage_at_position ( percent_val ,  ( line_starts [ dragged_anchor ]  +  anchors_pos [ dragged_anchor ] )  /  2 ,  ( Side ) ( dragged_anchor ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-10 14:39:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											percent_val  =  anchors_values [ dragged_anchor ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											percent_val  =  ( dragged_anchor  > =  2 )  ?  ANCHOR_END  -  percent_val  :  percent_val ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-12-22 16:24:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											_draw_percentage_at_position ( percent_val ,  ( line_ends [ ( dragged_anchor  +  1 )  %  4 ]  +  anchors_pos [ dragged_anchor ] )  /  2 ,  ( Side ) ( ( dragged_anchor  +  1 )  %  4 ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-10 14:39:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										// Draw the margin values and the node width/height when dragging control side
 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-20 23:30:19 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										const  real_t  ratio  =  0.33 ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-10 14:39:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Transform2D  parent_transform  =  xform  *  control - > get_transform ( ) . affine_inverse ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-20 23:30:19 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										real_t  node_pos_in_parent [ 4 ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-10 14:39:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										Rect2  parent_rect  =  control - > get_parent_anchorable_rect ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-12-22 16:24:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										node_pos_in_parent [ 0 ]  =  control - > get_anchor ( SIDE_LEFT )  *  parent_rect . size . width  +  control - > get_offset ( SIDE_LEFT )  +  parent_rect . position . x ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										node_pos_in_parent [ 1 ]  =  control - > get_anchor ( SIDE_TOP )  *  parent_rect . size . height  +  control - > get_offset ( SIDE_TOP )  +  parent_rect . position . y ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										node_pos_in_parent [ 2 ]  =  control - > get_anchor ( SIDE_RIGHT )  *  parent_rect . size . width  +  control - > get_offset ( SIDE_RIGHT )  +  parent_rect . position . x ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										node_pos_in_parent [ 3 ]  =  control - > get_anchor ( SIDE_BOTTOM )  *  parent_rect . size . height  +  control - > get_offset ( SIDE_BOTTOM )  +  parent_rect . position . y ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-10 14:39:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										Point2  start ,  end ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										switch  ( drag_type )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											case  DRAG_LEFT : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											case  DRAG_TOP_LEFT : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											case  DRAG_BOTTOM_LEFT : 
							 
						 
					
						
							
								
									
										
										
										
											2020-12-22 16:24:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												_draw_margin_at_position ( control - > get_size ( ) . width ,  parent_transform . xform ( Vector2 ( ( node_pos_in_parent [ 0 ]  +  node_pos_in_parent [ 2 ] )  /  2 ,  node_pos_in_parent [ 3 ] ) )  +  Vector2 ( 0 ,  5 ) ,  SIDE_BOTTOM ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-22 20:47:50 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												[[fallthrough]] ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-10 14:39:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											case  DRAG_MOVE : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												start  =  Vector2 ( node_pos_in_parent [ 0 ] ,  Math : : lerp ( node_pos_in_parent [ 1 ] ,  node_pos_in_parent [ 3 ] ,  ratio ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-12-22 16:24:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												end  =  start  -  Vector2 ( control - > get_offset ( SIDE_LEFT ) ,  0 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												_draw_margin_at_position ( control - > get_offset ( SIDE_LEFT ) ,  parent_transform . xform ( ( start  +  end )  /  2 ) ,  SIDE_TOP ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-09 01:49:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												viewport - > draw_line ( parent_transform . xform ( start ) ,  parent_transform . xform ( end ) ,  color_base ,  Math : : round ( EDSCALE ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-10 14:39:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											default : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										switch  ( drag_type )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											case  DRAG_RIGHT : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											case  DRAG_TOP_RIGHT : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											case  DRAG_BOTTOM_RIGHT : 
							 
						 
					
						
							
								
									
										
										
										
											2020-12-22 16:24:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												_draw_margin_at_position ( control - > get_size ( ) . width ,  parent_transform . xform ( Vector2 ( ( node_pos_in_parent [ 0 ]  +  node_pos_in_parent [ 2 ] )  /  2 ,  node_pos_in_parent [ 3 ] ) )  +  Vector2 ( 0 ,  5 ) ,  SIDE_BOTTOM ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-22 20:47:50 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												[[fallthrough]] ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-10 14:39:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											case  DRAG_MOVE : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												start  =  Vector2 ( node_pos_in_parent [ 2 ] ,  Math : : lerp ( node_pos_in_parent [ 3 ] ,  node_pos_in_parent [ 1 ] ,  ratio ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-12-22 16:24:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												end  =  start  -  Vector2 ( control - > get_offset ( SIDE_RIGHT ) ,  0 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												_draw_margin_at_position ( control - > get_offset ( SIDE_RIGHT ) ,  parent_transform . xform ( ( start  +  end )  /  2 ) ,  SIDE_BOTTOM ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-09 01:49:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												viewport - > draw_line ( parent_transform . xform ( start ) ,  parent_transform . xform ( end ) ,  color_base ,  Math : : round ( EDSCALE ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-10 14:39:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											default : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										switch  ( drag_type )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											case  DRAG_TOP : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											case  DRAG_TOP_LEFT : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											case  DRAG_TOP_RIGHT : 
							 
						 
					
						
							
								
									
										
										
										
											2020-12-22 16:24:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												_draw_margin_at_position ( control - > get_size ( ) . height ,  parent_transform . xform ( Vector2 ( node_pos_in_parent [ 2 ] ,  ( node_pos_in_parent [ 1 ]  +  node_pos_in_parent [ 3 ] )  /  2 ) )  +  Vector2 ( 5 ,  0 ) ,  SIDE_RIGHT ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-22 20:47:50 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												[[fallthrough]] ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-10 14:39:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											case  DRAG_MOVE : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												start  =  Vector2 ( Math : : lerp ( node_pos_in_parent [ 0 ] ,  node_pos_in_parent [ 2 ] ,  ratio ) ,  node_pos_in_parent [ 1 ] ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-12-22 16:24:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												end  =  start  -  Vector2 ( 0 ,  control - > get_offset ( SIDE_TOP ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												_draw_margin_at_position ( control - > get_offset ( SIDE_TOP ) ,  parent_transform . xform ( ( start  +  end )  /  2 ) ,  SIDE_LEFT ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-09 01:49:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												viewport - > draw_line ( parent_transform . xform ( start ) ,  parent_transform . xform ( end ) ,  color_base ,  Math : : round ( EDSCALE ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-10 14:39:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											default : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										switch  ( drag_type )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											case  DRAG_BOTTOM : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											case  DRAG_BOTTOM_LEFT : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											case  DRAG_BOTTOM_RIGHT : 
							 
						 
					
						
							
								
									
										
										
										
											2020-12-22 16:24:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												_draw_margin_at_position ( control - > get_size ( ) . height ,  parent_transform . xform ( Vector2 ( node_pos_in_parent [ 2 ] ,  ( node_pos_in_parent [ 1 ]  +  node_pos_in_parent [ 3 ] )  /  2 )  +  Vector2 ( 5 ,  0 ) ) ,  SIDE_RIGHT ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-22 20:47:50 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												[[fallthrough]] ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-10 14:39:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											case  DRAG_MOVE : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												start  =  Vector2 ( Math : : lerp ( node_pos_in_parent [ 2 ] ,  node_pos_in_parent [ 0 ] ,  ratio ) ,  node_pos_in_parent [ 3 ] ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-12-22 16:24:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												end  =  start  -  Vector2 ( 0 ,  control - > get_offset ( SIDE_BOTTOM ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												_draw_margin_at_position ( control - > get_offset ( SIDE_BOTTOM ) ,  parent_transform . xform ( ( start  +  end )  /  2 ) ,  SIDE_RIGHT ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-09 01:49:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												viewport - > draw_line ( parent_transform . xform ( start ) ,  parent_transform . xform ( end ) ,  color_base ,  Math : : round ( EDSCALE ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-10 14:39:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											default : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										switch  ( drag_type )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											//Draw the ghost rect if the node if rotated/scaled
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											case  DRAG_LEFT : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											case  DRAG_TOP_LEFT : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											case  DRAG_TOP : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											case  DRAG_TOP_RIGHT : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											case  DRAG_RIGHT : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											case  DRAG_BOTTOM_RIGHT : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											case  DRAG_BOTTOM : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											case  DRAG_BOTTOM_LEFT : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											case  DRAG_MOVE : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												if  ( control - > get_rotation ( )  ! =  0.0  | |  control - > get_scale ( )  ! =  Vector2 ( 1 ,  1 ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													Rect2  rect  =  Rect2 ( Vector2 ( node_pos_in_parent [ 0 ] ,  node_pos_in_parent [ 1 ] ) ,  control - > get_size ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-09 01:49:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													viewport - > draw_rect ( parent_transform . xform ( rect ) ,  color_base ,  false ,  Math : : round ( EDSCALE ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-10 14:39:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											default : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-08-28 21:51:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : _draw_selection ( )  {  
						 
					
						
							
								
									
										
										
										
											2023-08-13 02:33:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Ref < Texture2D >  pivot_icon  =  get_editor_theme_icon ( SNAME ( " EditorPivot " ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Ref < Texture2D >  position_icon  =  get_editor_theme_icon ( SNAME ( " EditorPosition " ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Ref < Texture2D >  previous_position_icon  =  get_editor_theme_icon ( SNAME ( " EditorPositionPrevious " ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-10 11:56:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									RID  vp_ci  =  viewport - > get_canvas_item ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-04-15 22:03:12 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									List < CanvasItem  * >  selection  =  _get_edited_canvas_items ( true ,  false ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									bool  single  =  selection . size ( )  = =  1 ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-25 16:34:32 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									bool  transform_tool  =  tool  = =  TOOL_SELECT  | |  tool  = =  TOOL_MOVE  | |  tool  = =  TOOL_SCALE  | |  tool  = =  TOOL_ROTATE  | |  tool  = =  TOOL_EDIT_PIVOT ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-07-15 23:45:57 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									for  ( CanvasItem  * E  :  selection )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										CanvasItem  * ci  =  Object : : cast_to < CanvasItem > ( E ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										CanvasItemEditorSelectedItem  * se  =  editor_selection - > get_node_editor_data < CanvasItemEditorSelectedItem > ( ci ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										// Draw the previous position if we are dragging the node
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if  ( show_helpers  & & 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-09 22:17:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												( drag_type  = =  DRAG_MOVE  | |  drag_type  = =  DRAG_ROTATE  | | 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														drag_type  = =  DRAG_LEFT  | |  drag_type  = =  DRAG_RIGHT  | |  drag_type  = =  DRAG_TOP  | |  drag_type  = =  DRAG_BOTTOM  | | 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														drag_type  = =  DRAG_TOP_LEFT  | |  drag_type  = =  DRAG_TOP_RIGHT  | |  drag_type  = =  DRAG_BOTTOM_LEFT  | |  drag_type  = =  DRAG_BOTTOM_RIGHT ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-12 19:11:53 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											const  Transform2D  pre_drag_xform  =  transform  *  se - > pre_drag_xform ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											const  Color  pre_drag_color  =  Color ( 0.4 ,  0.6 ,  1 ,  0.7 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if  ( ci - > _edit_use_rect ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-08 21:35:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												Vector2  pre_drag_endpoints [ 4 ]  =  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													pre_drag_xform . xform ( se - > pre_drag_rect . position ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													pre_drag_xform . xform ( se - > pre_drag_rect . position  +  Vector2 ( se - > pre_drag_rect . size . x ,  0 ) ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													pre_drag_xform . xform ( se - > pre_drag_rect . position  +  se - > pre_drag_rect . size ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													pre_drag_xform . xform ( se - > pre_drag_rect . position  +  Vector2 ( 0 ,  se - > pre_drag_rect . size . y ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												} ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-12 19:11:53 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-03-08 21:35:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												for  ( int  i  =  0 ;  i  <  4 ;  i + + )  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-06-24 22:24:07 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													viewport - > draw_line ( pre_drag_endpoints [ i ] ,  pre_drag_endpoints [ ( i  +  1 )  %  4 ] ,  pre_drag_color ,  Math : : round ( 2  *  EDSCALE ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-08 21:35:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-10 11:56:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												viewport - > draw_texture ( previous_position_icon ,  ( pre_drag_xform . xform ( Point2 ( ) )  -  ( previous_position_icon - > get_size ( )  /  2 ) ) . floor ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-12 19:11:53 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-10-25 16:34:32 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										bool  item_locked  =  ci - > has_meta ( " _edit_lock_ " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-18 17:16:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Transform2D  xform  =  transform  *  ci - > get_screen_transform ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-03-08 21:35:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										// Draw the selected items position / surrounding boxes
 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( ci - > _edit_use_rect ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											Rect2  rect  =  ci - > _edit_get_rect ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-05 13:40:26 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											const  Vector2  endpoints [ 4 ]  =  { 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-08 21:35:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												xform . xform ( rect . position ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												xform . xform ( rect . position  +  Vector2 ( rect . size . x ,  0 ) ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												xform . xform ( rect . position  +  rect . size ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												xform . xform ( rect . position  +  Vector2 ( 0 ,  rect . size . y ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-03-08 21:35:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											Color  c  =  Color ( 1 ,  0.6 ,  0.4 ,  0.7 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-04-15 22:03:12 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if  ( item_locked )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												c  =  Color ( 0.7 ,  0.7 ,  0.7 ,  0.7 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-03-08 21:35:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											for  ( int  i  =  0 ;  i  <  4 ;  i + + )  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-06-24 22:24:07 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												viewport - > draw_line ( endpoints [ i ] ,  endpoints [ ( i  +  1 )  %  4 ] ,  c ,  Math : : round ( 2  *  EDSCALE ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-08 21:35:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											Transform2D  unscaled_transform  =  ( xform  *  ci - > get_transform ( ) . affine_inverse ( )  *  ci - > _edit_get_transform ( ) ) . orthonormalized ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-10 14:39:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											Transform2D  simple_xform  =  viewport - > get_transform ( )  *  unscaled_transform ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											viewport - > draw_set_transform_matrix ( simple_xform ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-08 21:35:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											viewport - > draw_texture ( position_icon ,  - ( position_icon - > get_size ( )  /  2 ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-10 14:39:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											viewport - > draw_set_transform_matrix ( viewport - > get_transform ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-10-25 16:34:32 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( single  & &  ! item_locked  & &  transform_tool )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											// Draw the pivot
 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if  ( ci - > _edit_use_pivot ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-01-18 19:30:45 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												// Draw the node's pivot
 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												Transform2D  unscaled_transform  =  ( xform  *  ci - > get_transform ( ) . affine_inverse ( )  *  ci - > _edit_get_transform ( ) ) . orthonormalized ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-01-18 19:30:45 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												Transform2D  simple_xform  =  viewport - > get_transform ( )  *  unscaled_transform ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-01-27 15:51:45 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-01-18 19:30:45 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												viewport - > draw_set_transform_matrix ( simple_xform ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-01-27 15:51:45 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												viewport - > draw_texture ( pivot_icon ,  - ( pivot_icon - > get_size ( )  /  2 ) . floor ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-01-18 19:30:45 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												viewport - > draw_set_transform_matrix ( viewport - > get_transform ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2017-07-11 00:14:22 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-09-10 14:39:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											// Draw control-related helpers
 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											Control  * control  =  Object : : cast_to < Control > ( ci ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-10-16 20:35:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if  ( control  & &  _is_node_movable ( control ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-03-31 18:53:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												_draw_control_anchors ( control ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-10 14:39:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												_draw_control_helpers ( control ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-07-06 17:42:44 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-09-10 14:39:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											// Draw the resize handles
 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if  ( tool  = =  TOOL_SELECT  & &  ci - > _edit_use_rect ( )  & &  _is_node_movable ( ci ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												Rect2  rect  =  ci - > _edit_get_rect ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-07 13:23:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												const  Vector2  endpoints [ 4 ]  =  { 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-08 21:35:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													xform . xform ( rect . position ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													xform . xform ( rect . position  +  Vector2 ( rect . size . x ,  0 ) ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													xform . xform ( rect . position  +  rect . size ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													xform . xform ( rect . position  +  Vector2 ( 0 ,  rect . size . y ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												} ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												for  ( int  i  =  0 ;  i  <  4 ;  i + + )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													int  prev  =  ( i  +  3 )  %  4 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													int  next  =  ( i  +  1 )  %  4 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													Vector2  ofs  =  ( ( endpoints [ i ]  -  endpoints [ prev ] ) . normalized ( )  +  ( ( endpoints [ i ]  -  endpoints [ next ] ) . normalized ( ) ) ) . normalized ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-12-10 05:13:02 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													ofs  * =  Math_SQRT2  *  ( select_handle - > get_size ( ) . width  /  2 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													select_handle - > draw ( vp_ci ,  ( endpoints [ i ]  +  ofs  -  ( select_handle - > get_size ( )  /  2 ) ) . floor ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													ofs  =  ( endpoints [ i ]  +  endpoints [ next ] )  /  2 ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-12-06 18:16:06 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													ofs  + =  ( endpoints [ next ]  -  endpoints [ i ] ) . orthogonal ( ) . normalized ( )  *  ( select_handle - > get_size ( ) . width  /  2 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													select_handle - > draw ( vp_ci ,  ( ofs  -  ( select_handle - > get_size ( )  /  2 ) ) . floor ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-25 16:34:32 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-10 14:39:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-10-25 16:34:32 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// Remove non-movable nodes.
 
							 
						 
					
						
							
								
									
										
										
										
											2025-02-07 09:30:02 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									for  ( List < CanvasItem  * > : : Element  * E  =  selection . front ( ) ;  E ; )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										List < CanvasItem  * > : : Element  * N  =  E - > next ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if  ( ! _is_node_movable ( E - > get ( ) ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											selection . erase ( E ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-25 16:34:32 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2025-02-07 09:30:02 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										E  =  N ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-25 16:34:32 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2019-11-08 15:48:26 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-10-25 16:34:32 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( ! selection . is_empty ( )  & &  transform_tool  & &  show_transformation_gizmos )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										CanvasItem  * ci  =  selection . front ( ) - > get ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-11-08 15:48:26 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-11-18 17:16:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Transform2D  xform  =  transform  *  ci - > get_screen_transform ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-25 16:34:32 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										bool  is_ctrl  =  Input : : get_singleton ( ) - > is_key_pressed ( Key : : CMD_OR_CTRL ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										bool  is_alt  =  Input : : get_singleton ( ) - > is_key_pressed ( Key : : ALT ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-11-08 15:48:26 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-10-25 16:34:32 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										// Draw the move handles.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if  ( ( tool  = =  TOOL_SELECT  & &  is_alt  & &  ! is_ctrl )  | |  tool  = =  TOOL_MOVE )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											Transform2D  unscaled_transform  =  ( xform  *  ci - > get_transform ( ) . affine_inverse ( )  *  ci - > _edit_get_transform ( ) ) . orthonormalized ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											Transform2D  simple_xform  =  viewport - > get_transform ( )  *  unscaled_transform ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-11-08 15:48:26 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-10-25 16:34:32 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											Size2  move_factor  =  Size2 ( MOVE_HANDLE_DISTANCE ,  MOVE_HANDLE_DISTANCE ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											viewport - > draw_set_transform_matrix ( simple_xform ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-11-08 15:48:26 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-10-25 16:34:32 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											Vector < Point2 >  points  =  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												Vector2 ( move_factor . x  *  EDSCALE ,  5  *  EDSCALE ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												Vector2 ( move_factor . x  *  EDSCALE ,  - 5  *  EDSCALE ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												Vector2 ( ( move_factor . x  +  10 )  *  EDSCALE ,  0 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-11-08 15:48:26 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-10-25 16:34:32 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											viewport - > draw_colored_polygon ( points ,  get_theme_color ( SNAME ( " axis_x_color " ) ,  EditorStringName ( Editor ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											viewport - > draw_line ( Point2 ( ) ,  Point2 ( move_factor . x  *  EDSCALE ,  0 ) ,  get_theme_color ( SNAME ( " axis_x_color " ) ,  EditorStringName ( Editor ) ) ,  Math : : round ( EDSCALE ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-11-08 15:48:26 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-10-25 16:34:32 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											points . clear ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											points . push_back ( Vector2 ( 5  *  EDSCALE ,  move_factor . y  *  EDSCALE ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											points . push_back ( Vector2 ( - 5  *  EDSCALE ,  move_factor . y  *  EDSCALE ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											points . push_back ( Vector2 ( 0 ,  ( move_factor . y  +  10 )  *  EDSCALE ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-10-16 20:35:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-10-25 16:34:32 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											viewport - > draw_colored_polygon ( points ,  get_theme_color ( SNAME ( " axis_y_color " ) ,  EditorStringName ( Editor ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											viewport - > draw_line ( Point2 ( ) ,  Point2 ( 0 ,  move_factor . y  *  EDSCALE ) ,  get_theme_color ( SNAME ( " axis_y_color " ) ,  EditorStringName ( Editor ) ) ,  Math : : round ( EDSCALE ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-10-16 20:35:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-10-25 16:34:32 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											viewport - > draw_set_transform_matrix ( viewport - > get_transform ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-10 14:39:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-10-25 16:34:32 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										// Draw the rescale handles.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if  ( ( tool  = =  TOOL_SELECT  & &  is_alt  & &  is_ctrl )  | |  tool  = =  TOOL_SCALE  | |  drag_type  = =  DRAG_SCALE_X  | |  drag_type  = =  DRAG_SCALE_Y )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											Transform2D  edit_transform ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if  ( ! Math : : is_inf ( temp_pivot . x )  | |  ! Math : : is_inf ( temp_pivot . y ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												edit_transform  =  Transform2D ( ci - > _edit_get_rotation ( ) ,  temp_pivot ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												edit_transform  =  ci - > _edit_get_transform ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											Transform2D  unscaled_transform  =  ( xform  *  ci - > get_transform ( ) . affine_inverse ( )  *  edit_transform ) . orthonormalized ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											Transform2D  simple_xform  =  viewport - > get_transform ( )  *  unscaled_transform ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-10 14:39:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-10-25 16:34:32 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											Size2  scale_factor  =  Size2 ( SCALE_HANDLE_DISTANCE ,  SCALE_HANDLE_DISTANCE ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											bool  uniform  =  Input : : get_singleton ( ) - > is_key_pressed ( Key : : SHIFT ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											Point2  offset  =  ( simple_xform . affine_inverse ( ) . xform ( drag_to )  -  simple_xform . affine_inverse ( ) . xform ( drag_from ) )  *  zoom ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-10 14:39:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-10-25 16:34:32 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if  ( drag_type  = =  DRAG_SCALE_X )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												scale_factor . x  + =  offset . x ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												if  ( uniform )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													scale_factor . y  + =  offset . x ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											}  else  if  ( drag_type  = =  DRAG_SCALE_Y )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												scale_factor . y  + =  offset . y ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												if  ( uniform )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													scale_factor . x  + =  offset . y ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-10-16 20:35:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-10 14:39:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-25 16:34:32 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											viewport - > draw_set_transform_matrix ( simple_xform ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											Rect2  x_handle_rect  =  Rect2 ( scale_factor . x  *  EDSCALE ,  - 5  *  EDSCALE ,  10  *  EDSCALE ,  10  *  EDSCALE ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											viewport - > draw_rect ( x_handle_rect ,  get_theme_color ( SNAME ( " axis_x_color " ) ,  EditorStringName ( Editor ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											viewport - > draw_line ( Point2 ( ) ,  Point2 ( scale_factor . x  *  EDSCALE ,  0 ) ,  get_theme_color ( SNAME ( " axis_x_color " ) ,  EditorStringName ( Editor ) ) ,  Math : : round ( EDSCALE ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											Rect2  y_handle_rect  =  Rect2 ( - 5  *  EDSCALE ,  scale_factor . y  *  EDSCALE ,  10  *  EDSCALE ,  10  *  EDSCALE ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											viewport - > draw_rect ( y_handle_rect ,  get_theme_color ( SNAME ( " axis_y_color " ) ,  EditorStringName ( Editor ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											viewport - > draw_line ( Point2 ( ) ,  Point2 ( 0 ,  scale_factor . y  *  EDSCALE ) ,  get_theme_color ( SNAME ( " axis_y_color " ) ,  EditorStringName ( Editor ) ) ,  Math : : round ( EDSCALE ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											viewport - > draw_set_transform_matrix ( viewport - > get_transform ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( drag_type  = =  DRAG_BOX_SELECTION )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										// Draw the dragging box
 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										Point2  bsfrom  =  transform . xform ( drag_from ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										Point2  bsto  =  transform . xform ( box_selecting_to ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-08-15 22:17:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										viewport - > draw_rect ( 
							 
						 
					
						
							
								
									
										
										
										
											2019-03-29 14:19:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												Rect2 ( bsfrom ,  bsto  -  bsfrom ) , 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-13 02:33:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												get_theme_color ( SNAME ( " box_selection_fill_color " ) ,  EditorStringName ( Editor ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-08-15 22:17:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										viewport - > draw_rect ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												Rect2 ( bsfrom ,  bsto  -  bsfrom ) , 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-13 02:33:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												get_theme_color ( SNAME ( " box_selection_stroke_color " ) ,  EditorStringName ( Editor ) ) , 
							 
						 
					
						
							
								
									
										
										
										
											2019-08-15 22:17:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												false , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												Math : : round ( EDSCALE ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( drag_type  = =  DRAG_ROTATE )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										// Draw the line when rotating a node
 
							 
						 
					
						
							
								
									
										
										
										
											2019-03-29 14:19:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										viewport - > draw_line ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												transform . xform ( drag_rotation_center ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												transform . xform ( drag_to ) , 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-13 02:33:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												get_theme_color ( SNAME ( " accent_color " ) ,  EditorStringName ( Editor ) )  *  Color ( 1 ,  1 ,  1 ,  0.6 ) , 
							 
						 
					
						
							
								
									
										
										
										
											2019-06-24 22:24:07 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												Math : : round ( 2  *  EDSCALE ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-21 01:22:11 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( ! Math : : is_inf ( temp_pivot . x )  | |  ! Math : : is_inf ( temp_pivot . y ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-13 16:56:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										viewport - > draw_texture ( pivot_icon ,  ( temp_pivot  -  view_offset )  *  zoom  -  ( pivot_icon - > get_size ( )  /  2 ) . floor ( ) ,  get_theme_color ( SNAME ( " accent_color " ) ,  EditorStringName ( Editor ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-21 01:22:11 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : _draw_straight_line ( Point2  p_from ,  Point2  p_to ,  Color  p_color )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									// Draw a line going through the whole screen from a vector
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									RID  ci  =  viewport - > get_canvas_item ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Vector < Point2 >  points ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Point2  from  =  transform . xform ( p_from ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Point2  to  =  transform . xform ( p_to ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Size2  viewport_size  =  viewport - > get_size ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( to . x  = =  from . x )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										// Vertical line
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										points . push_back ( Point2 ( to . x ,  0 ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										points . push_back ( Point2 ( to . x ,  viewport_size . y ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}  else  if  ( to . y  = =  from . y )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										// Horizontal line
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										points . push_back ( Point2 ( 0 ,  to . y ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										points . push_back ( Point2 ( viewport_size . x ,  to . y ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-20 23:30:19 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										real_t  y_for_zero_x  =  ( to . y  *  from . x  -  from . y  *  to . x )  /  ( from . x  -  to . x ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										real_t  x_for_zero_y  =  ( to . x  *  from . y  -  from . x  *  to . y )  /  ( from . y  -  to . y ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										real_t  y_for_viewport_x  =  ( ( to . y  -  from . y )  *  ( viewport_size . x  -  from . x ) )  /  ( to . x  -  from . x )  +  from . y ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										real_t  x_for_viewport_y  =  ( ( to . x  -  from . x )  *  ( viewport_size . y  -  from . y ) )  /  ( to . y  -  from . y )  +  from . x ;  // faux
 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										//bool start_set = false;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if  ( y_for_zero_x  > =  0  & &  y_for_zero_x  < =  viewport_size . y )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											points . push_back ( Point2 ( 0 ,  y_for_zero_x ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if  ( x_for_zero_y  > =  0  & &  x_for_zero_y  < =  viewport_size . x )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											points . push_back ( Point2 ( x_for_zero_y ,  0 ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if  ( y_for_viewport_x  > =  0  & &  y_for_viewport_x  < =  viewport_size . y )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											points . push_back ( Point2 ( viewport_size . x ,  y_for_viewport_x ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if  ( x_for_viewport_y  > =  0  & &  x_for_viewport_y  < =  viewport_size . x )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											points . push_back ( Point2 ( x_for_viewport_y ,  viewport_size . y ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( points . size ( )  > =  2 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-27 15:21:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										RenderingServer : : get_singleton ( ) - > canvas_item_add_line ( ci ,  points [ 0 ] ,  points [ 1 ] ,  p_color ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-28 21:51:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : _draw_axis ( )  {  
						 
					
						
							
								
									
										
										
										
											2018-03-02 03:52:13 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( show_origin )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-13 02:33:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										_draw_straight_line ( Point2 ( ) ,  Point2 ( 1 ,  0 ) ,  get_theme_color ( SNAME ( " axis_x_color " ) ,  EditorStringName ( Editor ) )  *  Color ( 1 ,  1 ,  1 ,  0.75 ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										_draw_straight_line ( Point2 ( ) ,  Point2 ( 0 ,  1 ) ,  get_theme_color ( SNAME ( " axis_y_color " ) ,  EditorStringName ( Editor ) )  *  Color ( 1 ,  1 ,  1 ,  0.75 ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-02 03:52:13 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-03-02 03:52:13 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( show_viewport )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										RID  ci  =  viewport - > get_canvas_item ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-10-18 16:43:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Color  area_axis_color  =  EDITOR_GET ( " editors/2d/viewport_border_color " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-10-18 16:43:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Size2  screen_size  =  Size2 ( GLOBAL_GET ( " display/window/size/viewport_width " ) ,  GLOBAL_GET ( " display/window/size/viewport_height " ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-02 03:52:13 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										Vector2  screen_endpoints [ 4 ]  =  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											transform . xform ( Vector2 ( 0 ,  0 ) ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											transform . xform ( Vector2 ( screen_size . width ,  0 ) ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											transform . xform ( Vector2 ( screen_size . width ,  screen_size . height ) ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											transform . xform ( Vector2 ( 0 ,  screen_size . height ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										for  ( int  i  =  0 ;  i  <  4 ;  i + + )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-27 15:21:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											RenderingServer : : get_singleton ( ) - > canvas_item_add_line ( ci ,  screen_endpoints [ i ] ,  screen_endpoints [ ( i  +  1 )  %  4 ] ,  area_axis_color ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-02 03:52:13 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-28 21:51:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-03-10 11:56:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : _draw_invisible_nodes_positions ( Node  * p_node ,  const  Transform2D  & p_parent_xform ,  const  Transform2D  & p_canvas_xform )  {  
						 
					
						
							
								
									
										
										
										
											2023-09-09 17:24:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_NULL ( p_node ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-20 16:28:16 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 10:36:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Node  * scene  =  EditorNode : : get_singleton ( ) - > get_edited_scene ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( p_node  ! =  scene  & &  p_node - > get_owner ( )  ! =  scene  & &  ! scene - > is_editable_instance ( p_node - > get_owner ( ) ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-10 11:56:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									CanvasItem  * ci  =  Object : : cast_to < CanvasItem > ( p_node ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( ci  & &  ! ci - > is_visible_in_tree ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-10 11:56:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-28 21:51:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-03-10 11:56:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Transform2D  parent_xform  =  p_parent_xform ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Transform2D  canvas_xform  =  p_canvas_xform ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( ci  & &  ! ci - > is_set_as_top_level ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										parent_xform  =  parent_xform  *  ci - > get_transform ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-18 17:16:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									}  else  if  ( CanvasLayer  * cl  =  Object : : cast_to < CanvasLayer > ( p_node ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-10 11:56:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										parent_xform  =  Transform2D ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-18 17:16:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										canvas_xform  =  cl - > get_transform ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}  else  if  ( Viewport  * vp  =  Object : : cast_to < Viewport > ( p_node ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-12-02 15:36:17 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( ! vp - > is_visible_subviewport ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-18 17:16:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										parent_xform  =  Transform2D ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										canvas_xform  =  vp - > get_popup_base_transform ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-10 11:56:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-28 21:51:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									for  ( int  i  =  p_node - > get_child_count ( )  -  1 ;  i  > =  0 ;  i - - )  { 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-10 11:56:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										_draw_invisible_nodes_positions ( p_node - > get_child ( i ) ,  parent_xform ,  canvas_xform ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-10-25 12:41:37 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( show_position_gizmos  & &  ci  & &  ! ci - > _edit_use_rect ( )  & &  ( ! editor_selection - > is_selected ( ci )  | |  _is_node_locked ( ci ) ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-10 11:56:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Transform2D  xform  =  transform  *  canvas_xform  *  parent_xform ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-03-12 23:32:25 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										// Draw the node's position
 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-13 02:33:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Ref < Texture2D >  position_icon  =  get_editor_theme_icon ( SNAME ( " EditorPositionUnselected " ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Transform2D  unscaled_transform  =  ( xform  *  ci - > get_transform ( ) . affine_inverse ( )  *  ci - > _edit_get_transform ( ) ) . orthonormalized ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-10 14:39:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Transform2D  simple_xform  =  viewport - > get_transform ( )  *  unscaled_transform ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										viewport - > draw_set_transform_matrix ( simple_xform ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-10 11:56:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										viewport - > draw_texture ( position_icon ,  - position_icon - > get_size ( )  /  2 ,  Color ( 1.0 ,  1.0 ,  1.0 ,  0.5 ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-10 14:39:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										viewport - > draw_set_transform_matrix ( viewport - > get_transform ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-28 21:51:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-12 23:32:25 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : _draw_hover ( )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									List < Rect2 >  previous_rects ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-03 15:43:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Vector2  icon_size  =  Vector2 ( 1 ,  1 )  *  get_theme_constant ( SNAME ( " class_icon_size " ) ,  EditorStringName ( Editor ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-12 23:32:25 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									for  ( int  i  =  0 ;  i  <  hovering_results . size ( ) ;  i + + )  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-06-11 15:43:37 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Ref < Texture2D >  node_icon  =  hovering_results [ i ] . icon ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-06-12 11:01:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										String  node_name  =  hovering_results [ i ] . name ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-12 23:32:25 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-14 15:57:29 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Ref < Font >  font  =  get_theme_font ( SceneStringName ( font ) ,  SNAME ( " Label " ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										int  font_size  =  get_theme_font_size ( SceneStringName ( font_size ) ,  SNAME ( " Label " ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-05-09 12:47:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Size2  node_name_size  =  font - > get_string_size ( node_name ,  HORIZONTAL_ALIGNMENT_LEFT ,  - 1 ,  font_size ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-03 15:43:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Size2  item_size  =  Size2 ( icon_size . x  +  4  +  node_name_size . x ,  MAX ( icon_size . y ,  node_name_size . y  -  3 ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-12 23:32:25 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-10-03 15:43:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Point2  pos  =  transform . xform ( hovering_results [ i ] . position )  -  Point2 ( 0 ,  item_size . y )  +  ( Point2 ( icon_size . x ,  - icon_size . y )  /  4 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-12 21:38:39 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										// Rectify the position to avoid overlapping items
 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-24 15:46:25 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										for  ( const  Rect2  & E  :  previous_rects )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-15 23:45:57 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if  ( E . intersects ( Rect2 ( pos ,  item_size ) ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												pos . y  =  E . get_position ( ) . y  -  item_size . y ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-12 23:32:25 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										previous_rects . push_back ( Rect2 ( pos ,  item_size ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-06-12 11:01:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										// Draw icon
 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-03 15:43:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										viewport - > draw_texture_rect ( node_icon ,  Rect2 ( pos ,  icon_size ) ,  false ,  Color ( 1.0 ,  1.0 ,  1.0 ,  0.5 ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-06-12 11:01:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										// Draw name
 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-03 15:43:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										viewport - > draw_string ( font ,  pos  +  Point2 ( icon_size . x  +  4 ,  item_size . y  -  3 ) ,  node_name ,  HORIZONTAL_ALIGNMENT_LEFT ,  - 1 ,  font_size ,  Color ( 1.0 ,  1.0 ,  1.0 ,  0.5 ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-10 11:56:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-02-25 13:36:42 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : _draw_message ( )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( drag_type  ! =  DRAG_NONE  & &  ! drag_selection . is_empty ( )  & &  drag_selection . front ( ) - > get ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										Transform2D  current_transform  =  drag_selection . front ( ) - > get ( ) - > get_global_transform ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-05 13:06:12 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-02-25 13:36:42 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										double  snap  =  EDITOR_GET ( " interface/inspector/default_float_step " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										int  snap_step_decimals  =  Math : : range_step_decimals ( snap ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-05 13:06:12 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# define FORMAT(value) (TS->format_number(String::num(value, snap_step_decimals))) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-02-25 13:36:42 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										switch  ( drag_type )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											case  DRAG_MOVE : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											case  DRAG_MOVE_X : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											case  DRAG_MOVE_Y :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												Vector2  delta  =  current_transform . get_origin ( )  -  original_transform . get_origin ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												if  ( drag_type  = =  DRAG_MOVE )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													message  =  TTR ( " Moving: " )  +  "  ( "  +  FORMAT ( delta . x )  +  " ,  "  +  FORMAT ( delta . y )  +  " ) px " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												}  else  if  ( drag_type  = =  DRAG_MOVE_X )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													message  =  TTR ( " Moving: " )  +  "   "  +  FORMAT ( delta . x )  +  "  px " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												}  else  if  ( drag_type  = =  DRAG_MOVE_Y )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													message  =  TTR ( " Moving: " )  +  "   "  +  FORMAT ( delta . y )  +  "  px " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											}  break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											case  DRAG_ROTATE :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												real_t  delta  =  Math : : rad_to_deg ( current_transform . get_rotation ( )  -  original_transform . get_rotation ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												message  =  TTR ( " Rotating: " )  +  "   "  +  FORMAT ( delta )  +  String : : utf8 ( "  ° " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											}  break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											case  DRAG_SCALE_X : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											case  DRAG_SCALE_Y : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											case  DRAG_SCALE_BOTH :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												Vector2  original_scale  =  ( Math : : is_zero_approx ( original_transform . get_scale ( ) . x )  | |  Math : : is_zero_approx ( original_transform . get_scale ( ) . y ) )  ?  Vector2 ( CMP_EPSILON ,  CMP_EPSILON )  :  original_transform . get_scale ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												Vector2  delta  =  current_transform . get_scale ( )  /  original_scale ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												if  ( drag_type  = =  DRAG_SCALE_BOTH )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
													message  =  TTR ( " Scaling: " )  +  String : : utf8 ( "  ×  " )  +  FORMAT ( delta . x )  +  " ,  "  +  FORMAT ( delta . y )  +  " ) " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												}  else  if  ( drag_type  = =  DRAG_SCALE_X )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
													message  =  TTR ( " Scaling: " )  +  String : : utf8 ( "  ×  " )  +  FORMAT ( delta . x ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												}  else  if  ( drag_type  = =  DRAG_SCALE_Y )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
													message  =  TTR ( " Scaling: " )  +  String : : utf8 ( "  ×  " )  +  FORMAT ( delta . y ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											}  break ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-05 13:06:12 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-02-25 13:36:42 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											default : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-05 13:06:12 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# undef FORMAT 
  
						 
					
						
							
								
									
										
										
										
											2024-02-25 13:36:42 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-05 13:06:12 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-02-25 13:36:42 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( message . is_empty ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-05 13:06:12 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-14 15:57:29 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Ref < Font >  font  =  get_theme_font ( SceneStringName ( font ) ,  SNAME ( " Label " ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									int  font_size  =  get_theme_font_size ( SceneStringName ( font_size ) ,  SNAME ( " Label " ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-21 08:24:08 +04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Point2  msgpos  =  Point2 ( RULER_WIDTH  +  10  *  EDSCALE ,  viewport - > get_size ( ) . y  -  14  *  EDSCALE ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-25 13:36:42 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									viewport - > draw_string ( font ,  msgpos  +  Point2 ( 1 ,  1 ) ,  message ,  HORIZONTAL_ALIGNMENT_LEFT ,  - 1 ,  font_size ,  Color ( 0 ,  0 ,  0 ,  0.8 ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									viewport - > draw_string ( font ,  msgpos  +  Point2 ( - 1 ,  - 1 ) ,  message ,  HORIZONTAL_ALIGNMENT_LEFT ,  - 1 ,  font_size ,  Color ( 0 ,  0 ,  0 ,  0.8 ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									viewport - > draw_string ( font ,  msgpos ,  message ,  HORIZONTAL_ALIGNMENT_LEFT ,  - 1 ,  font_size ,  Color ( 1 ,  1 ,  1 ,  1 ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-05 13:06:12 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-03-08 21:12:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : _draw_locks_and_groups ( Node  * p_node ,  const  Transform2D  & p_parent_xform ,  const  Transform2D  & p_canvas_xform )  {  
						 
					
						
							
								
									
										
										
										
											2023-09-09 17:24:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_NULL ( p_node ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-20 16:28:16 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 10:36:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Node  * scene  =  EditorNode : : get_singleton ( ) - > get_edited_scene ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( p_node  ! =  scene  & &  p_node - > get_owner ( )  ! =  scene  & &  ! scene - > is_editable_instance ( p_node - > get_owner ( ) ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-08 21:12:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									CanvasItem  * ci  =  Object : : cast_to < CanvasItem > ( p_node ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( ci  & &  ! ci - > is_visible_in_tree ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-08 21:12:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-28 21:51:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-03-08 21:12:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Transform2D  parent_xform  =  p_parent_xform ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Transform2D  canvas_xform  =  p_canvas_xform ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( ci  & &  ! ci - > is_set_as_top_level ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										parent_xform  =  parent_xform  *  ci - > get_transform ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-12-02 15:36:17 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									}  else  if  ( CanvasLayer  * cl  =  Object : : cast_to < CanvasLayer > ( p_node ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-08 21:12:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										parent_xform  =  Transform2D ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-12-02 15:36:17 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										canvas_xform  =  cl - > get_transform ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}  else  if  ( Viewport  * vp  =  Object : : cast_to < Viewport > ( p_node ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if  ( ! vp - > is_visible_subviewport ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										parent_xform  =  Transform2D ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										canvas_xform  =  vp - > get_popup_base_transform ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-08 21:12:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-28 21:51:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									for  ( int  i  =  p_node - > get_child_count ( )  -  1 ;  i  > =  0 ;  i - - )  { 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-08 21:12:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										_draw_locks_and_groups ( p_node - > get_child ( i ) ,  parent_xform ,  canvas_xform ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-28 21:51:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									RID  viewport_ci  =  viewport - > get_canvas_item ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( ci )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-20 23:30:19 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										real_t  offset  =  0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-28 21:51:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-13 02:33:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Ref < Texture2D >  lock  =  get_editor_theme_icon ( SNAME ( " LockViewport " ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-25 12:41:37 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( show_lock_gizmos  & &  p_node - > has_meta ( " _edit_lock_ " ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											lock - > draw ( viewport_ci ,  ( transform  *  canvas_xform  *  parent_xform ) . xform ( Point2 ( 0 ,  0 ) )  +  Point2 ( offset ,  0 ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-08 21:12:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											offset  + =  lock - > get_size ( ) . x ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-28 21:51:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-13 02:33:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Ref < Texture2D >  group  =  get_editor_theme_icon ( SNAME ( " GroupViewport " ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-25 12:41:37 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( show_group_gizmos  & &  ci - > has_meta ( " _edit_group_ " ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											group - > draw ( viewport_ci ,  ( transform  *  canvas_xform  *  parent_xform ) . xform ( Point2 ( 0 ,  0 ) )  +  Point2 ( offset ,  0 ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-08 21:12:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											//offset += group->get_size().x;
 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-28 21:51:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : _draw_viewport ( )  {  
						 
					
						
							
								
									
										
										
										
											2018-03-15 15:12:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// Update the transform
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									transform  =  Transform2D ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									transform . scale_basis ( Size2 ( zoom ,  zoom ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-24 16:59:24 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									transform . columns [ 2 ]  =  - view_offset  *  zoom ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 10:36:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									EditorNode : : get_singleton ( ) - > get_scene_root ( ) - > set_global_canvas_transform ( transform ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-31 00:03:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-08-28 21:51:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									_draw_grid ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-08-30 22:49:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									_draw_ruler_tool ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-28 21:51:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									_draw_axis ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 10:36:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( EditorNode : : get_singleton ( ) - > get_edited_scene ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										_draw_locks_and_groups ( EditorNode : : get_singleton ( ) - > get_edited_scene ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										_draw_invisible_nodes_positions ( EditorNode : : get_singleton ( ) - > get_edited_scene ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-10 11:56:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-27 18:47:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									_draw_selection ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-28 21:51:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									RID  ci  =  viewport - > get_canvas_item ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-27 15:21:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									RenderingServer : : get_singleton ( ) - > canvas_item_add_set_transform ( ci ,  Transform2D ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-28 21:51:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 10:36:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									EditorPluginList  * over_plugin_list  =  EditorNode : : get_singleton ( ) - > get_editor_plugins_over ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-12-15 12:04:21 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( ! over_plugin_list - > is_empty ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-18 20:00:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										over_plugin_list - > forward_canvas_draw_over_viewport ( viewport ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-28 21:51:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 10:36:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									EditorPluginList  * force_over_plugin_list  =  EditorNode : : get_singleton ( ) - > get_editor_plugins_force_over ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-12-15 12:04:21 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( ! force_over_plugin_list - > is_empty ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-18 20:00:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										force_over_plugin_list - > forward_canvas_force_draw_over_viewport ( viewport ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-29 20:32:09 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( show_rulers )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										_draw_rulers ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( show_guides )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										_draw_guides ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-05 10:18:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									_draw_smart_snapping ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									_draw_focus ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-12 23:32:25 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									_draw_hover ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-25 13:36:42 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									_draw_message ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-28 21:51:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-10-18 14:06:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : update_viewport ( )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									_update_scrollbars ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-13 23:21:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									viewport - > queue_redraw ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-10-18 14:06:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-08-21 15:34:06 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : set_current_tool ( Tool  p_tool )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									_button_tool_select ( p_tool ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-15 21:44:22 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : _update_editor_settings ( )  {  
						 
					
						
							
								
									
										
										
										
											2024-10-09 15:21:47 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									button_center_view - > set_button_icon ( get_editor_theme_icon ( SNAME ( " CenterView " ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									select_button - > set_button_icon ( get_editor_theme_icon ( SNAME ( " ToolSelect " ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-13 02:33:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									select_sb - > set_texture ( get_editor_theme_icon ( SNAME ( " EditorRect2D " ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-09 15:21:47 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									list_select_button - > set_button_icon ( get_editor_theme_icon ( SNAME ( " ListSelect " ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									move_button - > set_button_icon ( get_editor_theme_icon ( SNAME ( " ToolMove " ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									scale_button - > set_button_icon ( get_editor_theme_icon ( SNAME ( " ToolScale " ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									rotate_button - > set_button_icon ( get_editor_theme_icon ( SNAME ( " ToolRotate " ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									smart_snap_button - > set_button_icon ( get_editor_theme_icon ( SNAME ( " Snap " ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									grid_snap_button - > set_button_icon ( get_editor_theme_icon ( SNAME ( " SnapGrid " ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									snap_config_menu - > set_button_icon ( get_editor_theme_icon ( SNAME ( " GuiTabMenuHl " ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									skeleton_menu - > set_button_icon ( get_editor_theme_icon ( SNAME ( " Bone " ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									pan_button - > set_button_icon ( get_editor_theme_icon ( SNAME ( " ToolPan " ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ruler_button - > set_button_icon ( get_editor_theme_icon ( SNAME ( " Ruler " ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									pivot_button - > set_button_icon ( get_editor_theme_icon ( SNAME ( " EditPivot " ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-13 02:33:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									select_handle  =  get_editor_theme_icon ( SNAME ( " EditorHandle " ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									anchor_handle  =  get_editor_theme_icon ( SNAME ( " EditorControlAnchor " ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-09 15:21:47 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									lock_button - > set_button_icon ( get_editor_theme_icon ( SNAME ( " Lock " ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									unlock_button - > set_button_icon ( get_editor_theme_icon ( SNAME ( " Unlock " ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									group_button - > set_button_icon ( get_editor_theme_icon ( SNAME ( " Group " ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ungroup_button - > set_button_icon ( get_editor_theme_icon ( SNAME ( " Ungroup " ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									key_loc_button - > set_button_icon ( get_editor_theme_icon ( SNAME ( " KeyPosition " ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									key_rot_button - > set_button_icon ( get_editor_theme_icon ( SNAME ( " KeyRotation " ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									key_scale_button - > set_button_icon ( get_editor_theme_icon ( SNAME ( " KeyScale " ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									key_insert_button - > set_button_icon ( get_editor_theme_icon ( SNAME ( " Key " ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									key_auto_insert_button - > set_button_icon ( get_editor_theme_icon ( SNAME ( " AutoKey " ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-15 21:44:22 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// Use a different color for the active autokey icon to make them easier
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									// to distinguish from the other key icons at the top. On a light theme,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									// the icon will be dark, so we need to lighten it before blending it
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									// with the red color.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-17 15:03:55 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									const  Color  key_auto_color  =  EditorThemeManager : : is_dark_theme ( )  ?  Color ( 1 ,  1 ,  1 )  :  Color ( 4.25 ,  4.25 ,  4.25 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-15 21:44:22 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									key_auto_insert_button - > add_theme_color_override ( " icon_pressed_color " ,  key_auto_color . lerp ( Color ( 1 ,  0 ,  0 ) ,  0.55 ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-09 15:21:47 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									animation_menu - > set_button_icon ( get_editor_theme_icon ( SNAME ( " GuiTabMenuHl " ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-15 21:44:22 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-14 15:50:53 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									context_toolbar_panel - > add_theme_style_override ( SceneStringName ( panel ) ,  get_theme_stylebox ( SNAME ( " ContextualToolbar " ) ,  EditorStringName ( EditorStyles ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-15 21:44:22 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-10-18 16:43:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									panner - > setup ( ( ViewPanner : : ControlScheme ) EDITOR_GET ( " editors/panning/2d_editor_panning_scheme " ) . operator  int ( ) ,  ED_GET_SHORTCUT ( " canvas_item_editor/pan_view " ) ,  bool ( EDITOR_GET ( " editors/panning/simple_panning " ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-19 17:50:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									panner - > set_scroll_speed ( EDITOR_GET ( " editors/panning/2d_editor_pan_speed " ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-03 10:39:22 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									panner - > setup_warped_panning ( get_viewport ( ) ,  EDITOR_GET ( " editors/panning/warped_mouse_panning " ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-15 21:44:22 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-03-07 16:02:33 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : _project_settings_changed ( )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									EditorNode : : get_singleton ( ) - > get_scene_root ( ) - > set_snap_controls_to_pixels ( GLOBAL_GET ( " gui/common/snap_controls_to_pixels " ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : _notification ( int  p_what )  {  
						 
					
						
							
								
									
										
										
										
											2022-02-15 21:44:22 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									switch  ( p_what )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 15:46:56 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										case  NOTIFICATION_READY :  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-05 21:42:12 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											_update_lock_and_group_button ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-08-09 15:29:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											SceneTreeDock : : get_singleton ( ) - > get_tree_editor ( ) - > connect ( " node_changed " ,  callable_mp ( this ,  & CanvasItemEditor : : _update_lock_and_group_button ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-07 16:02:33 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											ProjectSettings : : get_singleton ( ) - > connect ( " settings_changed " ,  callable_mp ( this ,  & CanvasItemEditor : : _project_settings_changed ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 15:46:56 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}  break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-02-02 19:14:48 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										case  NOTIFICATION_PROCESS :  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-15 21:44:22 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											// Update the viewport if the canvas_item changes
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											List < CanvasItem  * >  selection  =  _get_edited_canvas_items ( true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											for  ( CanvasItem  * ci  :  selection )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												CanvasItemEditorSelectedItem  * se  =  editor_selection - > get_node_editor_data < CanvasItemEditorSelectedItem > ( ci ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-15 21:44:22 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												Rect2  rect ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												if  ( ci - > _edit_use_rect ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													rect  =  ci - > _edit_get_rect ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-15 21:44:22 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													rect  =  Rect2 ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-18 11:18:14 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												Transform2D  xform  =  ci - > get_global_transform ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-15 21:44:22 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												if  ( rect  ! =  se - > prev_rect  | |  xform  ! =  se - > prev_xform )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-13 23:21:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													viewport - > queue_redraw ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-15 21:44:22 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													se - > prev_rect  =  rect ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													se - > prev_xform  =  xform ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												Control  * control  =  Object : : cast_to < Control > ( ci ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-15 21:44:22 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												if  ( control )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													real_t  anchors [ 4 ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													Vector2  pivot ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													pivot  =  control - > get_pivot_offset ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													anchors [ SIDE_LEFT ]  =  control - > get_anchor ( SIDE_LEFT ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													anchors [ SIDE_RIGHT ]  =  control - > get_anchor ( SIDE_RIGHT ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													anchors [ SIDE_TOP ]  =  control - > get_anchor ( SIDE_TOP ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													anchors [ SIDE_BOTTOM ]  =  control - > get_anchor ( SIDE_BOTTOM ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													if  ( pivot  ! =  se - > prev_pivot  | |  anchors [ SIDE_LEFT ]  ! =  se - > prev_anchors [ SIDE_LEFT ]  | |  anchors [ SIDE_RIGHT ]  ! =  se - > prev_anchors [ SIDE_RIGHT ]  | |  anchors [ SIDE_TOP ]  ! =  se - > prev_anchors [ SIDE_TOP ]  | |  anchors [ SIDE_BOTTOM ]  ! =  se - > prev_anchors [ SIDE_BOTTOM ] )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														se - > prev_pivot  =  pivot ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														se - > prev_anchors [ SIDE_LEFT ]  =  anchors [ SIDE_LEFT ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														se - > prev_anchors [ SIDE_RIGHT ]  =  anchors [ SIDE_RIGHT ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														se - > prev_anchors [ SIDE_TOP ]  =  anchors [ SIDE_TOP ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														se - > prev_anchors [ SIDE_BOTTOM ]  =  anchors [ SIDE_BOTTOM ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-13 23:21:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														viewport - > queue_redraw ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-15 21:44:22 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-12 18:44:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-21 01:22:11 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											// Activate / Deactivate the pivot tool.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											pivot_button - > set_disabled ( selection . is_empty ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-15 21:44:22 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											// Update the viewport if bones changes
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											for  ( KeyValue < BoneKey ,  BoneList >  & E  :  bone_list )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												Object  * b  =  ObjectDB : : get_instance ( E . key . from ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												if  ( ! b )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-13 23:21:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													viewport - > queue_redraw ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-15 21:44:22 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													break ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-01 22:33:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-15 21:44:22 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												Node2D  * b2  =  Object : : cast_to < Node2D > ( b ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												if  ( ! b2  | |  ! b2 - > is_inside_tree ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2018-05-05 15:45:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-15 21:44:22 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												Transform2D  global_xform  =  b2 - > get_global_transform ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-15 21:44:22 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												if  ( global_xform  ! =  E . value . xform )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													E . value . xform  =  global_xform ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-13 23:21:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													viewport - > queue_redraw ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-15 21:44:22 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												Bone2D  * bone  =  Object : : cast_to < Bone2D > ( b ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												if  ( bone  & &  bone - > get_length ( )  ! =  E . value . length )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													E . value . length  =  bone - > get_length ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-13 23:21:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													viewport - > queue_redraw ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-15 21:44:22 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2014-07-07 17:44:21 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-15 21:44:22 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}  break ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-07-07 17:44:21 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-15 21:44:22 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										case  NOTIFICATION_ENTER_TREE :  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-13 02:33:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											select_sb - > set_texture ( get_editor_theme_icon ( SNAME ( " EditorRect2D " ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-19 19:14:09 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											select_sb - > set_texture_margin_all ( 4 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											select_sb - > set_content_margin_all ( 4 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-07-07 17:44:21 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-13 14:58:16 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											AnimationPlayerEditor : : get_singleton ( ) - > get_track_editor ( ) - > connect ( " keying_changed " ,  callable_mp ( this ,  & CanvasItemEditor : : _keying_changed ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-24 12:46:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											AnimationPlayerEditor : : get_singleton ( ) - > connect ( " animation_selected " ,  callable_mp ( this ,  & CanvasItemEditor : : _keying_changed ) . unbind ( 1 ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-15 21:44:22 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											_keying_changed ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											_update_editor_settings ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-06 17:51:14 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											connect ( " item_lock_status_changed " ,  callable_mp ( this ,  & CanvasItemEditor : : _update_lock_and_group_button ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											connect ( " item_group_status_changed " ,  callable_mp ( this ,  & CanvasItemEditor : : _update_lock_and_group_button ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-15 21:44:22 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}  break ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-05-04 16:46:32 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-15 21:44:22 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										case  EditorSettings : : NOTIFICATION_EDITOR_SETTINGS_CHANGED :  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-03 10:39:22 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if  ( EditorThemeManager : : is_generated_theme_outdated ( )  | | 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													EditorSettings : : get_singleton ( ) - > check_changed_settings_in_group ( " editors/panning " ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												_update_editor_settings ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-23 00:14:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-15 21:44:22 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}  break ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-05-04 16:46:32 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-09-04 19:12:30 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										case  NOTIFICATION_APPLICATION_FOCUS_OUT : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case  NOTIFICATION_WM_WINDOW_FOCUS_OUT :  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-08 19:34:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if  ( drag_type  ! =  DRAG_NONE )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												_reset_drag ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												viewport - > queue_redraw ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}  break ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-06 22:55:01 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-03-31 18:53:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : _selection_changed ( )  {  
						 
					
						
							
								
									
										
										
										
											2024-03-04 15:00:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									_update_lock_and_group_button ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-11-19 16:02:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( ! selected_from_canvas )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-14 14:51:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										_reset_drag ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-11-19 16:02:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									selected_from_canvas  =  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-21 01:22:11 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( temp_pivot  ! =  Vector2 ( INFINITY ,  INFINITY ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										temp_pivot  =  Vector2 ( INFINITY ,  INFINITY ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										viewport - > queue_redraw ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2019-03-31 18:53:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : edit ( CanvasItem  * p_canvas_item )  {  
						 
					
						
							
								
									
										
										
										
											2023-01-22 23:37:56 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( ! p_canvas_item )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-10-16 20:35:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Array  selection  =  editor_selection - > get_selected_nodes ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-25 08:37:41 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( selection . size ( )  ! =  1  | |  Object : : cast_to < Node > ( selection [ 0 ] )  ! =  p_canvas_item )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-14 14:51:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										_reset_drag ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-10-16 20:35:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : _update_scrollbars ( )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									updating_scroll  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-01-13 22:49:17 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// Move the zoom buttons.
 
							 
						 
					
						
							
								
									
										
										
										
											2019-11-18 10:49:37 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Point2  controls_vb_begin  =  Point2 ( 5 ,  5 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									controls_vb_begin  + =  ( show_rulers )  ?  Point2 ( RULER_WIDTH ,  RULER_WIDTH )  :  Point2 ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									controls_vb - > set_begin ( controls_vb_begin ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-29 21:50:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Size2  hmin  =  h_scroll - > get_minimum_size ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Size2  vmin  =  v_scroll - > get_minimum_size ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-01-13 22:49:17 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// Get the visible frame.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-18 16:43:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Size2  screen_rect  =  Size2 ( GLOBAL_GET ( " display/window/size/viewport_width " ) ,  GLOBAL_GET ( " display/window/size/viewport_height " ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Rect2  local_rect  =  Rect2 ( Point2 ( ) ,  viewport - > get_size ( )  -  Size2 ( vmin . width ,  hmin . height ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-01-13 22:49:17 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// Calculate scrollable area.
 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Rect2  canvas_item_rect  =  Rect2 ( Point2 ( ) ,  screen_rect ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 10:36:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( EditorNode : : get_singleton ( ) - > is_inside_tree ( )  & &  EditorNode : : get_singleton ( ) - > get_edited_scene ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										Rect2  content_rect  =  _get_encompassing_rect ( EditorNode : : get_singleton ( ) - > get_edited_scene ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										canvas_item_rect . expand_to ( content_rect . position ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										canvas_item_rect . expand_to ( content_rect . position  +  content_rect . size ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									canvas_item_rect . size  + =  screen_rect  *  2 ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-06-04 00:25:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									canvas_item_rect . position  - =  screen_rect ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-04 19:25:11 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// Updates the scrollbars.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									const  Size2  size  =  viewport - > get_size ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									const  Point2  begin  =  canvas_item_rect . position ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									const  Point2  end  =  canvas_item_rect . position  +  canvas_item_rect . size  -  local_rect . size  /  zoom ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( canvas_item_rect . size . height  < =  ( local_rect . size . y  /  zoom ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										v_scroll - > hide ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-15 15:12:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										v_scroll - > show ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										v_scroll - > set_min ( MIN ( view_offset . y ,  begin . y ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										v_scroll - > set_max ( MAX ( view_offset . y ,  end . y )  +  screen_rect . y ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										v_scroll - > set_page ( screen_rect . y ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( canvas_item_rect . size . width  < =  ( local_rect . size . x  /  zoom ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										h_scroll - > hide ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										h_scroll - > show ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-15 15:12:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										h_scroll - > set_min ( MIN ( view_offset . x ,  begin . x ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										h_scroll - > set_max ( MAX ( view_offset . x ,  end . x )  +  screen_rect . x ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										h_scroll - > set_page ( screen_rect . x ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-01-13 22:49:17 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// Move and resize the scrollbars, avoiding overlap.
 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-03 14:22:16 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( is_layout_rtl ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										v_scroll - > set_begin ( Point2 ( 0 ,  ( show_rulers )  ?  RULER_WIDTH  :  0 ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										v_scroll - > set_end ( Point2 ( vmin . width ,  size . height  -  ( h_scroll - > is_visible ( )  ?  hmin . height  :  0 ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										v_scroll - > set_begin ( Point2 ( size . width  -  vmin . width ,  ( show_rulers )  ?  RULER_WIDTH  :  0 ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										v_scroll - > set_end ( Point2 ( size . width ,  size . height  -  ( h_scroll - > is_visible ( )  ?  hmin . height  :  0 ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-13 22:49:17 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									h_scroll - > set_begin ( Point2 ( ( show_rulers )  ?  RULER_WIDTH  :  0 ,  size . height  -  hmin . height ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									h_scroll - > set_end ( Point2 ( size . width  -  ( v_scroll - > is_visible ( )  ?  vmin . width  :  0 ) ,  size . height ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									// Calculate scrollable area.
 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-15 15:12:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									v_scroll - > set_value ( view_offset . y ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									h_scroll - > set_value ( view_offset . x ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-03-15 15:12:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									previous_update_view_offset  =  view_offset ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									updating_scroll  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-06-20 23:30:19 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : _update_scroll ( real_t )  {  
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( updating_scroll )  { 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-03-15 15:12:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									view_offset . x  =  h_scroll - > get_value ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									view_offset . y  =  v_scroll - > get_value ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-13 23:21:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									viewport - > queue_redraw ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-06-20 23:30:19 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : _zoom_on_position ( real_t  p_zoom ,  Point2  p_position )  {  
						 
					
						
							
								
									
										
										
										
											2023-09-17 18:33:02 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									p_zoom  =  CLAMP ( p_zoom ,  zoom_widget - > get_min_zoom ( ) ,  zoom_widget - > get_max_zoom ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-15 14:13:07 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( p_zoom  = =  zoom )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-19 18:29:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-01 11:30:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-06-20 23:30:19 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									real_t  prev_zoom  =  zoom ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-01 11:30:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									zoom  =  p_zoom ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-18 02:05:23 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									view_offset  + =  p_position  /  prev_zoom  -  p_position  /  zoom ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									// We want to align in-scene pixels to screen pixels, this prevents blurry rendering
 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-17 18:33:02 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// of small details (texts, lines).
 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-18 02:05:23 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// This correction adds a jitter movement when zooming, so we correct only when the
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									// zoom factor is an integer. (in the other cases, all pixels won't be aligned anyway)
 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-20 23:30:19 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									const  real_t  closest_zoom_factor  =  Math : : round ( zoom ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-18 02:05:23 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( Math : : is_zero_approx ( zoom  -  closest_zoom_factor ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-17 18:33:02 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										// Make sure scene pixel at view_offset is aligned on a screen pixel.
 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-18 02:05:23 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Vector2  view_offset_int  =  view_offset . floor ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										Vector2  view_offset_frac  =  view_offset  -  view_offset_int ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										view_offset  =  view_offset_int  +  ( view_offset_frac  *  closest_zoom_factor ) . round ( )  /  closest_zoom_factor ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-19 18:29:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-05-07 15:41:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									zoom_widget - > set_zoom ( zoom ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-10-18 14:06:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									update_viewport ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-19 18:29:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-06-20 23:30:19 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : _update_zoom ( real_t  p_zoom )  {  
						 
					
						
							
								
									
										
										
										
											2021-05-07 15:41:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									_zoom_on_position ( p_zoom ,  viewport_scrollable - > get_size ( )  /  2.0 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-19 18:29:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-15 16:48:55 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : _shortcut_zoom_set ( real_t  p_zoom )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									_zoom_on_position ( p_zoom  *  MAX ( 1 ,  EDSCALE ) ,  viewport - > get_local_mouse_position ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-10-10 19:41:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : _button_toggle_smart_snap ( bool  p_status )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									smart_snap_active  =  p_status ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-13 23:21:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									viewport - > queue_redraw ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-10 19:41:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : _button_toggle_grid_snap ( bool  p_status )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									grid_snap_active  =  p_status ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-13 23:21:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									viewport - > queue_redraw ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2020-05-14 14:29:06 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : _button_tool_select ( int  p_index )  {  
						 
					
						
							
								
									
										
										
										
											2020-06-19 20:49:04 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Button  * tb [ TOOL_MAX ]  =  {  select_button ,  list_select_button ,  move_button ,  scale_button ,  rotate_button ,  pivot_button ,  pan_button ,  ruler_button  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									for  ( int  i  =  0 ;  i  <  TOOL_MAX ;  i + + )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										tb [ i ] - > set_pressed ( i  = =  p_index ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									tool  =  ( Tool ) p_index ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-26 21:35:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-21 01:22:11 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( p_index  = =  TOOL_EDIT_PIVOT  & &  Input : : get_singleton ( ) - > is_key_pressed ( Key : : SHIFT ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										// Special action that places temporary rotation pivot in the middle of the selection.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										List < CanvasItem  * >  selection  =  _get_edited_canvas_items ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if  ( ! selection . is_empty ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											Vector2  center ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											for  ( const  CanvasItem  * ci  :  selection )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-18 17:16:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												center  + =  ci - > get_viewport ( ) - > get_popup_base_transform ( ) . xform ( ci - > _edit_get_position ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-21 01:22:11 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											temp_pivot  =  center  /  selection . size ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-13 23:21:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									viewport - > queue_redraw ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-26 21:35:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									_update_cursor ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-17 22:52:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-04-15 00:49:03 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : _insert_animation_keys ( bool  p_location ,  bool  p_rotation ,  bool  p_scale ,  bool  p_on_existing )  {  
						 
					
						
							
								
									
										
										
										
											2022-05-13 15:04:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									const  HashMap < Node  * ,  Object  * >  & selection  =  editor_selection - > get_selection ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-15 00:49:03 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-12 16:02:09 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									AnimationTrackEditor  * te  =  AnimationPlayerEditor : : get_singleton ( ) - > get_track_editor ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-25 14:15:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_COND_MSG ( te - > get_current_animation ( ) . is_null ( ) ,  " Cannot insert animation key. No animation selected. " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-24 12:46:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-12 16:02:09 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									te - > make_insert_queue ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-09 14:13:42 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									for  ( const  KeyValue < Node  * ,  Object  * >  & E  :  selection )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										CanvasItem  * ci  =  Object : : cast_to < CanvasItem > ( E . key ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if  ( ! ci  | |  ! ci - > is_visible_in_tree ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-15 00:49:03 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											continue ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-15 00:49:03 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( Object : : cast_to < Node2D > ( ci ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											Node2D  * n2d  =  Object : : cast_to < Node2D > ( ci ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-15 00:49:03 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if  ( key_pos  & &  p_location )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-06 17:47:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												te - > insert_node_value_key ( n2d ,  " position " ,  p_on_existing ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if  ( key_rot  & &  p_rotation )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-06 17:47:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												te - > insert_node_value_key ( n2d ,  " rotation " ,  p_on_existing ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if  ( key_scale  & &  p_scale )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-06 17:47:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												te - > insert_node_value_key ( n2d ,  " scale " ,  p_on_existing ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-15 00:49:03 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if  ( n2d - > has_meta ( " _edit_bone_ " )  & &  n2d - > get_parent_item ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												//look for an IK chain
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												List < Node2D  * >  ik_chain ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												Node2D  * n  =  Object : : cast_to < Node2D > ( n2d - > get_parent_item ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												bool  has_chain  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												while  ( n )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													ik_chain . push_back ( n ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													if  ( n - > has_meta ( " _edit_ik_ " ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														has_chain  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													if  ( ! n - > get_parent_item ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-15 00:49:03 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														break ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													} 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-15 00:49:03 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													n  =  Object : : cast_to < Node2D > ( n - > get_parent_item ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												if  ( has_chain  & &  ik_chain . size ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-15 23:45:57 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													for  ( Node2D  * & F  :  ik_chain )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														if  ( key_pos )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-06 17:47:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
															te - > insert_node_value_key ( F ,  " position " ,  p_on_existing ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														if  ( key_rot )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-06 17:47:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
															te - > insert_node_value_key ( F ,  " rotation " ,  p_on_existing ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														if  ( key_scale )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-06 17:47:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
															te - > insert_node_value_key ( F ,  " scale " ,  p_on_existing ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														} 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-15 00:49:03 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}  else  if  ( Object : : cast_to < Control > ( ci ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											Control  * ctrl  =  Object : : cast_to < Control > ( ci ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-15 00:49:03 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if  ( key_pos )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-06 17:47:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												te - > insert_node_value_key ( ctrl ,  " position " ,  p_on_existing ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if  ( key_rot )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-06 17:47:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												te - > insert_node_value_key ( ctrl ,  " rotation " ,  p_on_existing ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if  ( key_scale )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-06 17:47:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												te - > insert_node_value_key ( ctrl ,  " size " ,  p_on_existing ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-15 00:49:03 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-12 16:02:09 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									te - > commit_insert_queue ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-15 00:49:03 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-11-23 12:55:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : _prepare_view_menu ( )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									PopupMenu  * popup  =  view_menu - > get_popup ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Node  * root  =  EditorNode : : get_singleton ( ) - > get_edited_scene ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									bool  has_guides  =  root  & &  ( root - > has_meta ( " _edit_horizontal_guides_ " )  | |  root - > has_meta ( " _edit_vertical_guides_ " ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									popup - > set_item_disabled ( popup - > get_item_index ( CLEAR_GUIDES ) ,  ! has_guides ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : _popup_callback ( int  p_op )  {  
						 
					
						
							
								
									
										
										
										
											2022-12-23 23:53:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									EditorUndoRedoManager  * undo_redo  =  EditorUndoRedoManager : : get_singleton ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									last_option  =  MenuOption ( p_op ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									switch  ( p_op )  { 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-02 03:52:13 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										case  SHOW_ORIGIN :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											show_origin  =  ! show_origin ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											int  idx  =  view_menu - > get_popup ( ) - > get_item_index ( SHOW_ORIGIN ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											view_menu - > get_popup ( ) - > set_item_checked ( idx ,  show_origin ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-13 23:21:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											viewport - > queue_redraw ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-02 03:52:13 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}  break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case  SHOW_VIEWPORT :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											show_viewport  =  ! show_viewport ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											int  idx  =  view_menu - > get_popup ( ) - > get_item_index ( SHOW_VIEWPORT ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											view_menu - > get_popup ( ) - > set_item_checked ( idx ,  show_viewport ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-13 23:21:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											viewport - > queue_redraw ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-02 03:52:13 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}  break ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-25 12:41:37 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										case  SHOW_POSITION_GIZMOS :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											show_position_gizmos  =  ! show_position_gizmos ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											int  idx  =  gizmos_menu - > get_item_index ( SHOW_POSITION_GIZMOS ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											gizmos_menu - > set_item_checked ( idx ,  show_position_gizmos ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											viewport - > queue_redraw ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}  break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case  SHOW_LOCK_GIZMOS :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											show_lock_gizmos  =  ! show_lock_gizmos ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											int  idx  =  gizmos_menu - > get_item_index ( SHOW_LOCK_GIZMOS ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											gizmos_menu - > set_item_checked ( idx ,  show_lock_gizmos ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											viewport - > queue_redraw ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}  break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case  SHOW_GROUP_GIZMOS :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											show_group_gizmos  =  ! show_group_gizmos ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											int  idx  =  gizmos_menu - > get_item_index ( SHOW_GROUP_GIZMOS ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											gizmos_menu - > set_item_checked ( idx ,  show_group_gizmos ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-13 23:21:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											viewport - > queue_redraw ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-20 02:41:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}  break ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-11-10 10:07:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										case  SHOW_TRANSFORMATION_GIZMOS :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											show_transformation_gizmos  =  ! show_transformation_gizmos ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-25 12:41:37 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											int  idx  =  gizmos_menu - > get_item_index ( SHOW_TRANSFORMATION_GIZMOS ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											gizmos_menu - > set_item_checked ( idx ,  show_transformation_gizmos ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-13 23:21:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											viewport - > queue_redraw ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-11-10 10:07:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}  break ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-17 22:52:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										case  SNAP_USE_NODE_PARENT :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											snap_node_parent  =  ! snap_node_parent ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											int  idx  =  smartsnap_config_popup - > get_item_index ( SNAP_USE_NODE_PARENT ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											smartsnap_config_popup - > set_item_checked ( idx ,  snap_node_parent ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}  break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case  SNAP_USE_NODE_ANCHORS :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											snap_node_anchors  =  ! snap_node_anchors ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											int  idx  =  smartsnap_config_popup - > get_item_index ( SNAP_USE_NODE_ANCHORS ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											smartsnap_config_popup - > set_item_checked ( idx ,  snap_node_anchors ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}  break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case  SNAP_USE_NODE_SIDES :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											snap_node_sides  =  ! snap_node_sides ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											int  idx  =  smartsnap_config_popup - > get_item_index ( SNAP_USE_NODE_SIDES ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											smartsnap_config_popup - > set_item_checked ( idx ,  snap_node_sides ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}  break ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										case  SNAP_USE_NODE_CENTER :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											snap_node_center  =  ! snap_node_center ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											int  idx  =  smartsnap_config_popup - > get_item_index ( SNAP_USE_NODE_CENTER ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											smartsnap_config_popup - > set_item_checked ( idx ,  snap_node_center ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}  break ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-17 22:52:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										case  SNAP_USE_OTHER_NODES :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											snap_other_nodes  =  ! snap_other_nodes ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											int  idx  =  smartsnap_config_popup - > get_item_index ( SNAP_USE_OTHER_NODES ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											smartsnap_config_popup - > set_item_checked ( idx ,  snap_other_nodes ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}  break ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-18 23:55:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										case  SNAP_USE_GUIDES :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											snap_guides  =  ! snap_guides ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											int  idx  =  smartsnap_config_popup - > get_item_index ( SNAP_USE_GUIDES ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											smartsnap_config_popup - > set_item_checked ( idx ,  snap_guides ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}  break ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-02-15 18:00:55 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										case  SNAP_USE_ROTATION :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											snap_rotation  =  ! snap_rotation ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-17 22:52:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											int  idx  =  snap_config_menu - > get_popup ( ) - > get_item_index ( SNAP_USE_ROTATION ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											snap_config_menu - > get_popup ( ) - > set_item_checked ( idx ,  snap_rotation ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-02-15 18:00:55 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}  break ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-30 15:18:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										case  SNAP_USE_SCALE :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											snap_scale  =  ! snap_scale ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											int  idx  =  snap_config_menu - > get_popup ( ) - > get_item_index ( SNAP_USE_SCALE ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											snap_config_menu - > get_popup ( ) - > set_item_checked ( idx ,  snap_scale ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}  break ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-02-20 22:21:59 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										case  SNAP_RELATIVE :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											snap_relative  =  ! snap_relative ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-17 22:52:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											int  idx  =  snap_config_menu - > get_popup ( ) - > get_item_index ( SNAP_RELATIVE ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											snap_config_menu - > get_popup ( ) - > set_item_checked ( idx ,  snap_relative ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-13 23:21:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											viewport - > queue_redraw ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-02-15 18:00:55 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}  break ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case  SNAP_USE_PIXEL :  { 
							 
						 
					
						
							
								
									
										
										
										
											2015-02-15 18:00:55 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											snap_pixel  =  ! snap_pixel ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-17 22:52:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											int  idx  =  snap_config_menu - > get_popup ( ) - > get_item_index ( SNAP_USE_PIXEL ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											snap_config_menu - > get_popup ( ) - > set_item_checked ( idx ,  snap_pixel ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}  break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case  SNAP_CONFIGURE :  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-02 17:13:46 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											static_cast < SnapDialog  * > ( snap_dialog ) - > set_fields ( grid_offset ,  grid_step ,  primary_grid_step ,  snap_rotation_offset ,  snap_rotation_step ,  snap_scale_step ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											snap_dialog - > popup_centered ( Size2 ( 320 ,  160 )  *  EDSCALE ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}  break ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-09-07 11:10:00 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										case  SKELETON_SHOW_BONES :  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-12-01 06:40:29 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											List < Node  * >  selection  =  editor_selection - > get_top_selected_node_list ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-15 23:45:57 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											for  ( Node  * E  :  selection )  { 
							 
						 
					
						
							
								
									
										
											 
										
											
												New and improved IK system for Skeleton2D
This PR and commit adds a new IK system for 2D with the Skeleton2D node
that adds several new IK solvers, a way to control bones in a Skeleton2D
node similar to that in Skeleton3D. It also adds additional changes
and functionality.
This work was sponsored by GSoC 2020 and TwistedTwigleg.
Full list of changes:
* Adds a SkeletonModifier2D resource
  * This resource is the base where all IK code is written and executed
  * Has a function for clamping angles, since it is so commonly used
  * Modifiers are unique when duplicated so it works with instancing
* Adds a SkeletonModifierStack2D resource
  * This resource manages a series of SkeletonModification2Ds
  * This is what the Skeleton2D directly interfaces with to make IK possible
* Adds SkeletonModifier2D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
  * Each modification is in its own file
  * There is also a SkeletonModifier2D resource that acts as a stack for using multiple stacks together
* Adds a PhysicalBone2D node
  * Works similar to the PhysicalBone3D node, but uses a RigidBody2D node
* Changes to Skeleton2D listed below:
  * Skeleton2D now holds a single SkeletonModificationStack2D for IK
  * Skeleton2D now has a local_pose_override, which overrides the Bone2D position similar to how the overrides work in Skeleton3D
* Changes to Bone2D listed below:
  * The default_length property has been changed to length. Length is the length of the bone to its child bone node
  * New bone_angle property, which is the angle the bone has to its first child bone node
  * Bone2D caches its transform when not modified by IK for IK interpolation purposes
  * Bone2D draws its own editor gizmo, though this is stated to change in the future
* Changes to CanvasItemEditor listed below:
  * Bone2D gizmo drawing code removed
  * The 2D IK code is removed. Now Bone2D is the only bone system for 2D
* Transform2D now has a looking_at function for rotating to face a position
* Two new node notifications: NOTIFICATION_EDITOR_PRE_SAVE and NOTIFICATION_EDITOR_POST_SAVE
  * These notifications only are called in the editor right before and after saving a scene
  * Needed for not saving the IK position when executing IK in the editor
* Documentation for all the changes listed above.
											 
										 
										
											2020-08-03 14:02:24 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												// Add children nodes so they are processed
 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-15 23:45:57 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												for  ( int  child  =  0 ;  child  <  E - > get_child_count ( ) ;  child + + )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													selection . push_back ( E - > get_child ( child ) ) ; 
							 
						 
					
						
							
								
									
										
											 
										
											
												New and improved IK system for Skeleton2D
This PR and commit adds a new IK system for 2D with the Skeleton2D node
that adds several new IK solvers, a way to control bones in a Skeleton2D
node similar to that in Skeleton3D. It also adds additional changes
and functionality.
This work was sponsored by GSoC 2020 and TwistedTwigleg.
Full list of changes:
* Adds a SkeletonModifier2D resource
  * This resource is the base where all IK code is written and executed
  * Has a function for clamping angles, since it is so commonly used
  * Modifiers are unique when duplicated so it works with instancing
* Adds a SkeletonModifierStack2D resource
  * This resource manages a series of SkeletonModification2Ds
  * This is what the Skeleton2D directly interfaces with to make IK possible
* Adds SkeletonModifier2D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
  * Each modification is in its own file
  * There is also a SkeletonModifier2D resource that acts as a stack for using multiple stacks together
* Adds a PhysicalBone2D node
  * Works similar to the PhysicalBone3D node, but uses a RigidBody2D node
* Changes to Skeleton2D listed below:
  * Skeleton2D now holds a single SkeletonModificationStack2D for IK
  * Skeleton2D now has a local_pose_override, which overrides the Bone2D position similar to how the overrides work in Skeleton3D
* Changes to Bone2D listed below:
  * The default_length property has been changed to length. Length is the length of the bone to its child bone node
  * New bone_angle property, which is the angle the bone has to its first child bone node
  * Bone2D caches its transform when not modified by IK for IK interpolation purposes
  * Bone2D draws its own editor gizmo, though this is stated to change in the future
* Changes to CanvasItemEditor listed below:
  * Bone2D gizmo drawing code removed
  * The 2D IK code is removed. Now Bone2D is the only bone system for 2D
* Transform2D now has a looking_at function for rotating to face a position
* Two new node notifications: NOTIFICATION_EDITOR_PRE_SAVE and NOTIFICATION_EDITOR_POST_SAVE
  * These notifications only are called in the editor right before and after saving a scene
  * Needed for not saving the IK position when executing IK in the editor
* Documentation for all the changes listed above.
											 
										 
										
											2020-08-03 14:02:24 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-07-15 23:45:57 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												Bone2D  * bone_2d  =  Object : : cast_to < Bone2D > ( E ) ; 
							 
						 
					
						
							
								
									
										
											 
										
											
												New and improved IK system for Skeleton2D
This PR and commit adds a new IK system for 2D with the Skeleton2D node
that adds several new IK solvers, a way to control bones in a Skeleton2D
node similar to that in Skeleton3D. It also adds additional changes
and functionality.
This work was sponsored by GSoC 2020 and TwistedTwigleg.
Full list of changes:
* Adds a SkeletonModifier2D resource
  * This resource is the base where all IK code is written and executed
  * Has a function for clamping angles, since it is so commonly used
  * Modifiers are unique when duplicated so it works with instancing
* Adds a SkeletonModifierStack2D resource
  * This resource manages a series of SkeletonModification2Ds
  * This is what the Skeleton2D directly interfaces with to make IK possible
* Adds SkeletonModifier2D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
  * Each modification is in its own file
  * There is also a SkeletonModifier2D resource that acts as a stack for using multiple stacks together
* Adds a PhysicalBone2D node
  * Works similar to the PhysicalBone3D node, but uses a RigidBody2D node
* Changes to Skeleton2D listed below:
  * Skeleton2D now holds a single SkeletonModificationStack2D for IK
  * Skeleton2D now has a local_pose_override, which overrides the Bone2D position similar to how the overrides work in Skeleton3D
* Changes to Bone2D listed below:
  * The default_length property has been changed to length. Length is the length of the bone to its child bone node
  * New bone_angle property, which is the angle the bone has to its first child bone node
  * Bone2D caches its transform when not modified by IK for IK interpolation purposes
  * Bone2D draws its own editor gizmo, though this is stated to change in the future
* Changes to CanvasItemEditor listed below:
  * Bone2D gizmo drawing code removed
  * The 2D IK code is removed. Now Bone2D is the only bone system for 2D
* Transform2D now has a looking_at function for rotating to face a position
* Two new node notifications: NOTIFICATION_EDITOR_PRE_SAVE and NOTIFICATION_EDITOR_POST_SAVE
  * These notifications only are called in the editor right before and after saving a scene
  * Needed for not saving the IK position when executing IK in the editor
* Documentation for all the changes listed above.
											 
										 
										
											2020-08-03 14:02:24 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												if  ( ! bone_2d  | |  ! bone_2d - > is_inside_tree ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												bone_2d - > _editor_set_show_bone_gizmo ( ! bone_2d - > _editor_get_show_bone_gizmo ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2016-09-07 11:10:00 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}  break ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-19 18:29:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										case  SHOW_HELPERS :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											show_helpers  =  ! show_helpers ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											int  idx  =  view_menu - > get_popup ( ) - > get_item_index ( SHOW_HELPERS ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											view_menu - > get_popup ( ) - > set_item_checked ( idx ,  show_helpers ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-13 23:21:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											viewport - > queue_redraw ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}  break ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-29 21:50:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										case  SHOW_RULERS :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											show_rulers  =  ! show_rulers ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											int  idx  =  view_menu - > get_popup ( ) - > get_item_index ( SHOW_RULERS ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											view_menu - > get_popup ( ) - > set_item_checked ( idx ,  show_rulers ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-12 15:04:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											update_viewport ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-29 21:50:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}  break ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-18 23:55:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										case  SHOW_GUIDES :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											show_guides  =  ! show_guides ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											int  idx  =  view_menu - > get_popup ( ) - > get_item_index ( SHOW_GUIDES ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											view_menu - > get_popup ( ) - > set_item_checked ( idx ,  show_guides ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-13 23:21:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											viewport - > queue_redraw ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-18 23:55:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}  break ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case  LOCK_SELECTED :  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-26 12:23:50 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											undo_redo - > create_action ( TTR ( " Lock Selected " ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-12-01 06:40:29 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											List < Node  * >  selection  =  editor_selection - > get_top_selected_node_list ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-15 23:45:57 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											for  ( Node  * E  :  selection )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												CanvasItem  * ci  =  Object : : cast_to < CanvasItem > ( E ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												if  ( ! ci  | |  ! ci - > is_inside_tree ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													continue ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2016-01-24 16:41:50 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												undo_redo - > add_do_method ( ci ,  " set_meta " ,  " _edit_lock_ " ,  true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												undo_redo - > add_undo_method ( ci ,  " remove_meta " ,  " _edit_lock_ " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-26 12:23:50 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												undo_redo - > add_do_method ( this ,  " emit_signal " ,  " item_lock_status_changed " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												undo_redo - > add_undo_method ( this ,  " emit_signal " ,  " item_lock_status_changed " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-13 23:21:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											undo_redo - > add_do_method ( viewport ,  " queue_redraw " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											undo_redo - > add_undo_method ( viewport ,  " queue_redraw " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-26 12:23:50 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											undo_redo - > commit_action ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}  break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case  UNLOCK_SELECTED :  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-26 12:23:50 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											undo_redo - > create_action ( TTR ( " Unlock Selected " ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-12-01 06:40:29 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											List < Node  * >  selection  =  editor_selection - > get_top_selected_node_list ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-15 23:45:57 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											for  ( Node  * E  :  selection )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												CanvasItem  * ci  =  Object : : cast_to < CanvasItem > ( E ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												if  ( ! ci  | |  ! ci - > is_inside_tree ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													continue ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2016-01-24 16:41:50 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												undo_redo - > add_do_method ( ci ,  " remove_meta " ,  " _edit_lock_ " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												undo_redo - > add_undo_method ( ci ,  " set_meta " ,  " _edit_lock_ " ,  true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-26 12:23:50 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												undo_redo - > add_do_method ( this ,  " emit_signal " ,  " item_lock_status_changed " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												undo_redo - > add_undo_method ( this ,  " emit_signal " ,  " item_lock_status_changed " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-13 23:21:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											undo_redo - > add_do_method ( viewport ,  " queue_redraw " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											undo_redo - > add_undo_method ( viewport ,  " queue_redraw " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-26 12:23:50 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											undo_redo - > commit_action ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}  break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case  GROUP_SELECTED :  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-26 12:23:50 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											undo_redo - > create_action ( TTR ( " Group Selected " ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-12-01 06:40:29 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											List < Node  * >  selection  =  editor_selection - > get_top_selected_node_list ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-15 23:45:57 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											for  ( Node  * E  :  selection )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												CanvasItem  * ci  =  Object : : cast_to < CanvasItem > ( E ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												if  ( ! ci  | |  ! ci - > is_inside_tree ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													continue ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2016-01-24 16:41:50 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												undo_redo - > add_do_method ( ci ,  " set_meta " ,  " _edit_group_ " ,  true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												undo_redo - > add_undo_method ( ci ,  " remove_meta " ,  " _edit_group_ " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-26 12:23:50 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												undo_redo - > add_do_method ( this ,  " emit_signal " ,  " item_group_status_changed " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												undo_redo - > add_undo_method ( this ,  " emit_signal " ,  " item_group_status_changed " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-13 23:21:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											undo_redo - > add_do_method ( viewport ,  " queue_redraw " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											undo_redo - > add_undo_method ( viewport ,  " queue_redraw " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-26 12:23:50 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											undo_redo - > commit_action ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}  break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case  UNGROUP_SELECTED :  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-26 12:23:50 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											undo_redo - > create_action ( TTR ( " Ungroup Selected " ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-12-01 06:40:29 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											List < Node  * >  selection  =  editor_selection - > get_top_selected_node_list ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-15 23:45:57 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											for  ( Node  * E  :  selection )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												CanvasItem  * ci  =  Object : : cast_to < CanvasItem > ( E ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												if  ( ! ci  | |  ! ci - > is_inside_tree ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													continue ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2016-01-24 16:41:50 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												undo_redo - > add_do_method ( ci ,  " remove_meta " ,  " _edit_group_ " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												undo_redo - > add_undo_method ( ci ,  " set_meta " ,  " _edit_group_ " ,  true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-26 12:23:50 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												undo_redo - > add_do_method ( this ,  " emit_signal " ,  " item_group_status_changed " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												undo_redo - > add_undo_method ( this ,  " emit_signal " ,  " item_group_status_changed " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-13 23:21:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											undo_redo - > add_do_method ( viewport ,  " queue_redraw " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											undo_redo - > add_undo_method ( viewport ,  " queue_redraw " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-26 12:23:50 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											undo_redo - > commit_action ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}  break ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-08-24 01:00:39 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case  ANIM_INSERT_KEY : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case  ANIM_INSERT_KEY_EXISTING :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											bool  existing  =  p_op  = =  ANIM_INSERT_KEY_EXISTING ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-04-15 00:49:03 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											_insert_animation_keys ( true ,  true ,  true ,  existing ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}  break ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-07-06 11:49:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										case  ANIM_INSERT_POS :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											key_pos  =  key_loc_button - > is_pressed ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}  break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case  ANIM_INSERT_ROT :  { 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-02 17:31:43 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											key_rot  =  key_rot_button - > is_pressed ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-07-06 11:49:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}  break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case  ANIM_INSERT_SCALE :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											key_scale  =  key_scale_button - > is_pressed ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}  break ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case  ANIM_COPY_POSE :  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-01-14 18:03:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											pose_clipboard . clear ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-05-13 15:04:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											const  HashMap < Node  * ,  Object  * >  & selection  =  editor_selection - > get_selection ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-08-09 14:13:42 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											for  ( const  KeyValue < Node  * ,  Object  * >  & E  :  selection )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												CanvasItem  * ci  =  Object : : cast_to < CanvasItem > ( E . key ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												if  ( ! ci  | |  ! ci - > is_visible_in_tree ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													continue ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												if  ( Object : : cast_to < Node2D > ( ci ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													Node2D  * n2d  =  Object : : cast_to < Node2D > ( ci ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													PoseClipboard  pc ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-01-04 01:16:14 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													pc . pos  =  n2d - > get_position ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													pc . rot  =  n2d - > get_rotation ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													pc . scale  =  n2d - > get_scale ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-07 17:17:31 +07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													pc . id  =  n2d - > get_instance_id ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													pose_clipboard . push_back ( pc ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}  break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case  ANIM_PASTE_POSE :  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if  ( ! pose_clipboard . size ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												break ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-05-03 22:25:37 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											undo_redo - > create_action ( TTR ( " Paste Pose " ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-24 15:46:25 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											for  ( const  PoseClipboard  & E  :  pose_clipboard )  { 
							 
						 
					
						
							
								
									
										
										
										
											2025-03-27 14:42:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												Node2D  * n2d  =  ObjectDB : : get_instance < Node2D > ( E . id ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												if  ( ! n2d )  { 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													continue ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-15 23:45:57 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												undo_redo - > add_do_method ( n2d ,  " set_position " ,  E . pos ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												undo_redo - > add_do_method ( n2d ,  " set_rotation " ,  E . rot ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												undo_redo - > add_do_method ( n2d ,  " set_scale " ,  E . scale ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-03-29 11:29:38 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												undo_redo - > add_undo_method ( n2d ,  " set_position " ,  n2d - > get_position ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-06-24 10:39:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												undo_redo - > add_undo_method ( n2d ,  " set_rotation " ,  n2d - > get_rotation ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												undo_redo - > add_undo_method ( n2d ,  " set_scale " ,  n2d - > get_scale ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											undo_redo - > commit_action ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}  break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case  ANIM_CLEAR_POSE :  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-05-13 15:04:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											HashMap < Node  * ,  Object  * >  & selection  =  editor_selection - > get_selection ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-08-09 14:13:42 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											for  ( const  KeyValue < Node  * ,  Object  * >  & E  :  selection )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												CanvasItem  * ci  =  Object : : cast_to < CanvasItem > ( E . key ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												if  ( ! ci  | |  ! ci - > is_visible_in_tree ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													continue ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												if  ( Object : : cast_to < Node2D > ( ci ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													Node2D  * n2d  =  Object : : cast_to < Node2D > ( ci ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													if  ( key_pos )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-01-04 01:16:14 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														n2d - > set_position ( Vector2 ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													if  ( key_rot )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-01-04 01:16:14 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														n2d - > set_rotation ( 0 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													if  ( key_scale )  { 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														n2d - > set_scale ( Vector2 ( 1 ,  1 ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													} 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												}  else  if  ( Object : : cast_to < Control > ( ci ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													Control  * ctrl  =  Object : : cast_to < Control > ( ci ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													if  ( key_pos )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-03-29 11:29:38 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														ctrl - > set_position ( Point2 ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													} 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-08-24 22:58:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}  break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case  CLEAR_GUIDES :  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-12-05 15:20:50 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											Node  * const  root  =  EditorNode : : get_singleton ( ) - > get_edited_scene ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if  ( root  & &  ( root - > has_meta ( " _edit_horizontal_guides_ " )  | |  root - > has_meta ( " _edit_vertical_guides_ " ) ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-08-24 22:58:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												undo_redo - > create_action ( TTR ( " Clear Guides " ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-12-05 15:20:50 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												if  ( root - > has_meta ( " _edit_horizontal_guides_ " ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													Array  hguides  =  root - > get_meta ( " _edit_horizontal_guides_ " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-08-24 22:58:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-12-05 02:46:22 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													undo_redo - > add_do_method ( root ,  " remove_meta " ,  " _edit_horizontal_guides_ " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-12-05 15:20:50 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													undo_redo - > add_undo_method ( root ,  " set_meta " ,  " _edit_horizontal_guides_ " ,  hguides ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-08-24 22:58:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2019-12-05 15:20:50 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												if  ( root - > has_meta ( " _edit_vertical_guides_ " ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													Array  vguides  =  root - > get_meta ( " _edit_vertical_guides_ " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-08-24 22:58:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-12-05 02:46:22 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													undo_redo - > add_do_method ( root ,  " remove_meta " ,  " _edit_vertical_guides_ " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-12-05 15:20:50 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													undo_redo - > add_undo_method ( root ,  " set_meta " ,  " _edit_vertical_guides_ " ,  vguides ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-08-24 22:58:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-14 13:31:20 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												undo_redo - > add_do_method ( viewport ,  " queue_redraw " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-13 23:21:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												undo_redo - > add_undo_method ( viewport ,  " queue_redraw " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-08-24 22:58:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												undo_redo - > commit_action ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}  break ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-05-04 01:36:59 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										case  VIEW_CENTER_TO_SELECTION : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case  VIEW_FRAME_TO_SELECTION :  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-28 14:37:52 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											_focus_selection ( p_op ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-05-04 01:36:59 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-04-05 10:24:54 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}  break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case  PREVIEW_CANVAS_SCALE :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											bool  preview  =  view_menu - > get_popup ( ) - > is_item_checked ( view_menu - > get_popup ( ) - > get_item_index ( PREVIEW_CANVAS_SCALE ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											preview  =  ! preview ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-27 15:21:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											RS : : get_singleton ( ) - > canvas_set_disable_scale ( ! preview ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-05 10:24:54 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											view_menu - > get_popup ( ) - > set_item_checked ( view_menu - > get_popup ( ) - > get_item_index ( PREVIEW_CANVAS_SCALE ) ,  preview ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-05-04 01:36:59 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}  break ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-07-06 11:49:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										case  SKELETON_MAKE_BONES :  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-05-13 15:04:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											HashMap < Node  * ,  Object  * >  & selection  =  editor_selection - > get_selection ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-25 14:57:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											Node  * editor_root  =  get_tree ( ) - > get_edited_scene_root ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if  ( ! editor_root  | |  selection . is_empty ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2014-07-06 11:49:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
											 
										
											
												New and improved IK system for Skeleton2D
This PR and commit adds a new IK system for 2D with the Skeleton2D node
that adds several new IK solvers, a way to control bones in a Skeleton2D
node similar to that in Skeleton3D. It also adds additional changes
and functionality.
This work was sponsored by GSoC 2020 and TwistedTwigleg.
Full list of changes:
* Adds a SkeletonModifier2D resource
  * This resource is the base where all IK code is written and executed
  * Has a function for clamping angles, since it is so commonly used
  * Modifiers are unique when duplicated so it works with instancing
* Adds a SkeletonModifierStack2D resource
  * This resource manages a series of SkeletonModification2Ds
  * This is what the Skeleton2D directly interfaces with to make IK possible
* Adds SkeletonModifier2D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
  * Each modification is in its own file
  * There is also a SkeletonModifier2D resource that acts as a stack for using multiple stacks together
* Adds a PhysicalBone2D node
  * Works similar to the PhysicalBone3D node, but uses a RigidBody2D node
* Changes to Skeleton2D listed below:
  * Skeleton2D now holds a single SkeletonModificationStack2D for IK
  * Skeleton2D now has a local_pose_override, which overrides the Bone2D position similar to how the overrides work in Skeleton3D
* Changes to Bone2D listed below:
  * The default_length property has been changed to length. Length is the length of the bone to its child bone node
  * New bone_angle property, which is the angle the bone has to its first child bone node
  * Bone2D caches its transform when not modified by IK for IK interpolation purposes
  * Bone2D draws its own editor gizmo, though this is stated to change in the future
* Changes to CanvasItemEditor listed below:
  * Bone2D gizmo drawing code removed
  * The 2D IK code is removed. Now Bone2D is the only bone system for 2D
* Transform2D now has a looking_at function for rotating to face a position
* Two new node notifications: NOTIFICATION_EDITOR_PRE_SAVE and NOTIFICATION_EDITOR_POST_SAVE
  * These notifications only are called in the editor right before and after saving a scene
  * Needed for not saving the IK position when executing IK in the editor
* Documentation for all the changes listed above.
											 
										 
										
											2020-08-03 14:02:24 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											undo_redo - > create_action ( TTR ( " Create Custom Bone2D(s) from Node(s) " ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-09 14:13:42 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											for  ( const  KeyValue < Node  * ,  Object  * >  & E  :  selection )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												Node2D  * n2d  =  Object : : cast_to < Node2D > ( E . key ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-17 15:53:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												if  ( ! n2d )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2014-07-06 11:49:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
											 
										
											
												New and improved IK system for Skeleton2D
This PR and commit adds a new IK system for 2D with the Skeleton2D node
that adds several new IK solvers, a way to control bones in a Skeleton2D
node similar to that in Skeleton3D. It also adds additional changes
and functionality.
This work was sponsored by GSoC 2020 and TwistedTwigleg.
Full list of changes:
* Adds a SkeletonModifier2D resource
  * This resource is the base where all IK code is written and executed
  * Has a function for clamping angles, since it is so commonly used
  * Modifiers are unique when duplicated so it works with instancing
* Adds a SkeletonModifierStack2D resource
  * This resource manages a series of SkeletonModification2Ds
  * This is what the Skeleton2D directly interfaces with to make IK possible
* Adds SkeletonModifier2D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
  * Each modification is in its own file
  * There is also a SkeletonModifier2D resource that acts as a stack for using multiple stacks together
* Adds a PhysicalBone2D node
  * Works similar to the PhysicalBone3D node, but uses a RigidBody2D node
* Changes to Skeleton2D listed below:
  * Skeleton2D now holds a single SkeletonModificationStack2D for IK
  * Skeleton2D now has a local_pose_override, which overrides the Bone2D position similar to how the overrides work in Skeleton3D
* Changes to Bone2D listed below:
  * The default_length property has been changed to length. Length is the length of the bone to its child bone node
  * New bone_angle property, which is the angle the bone has to its first child bone node
  * Bone2D caches its transform when not modified by IK for IK interpolation purposes
  * Bone2D draws its own editor gizmo, though this is stated to change in the future
* Changes to CanvasItemEditor listed below:
  * Bone2D gizmo drawing code removed
  * The 2D IK code is removed. Now Bone2D is the only bone system for 2D
* Transform2D now has a looking_at function for rotating to face a position
* Two new node notifications: NOTIFICATION_EDITOR_PRE_SAVE and NOTIFICATION_EDITOR_POST_SAVE
  * These notifications only are called in the editor right before and after saving a scene
  * Needed for not saving the IK position when executing IK in the editor
* Documentation for all the changes listed above.
											 
										 
										
											2020-08-03 14:02:24 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												Bone2D  * new_bone  =  memnew ( Bone2D ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												String  new_bone_name  =  n2d - > get_name ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												new_bone_name  + =  " Bone2D " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												new_bone - > set_name ( new_bone_name ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												new_bone - > set_transform ( n2d - > get_transform ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-07-06 11:49:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
											 
										
											
												New and improved IK system for Skeleton2D
This PR and commit adds a new IK system for 2D with the Skeleton2D node
that adds several new IK solvers, a way to control bones in a Skeleton2D
node similar to that in Skeleton3D. It also adds additional changes
and functionality.
This work was sponsored by GSoC 2020 and TwistedTwigleg.
Full list of changes:
* Adds a SkeletonModifier2D resource
  * This resource is the base where all IK code is written and executed
  * Has a function for clamping angles, since it is so commonly used
  * Modifiers are unique when duplicated so it works with instancing
* Adds a SkeletonModifierStack2D resource
  * This resource manages a series of SkeletonModification2Ds
  * This is what the Skeleton2D directly interfaces with to make IK possible
* Adds SkeletonModifier2D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
  * Each modification is in its own file
  * There is also a SkeletonModifier2D resource that acts as a stack for using multiple stacks together
* Adds a PhysicalBone2D node
  * Works similar to the PhysicalBone3D node, but uses a RigidBody2D node
* Changes to Skeleton2D listed below:
  * Skeleton2D now holds a single SkeletonModificationStack2D for IK
  * Skeleton2D now has a local_pose_override, which overrides the Bone2D position similar to how the overrides work in Skeleton3D
* Changes to Bone2D listed below:
  * The default_length property has been changed to length. Length is the length of the bone to its child bone node
  * New bone_angle property, which is the angle the bone has to its first child bone node
  * Bone2D caches its transform when not modified by IK for IK interpolation purposes
  * Bone2D draws its own editor gizmo, though this is stated to change in the future
* Changes to CanvasItemEditor listed below:
  * Bone2D gizmo drawing code removed
  * The 2D IK code is removed. Now Bone2D is the only bone system for 2D
* Transform2D now has a looking_at function for rotating to face a position
* Two new node notifications: NOTIFICATION_EDITOR_PRE_SAVE and NOTIFICATION_EDITOR_POST_SAVE
  * These notifications only are called in the editor right before and after saving a scene
  * Needed for not saving the IK position when executing IK in the editor
* Documentation for all the changes listed above.
											 
										 
										
											2020-08-03 14:02:24 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												Node  * n2d_parent  =  n2d - > get_parent ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												if  ( ! n2d_parent )  { 
							 
						 
					
						
							
								
									
										
										
										
											2014-07-06 11:49:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													continue ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2014-07-06 11:49:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
											 
										
											
												New and improved IK system for Skeleton2D
This PR and commit adds a new IK system for 2D with the Skeleton2D node
that adds several new IK solvers, a way to control bones in a Skeleton2D
node similar to that in Skeleton3D. It also adds additional changes
and functionality.
This work was sponsored by GSoC 2020 and TwistedTwigleg.
Full list of changes:
* Adds a SkeletonModifier2D resource
  * This resource is the base where all IK code is written and executed
  * Has a function for clamping angles, since it is so commonly used
  * Modifiers are unique when duplicated so it works with instancing
* Adds a SkeletonModifierStack2D resource
  * This resource manages a series of SkeletonModification2Ds
  * This is what the Skeleton2D directly interfaces with to make IK possible
* Adds SkeletonModifier2D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
  * Each modification is in its own file
  * There is also a SkeletonModifier2D resource that acts as a stack for using multiple stacks together
* Adds a PhysicalBone2D node
  * Works similar to the PhysicalBone3D node, but uses a RigidBody2D node
* Changes to Skeleton2D listed below:
  * Skeleton2D now holds a single SkeletonModificationStack2D for IK
  * Skeleton2D now has a local_pose_override, which overrides the Bone2D position similar to how the overrides work in Skeleton3D
* Changes to Bone2D listed below:
  * The default_length property has been changed to length. Length is the length of the bone to its child bone node
  * New bone_angle property, which is the angle the bone has to its first child bone node
  * Bone2D caches its transform when not modified by IK for IK interpolation purposes
  * Bone2D draws its own editor gizmo, though this is stated to change in the future
* Changes to CanvasItemEditor listed below:
  * Bone2D gizmo drawing code removed
  * The 2D IK code is removed. Now Bone2D is the only bone system for 2D
* Transform2D now has a looking_at function for rotating to face a position
* Two new node notifications: NOTIFICATION_EDITOR_PRE_SAVE and NOTIFICATION_EDITOR_POST_SAVE
  * These notifications only are called in the editor right before and after saving a scene
  * Needed for not saving the IK position when executing IK in the editor
* Documentation for all the changes listed above.
											 
										 
										
											2020-08-03 14:02:24 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												undo_redo - > add_do_method ( n2d_parent ,  " add_child " ,  new_bone ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												undo_redo - > add_do_method ( n2d_parent ,  " remove_child " ,  n2d ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												undo_redo - > add_do_method ( new_bone ,  " add_child " ,  n2d ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												undo_redo - > add_do_method ( n2d ,  " set_transform " ,  Transform2D ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												undo_redo - > add_do_method ( this ,  " _set_owner_for_node_and_children " ,  new_bone ,  editor_root ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-28 16:55:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												undo_redo - > add_do_reference ( new_bone ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-07-06 11:49:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
											 
										
											
												New and improved IK system for Skeleton2D
This PR and commit adds a new IK system for 2D with the Skeleton2D node
that adds several new IK solvers, a way to control bones in a Skeleton2D
node similar to that in Skeleton3D. It also adds additional changes
and functionality.
This work was sponsored by GSoC 2020 and TwistedTwigleg.
Full list of changes:
* Adds a SkeletonModifier2D resource
  * This resource is the base where all IK code is written and executed
  * Has a function for clamping angles, since it is so commonly used
  * Modifiers are unique when duplicated so it works with instancing
* Adds a SkeletonModifierStack2D resource
  * This resource manages a series of SkeletonModification2Ds
  * This is what the Skeleton2D directly interfaces with to make IK possible
* Adds SkeletonModifier2D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
  * Each modification is in its own file
  * There is also a SkeletonModifier2D resource that acts as a stack for using multiple stacks together
* Adds a PhysicalBone2D node
  * Works similar to the PhysicalBone3D node, but uses a RigidBody2D node
* Changes to Skeleton2D listed below:
  * Skeleton2D now holds a single SkeletonModificationStack2D for IK
  * Skeleton2D now has a local_pose_override, which overrides the Bone2D position similar to how the overrides work in Skeleton3D
* Changes to Bone2D listed below:
  * The default_length property has been changed to length. Length is the length of the bone to its child bone node
  * New bone_angle property, which is the angle the bone has to its first child bone node
  * Bone2D caches its transform when not modified by IK for IK interpolation purposes
  * Bone2D draws its own editor gizmo, though this is stated to change in the future
* Changes to CanvasItemEditor listed below:
  * Bone2D gizmo drawing code removed
  * The 2D IK code is removed. Now Bone2D is the only bone system for 2D
* Transform2D now has a looking_at function for rotating to face a position
* Two new node notifications: NOTIFICATION_EDITOR_PRE_SAVE and NOTIFICATION_EDITOR_POST_SAVE
  * These notifications only are called in the editor right before and after saving a scene
  * Needed for not saving the IK position when executing IK in the editor
* Documentation for all the changes listed above.
											 
										 
										
											2020-08-03 14:02:24 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												undo_redo - > add_undo_method ( new_bone ,  " remove_child " ,  n2d ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												undo_redo - > add_undo_method ( n2d_parent ,  " add_child " ,  n2d ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-28 16:55:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												undo_redo - > add_undo_method ( n2d_parent ,  " remove_child " ,  new_bone ) ; 
							 
						 
					
						
							
								
									
										
											 
										
											
												New and improved IK system for Skeleton2D
This PR and commit adds a new IK system for 2D with the Skeleton2D node
that adds several new IK solvers, a way to control bones in a Skeleton2D
node similar to that in Skeleton3D. It also adds additional changes
and functionality.
This work was sponsored by GSoC 2020 and TwistedTwigleg.
Full list of changes:
* Adds a SkeletonModifier2D resource
  * This resource is the base where all IK code is written and executed
  * Has a function for clamping angles, since it is so commonly used
  * Modifiers are unique when duplicated so it works with instancing
* Adds a SkeletonModifierStack2D resource
  * This resource manages a series of SkeletonModification2Ds
  * This is what the Skeleton2D directly interfaces with to make IK possible
* Adds SkeletonModifier2D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
  * Each modification is in its own file
  * There is also a SkeletonModifier2D resource that acts as a stack for using multiple stacks together
* Adds a PhysicalBone2D node
  * Works similar to the PhysicalBone3D node, but uses a RigidBody2D node
* Changes to Skeleton2D listed below:
  * Skeleton2D now holds a single SkeletonModificationStack2D for IK
  * Skeleton2D now has a local_pose_override, which overrides the Bone2D position similar to how the overrides work in Skeleton3D
* Changes to Bone2D listed below:
  * The default_length property has been changed to length. Length is the length of the bone to its child bone node
  * New bone_angle property, which is the angle the bone has to its first child bone node
  * Bone2D caches its transform when not modified by IK for IK interpolation purposes
  * Bone2D draws its own editor gizmo, though this is stated to change in the future
* Changes to CanvasItemEditor listed below:
  * Bone2D gizmo drawing code removed
  * The 2D IK code is removed. Now Bone2D is the only bone system for 2D
* Transform2D now has a looking_at function for rotating to face a position
* Two new node notifications: NOTIFICATION_EDITOR_PRE_SAVE and NOTIFICATION_EDITOR_POST_SAVE
  * These notifications only are called in the editor right before and after saving a scene
  * Needed for not saving the IK position when executing IK in the editor
* Documentation for all the changes listed above.
											 
										 
										
											2020-08-03 14:02:24 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												undo_redo - > add_undo_method ( n2d ,  " set_transform " ,  new_bone - > get_transform ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												undo_redo - > add_undo_method ( this ,  " _set_owner_for_node_and_children " ,  n2d ,  editor_root ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-07-06 11:49:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2019-05-21 17:17:25 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											undo_redo - > commit_action ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-07-06 11:49:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}  break ; 
							 
						 
					
						
							
								
									
										
											 
										
											
												New and improved IK system for Skeleton2D
This PR and commit adds a new IK system for 2D with the Skeleton2D node
that adds several new IK solvers, a way to control bones in a Skeleton2D
node similar to that in Skeleton3D. It also adds additional changes
and functionality.
This work was sponsored by GSoC 2020 and TwistedTwigleg.
Full list of changes:
* Adds a SkeletonModifier2D resource
  * This resource is the base where all IK code is written and executed
  * Has a function for clamping angles, since it is so commonly used
  * Modifiers are unique when duplicated so it works with instancing
* Adds a SkeletonModifierStack2D resource
  * This resource manages a series of SkeletonModification2Ds
  * This is what the Skeleton2D directly interfaces with to make IK possible
* Adds SkeletonModifier2D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
  * Each modification is in its own file
  * There is also a SkeletonModifier2D resource that acts as a stack for using multiple stacks together
* Adds a PhysicalBone2D node
  * Works similar to the PhysicalBone3D node, but uses a RigidBody2D node
* Changes to Skeleton2D listed below:
  * Skeleton2D now holds a single SkeletonModificationStack2D for IK
  * Skeleton2D now has a local_pose_override, which overrides the Bone2D position similar to how the overrides work in Skeleton3D
* Changes to Bone2D listed below:
  * The default_length property has been changed to length. Length is the length of the bone to its child bone node
  * New bone_angle property, which is the angle the bone has to its first child bone node
  * Bone2D caches its transform when not modified by IK for IK interpolation purposes
  * Bone2D draws its own editor gizmo, though this is stated to change in the future
* Changes to CanvasItemEditor listed below:
  * Bone2D gizmo drawing code removed
  * The 2D IK code is removed. Now Bone2D is the only bone system for 2D
* Transform2D now has a looking_at function for rotating to face a position
* Two new node notifications: NOTIFICATION_EDITOR_PRE_SAVE and NOTIFICATION_EDITOR_POST_SAVE
  * These notifications only are called in the editor right before and after saving a scene
  * Needed for not saving the IK position when executing IK in the editor
* Documentation for all the changes listed above.
											 
										 
										
											2020-08-03 14:02:24 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2014-07-06 11:49:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
											 
										
											
												New and improved IK system for Skeleton2D
This PR and commit adds a new IK system for 2D with the Skeleton2D node
that adds several new IK solvers, a way to control bones in a Skeleton2D
node similar to that in Skeleton3D. It also adds additional changes
and functionality.
This work was sponsored by GSoC 2020 and TwistedTwigleg.
Full list of changes:
* Adds a SkeletonModifier2D resource
  * This resource is the base where all IK code is written and executed
  * Has a function for clamping angles, since it is so commonly used
  * Modifiers are unique when duplicated so it works with instancing
* Adds a SkeletonModifierStack2D resource
  * This resource manages a series of SkeletonModification2Ds
  * This is what the Skeleton2D directly interfaces with to make IK possible
* Adds SkeletonModifier2D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
  * Each modification is in its own file
  * There is also a SkeletonModifier2D resource that acts as a stack for using multiple stacks together
* Adds a PhysicalBone2D node
  * Works similar to the PhysicalBone3D node, but uses a RigidBody2D node
* Changes to Skeleton2D listed below:
  * Skeleton2D now holds a single SkeletonModificationStack2D for IK
  * Skeleton2D now has a local_pose_override, which overrides the Bone2D position similar to how the overrides work in Skeleton3D
* Changes to Bone2D listed below:
  * The default_length property has been changed to length. Length is the length of the bone to its child bone node
  * New bone_angle property, which is the angle the bone has to its first child bone node
  * Bone2D caches its transform when not modified by IK for IK interpolation purposes
  * Bone2D draws its own editor gizmo, though this is stated to change in the future
* Changes to CanvasItemEditor listed below:
  * Bone2D gizmo drawing code removed
  * The 2D IK code is removed. Now Bone2D is the only bone system for 2D
* Transform2D now has a looking_at function for rotating to face a position
* Two new node notifications: NOTIFICATION_EDITOR_PRE_SAVE and NOTIFICATION_EDITOR_POST_SAVE
  * These notifications only are called in the editor right before and after saving a scene
  * Needed for not saving the IK position when executing IK in the editor
* Documentation for all the changes listed above.
											 
										 
										
											2020-08-03 14:02:24 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : _set_owner_for_node_and_children ( Node  * p_node ,  Node  * p_owner )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									p_node - > set_owner ( p_owner ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									for  ( int  i  =  0 ;  i  <  p_node - > get_child_count ( ) ;  i + + )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										_set_owner_for_node_and_children ( p_node - > get_child ( i ) ,  p_owner ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-07-28 14:37:52 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : _focus_selection ( int  p_op )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Rect2  rect ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									int  count  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-05-13 15:04:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									const  HashMap < Node  * ,  Object  * >  & selection  =  editor_selection - > get_selection ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-09 14:13:42 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									for  ( const  KeyValue < Node  * ,  Object  * >  & E  :  selection )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										CanvasItem  * ci  =  Object : : cast_to < CanvasItem > ( E . key ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if  ( ! ci )  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-28 14:37:52 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											continue ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2025-03-08 17:08:57 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										const  Transform2D  canvas_item_transform  =  ci - > get_global_transform ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if  ( ! canvas_item_transform . is_finite ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-08 21:35:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Rect2  item_rect ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:53:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( ci - > _edit_use_rect ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											item_rect  =  ci - > _edit_get_rect ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-08 21:35:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											item_rect  =  Rect2 ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2025-03-08 17:08:57 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Vector2  pos  =  canvas_item_transform . get_origin ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										const  Vector2  scale  =  canvas_item_transform . get_scale ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										const  real_t  angle  =  canvas_item_transform . get_rotation ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-18 17:16:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										pos  =  ci - > get_viewport ( ) - > get_popup_base_transform ( ) . xform ( pos ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-28 14:37:52 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-01-11 00:52:51 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Transform2D  t ( angle ,  Vector2 ( 0.f ,  0.f ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-28 14:37:52 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										item_rect  =  t . xform ( item_rect ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-06-04 00:25:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Rect2  canvas_item_rect ( pos  +  scale  *  item_rect . position ,  scale  *  item_rect . size ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-03-08 17:08:57 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( count  = =  0 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-28 14:37:52 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											rect  =  canvas_item_rect ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											rect  =  rect . merge ( canvas_item_rect ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2025-03-08 17:08:57 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										count + + ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-12 15:04:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-28 14:37:52 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-01-12 15:04:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( p_op  = =  VIEW_FRAME_TO_SELECTION  & &  rect . size . x  >  CMP_EPSILON  & &  rect . size . y  >  CMP_EPSILON )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										real_t  scale_x  =  viewport - > get_size ( ) . x  /  rect . size . x ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										real_t  scale_y  =  viewport - > get_size ( ) . y  /  rect . size . y ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										zoom  =  scale_x  <  scale_y  ?  scale_x  :  scale_y ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										zoom  * =  0.90 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										zoom_widget - > set_zoom ( zoom ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										viewport - > queue_redraw ( ) ;  // Redraw to update the global canvas transform after zoom changes.
 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-18 15:46:56 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										callable_mp ( this ,  & CanvasItemEditor : : center_at ) . call_deferred ( rect . get_center ( ) ) ;  // Defer because the updated transform is needed.
 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-12 15:04:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										center_at ( rect . get_center ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-28 14:37:52 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-14 14:51:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : _reset_drag ( )  {  
						 
					
						
							
								
									
										
										
										
											2024-02-25 13:36:42 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									message  =  " " ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-14 14:51:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									drag_type  =  DRAG_NONE ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									drag_selection . clear ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : _bind_methods ( )  {  
						 
					
						
							
								
									
										
										
										
											2017-01-02 23:03:46 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									ClassDB : : bind_method ( " _get_editor_data " ,  & CanvasItemEditor : : _get_editor_data ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-22 12:37:22 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-10-18 14:06:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									ClassDB : : bind_method ( D_METHOD ( " update_viewport " ) ,  & CanvasItemEditor : : update_viewport ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-12 15:04:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									ClassDB : : bind_method ( D_METHOD ( " center_at " ,  " position " ) ,  & CanvasItemEditor : : center_at ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-03-05 16:44:50 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
											 
										
											
												New and improved IK system for Skeleton2D
This PR and commit adds a new IK system for 2D with the Skeleton2D node
that adds several new IK solvers, a way to control bones in a Skeleton2D
node similar to that in Skeleton3D. It also adds additional changes
and functionality.
This work was sponsored by GSoC 2020 and TwistedTwigleg.
Full list of changes:
* Adds a SkeletonModifier2D resource
  * This resource is the base where all IK code is written and executed
  * Has a function for clamping angles, since it is so commonly used
  * Modifiers are unique when duplicated so it works with instancing
* Adds a SkeletonModifierStack2D resource
  * This resource manages a series of SkeletonModification2Ds
  * This is what the Skeleton2D directly interfaces with to make IK possible
* Adds SkeletonModifier2D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
  * Each modification is in its own file
  * There is also a SkeletonModifier2D resource that acts as a stack for using multiple stacks together
* Adds a PhysicalBone2D node
  * Works similar to the PhysicalBone3D node, but uses a RigidBody2D node
* Changes to Skeleton2D listed below:
  * Skeleton2D now holds a single SkeletonModificationStack2D for IK
  * Skeleton2D now has a local_pose_override, which overrides the Bone2D position similar to how the overrides work in Skeleton3D
* Changes to Bone2D listed below:
  * The default_length property has been changed to length. Length is the length of the bone to its child bone node
  * New bone_angle property, which is the angle the bone has to its first child bone node
  * Bone2D caches its transform when not modified by IK for IK interpolation purposes
  * Bone2D draws its own editor gizmo, though this is stated to change in the future
* Changes to CanvasItemEditor listed below:
  * Bone2D gizmo drawing code removed
  * The 2D IK code is removed. Now Bone2D is the only bone system for 2D
* Transform2D now has a looking_at function for rotating to face a position
* Two new node notifications: NOTIFICATION_EDITOR_PRE_SAVE and NOTIFICATION_EDITOR_POST_SAVE
  * These notifications only are called in the editor right before and after saving a scene
  * Needed for not saving the IK position when executing IK in the editor
* Documentation for all the changes listed above.
											 
										 
										
											2020-08-03 14:02:24 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									ClassDB : : bind_method ( " _set_owner_for_node_and_children " ,  & CanvasItemEditor : : _set_owner_for_node_and_children ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-05-08 13:43:19 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									ADD_SIGNAL ( MethodInfo ( " item_lock_status_changed " ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ADD_SIGNAL ( MethodInfo ( " item_group_status_changed " ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Dictionary  CanvasItemEditor : : get_state ( )  const  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Dictionary  state ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-04 18:43:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// Take the editor scale into account.
 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-13 12:13:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									state [ " zoom " ]  =  zoom  /  MAX ( 1 ,  EDSCALE ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-15 15:12:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									state [ " ofs " ]  =  view_offset ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									state [ " grid_offset " ]  =  grid_offset ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									state [ " grid_step " ]  =  grid_step ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-02 17:13:46 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									state [ " primary_grid_step " ]  =  primary_grid_step ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									state [ " snap_rotation_offset " ]  =  snap_rotation_offset ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									state [ " snap_rotation_step " ]  =  snap_rotation_step ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-30 15:18:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									state [ " snap_scale_step " ]  =  snap_scale_step ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-10 19:41:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									state [ " smart_snap_active " ]  =  smart_snap_active ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									state [ " grid_snap_active " ]  =  grid_snap_active ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									state [ " snap_node_parent " ]  =  snap_node_parent ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									state [ " snap_node_anchors " ]  =  snap_node_anchors ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									state [ " snap_node_sides " ]  =  snap_node_sides ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									state [ " snap_node_center " ]  =  snap_node_center ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									state [ " snap_other_nodes " ]  =  snap_other_nodes ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									state [ " snap_guides " ]  =  snap_guides ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-09 17:53:39 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									state [ " grid_visibility " ]  =  grid_visibility ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-02 03:52:13 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									state [ " show_origin " ]  =  show_origin ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									state [ " show_viewport " ]  =  show_viewport ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									state [ " show_rulers " ]  =  show_rulers ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									state [ " show_guides " ]  =  show_guides ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									state [ " show_helpers " ]  =  show_helpers ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-05-07 15:41:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									state [ " show_zoom_control " ]  =  zoom_widget - > is_visible ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-25 12:41:37 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									state [ " show_position_gizmos " ]  =  show_position_gizmos ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									state [ " show_lock_gizmos " ]  =  show_lock_gizmos ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									state [ " show_group_gizmos " ]  =  show_group_gizmos ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-11-10 10:07:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									state [ " show_transformation_gizmos " ]  =  show_transformation_gizmos ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									state [ " snap_rotation " ]  =  snap_rotation ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-30 15:18:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									state [ " snap_scale " ]  =  snap_scale ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									state [ " snap_relative " ]  =  snap_relative ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									state [ " snap_pixel " ]  =  snap_pixel ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return  state ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : set_state ( const  Dictionary  & p_state )  {  
						 
					
						
							
								
									
										
										
										
											2019-05-20 22:35:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									bool  update_scrollbars  =  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Dictionary  state  =  p_state ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( state . has ( " zoom " ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-04 18:43:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										// Compensate the editor scale, so that the editor scale can be changed
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										// and the zoom level will still be the same (relative to the editor scale).
 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-20 23:30:19 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										zoom  =  real_t ( p_state [ " zoom " ] )  *  MAX ( 1 ,  EDSCALE ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-05-07 15:41:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										zoom_widget - > set_zoom ( zoom ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( state . has ( " ofs " ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-15 15:12:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										view_offset  =  p_state [ " ofs " ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										previous_update_view_offset  =  view_offset ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-05-20 22:35:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										update_scrollbars  =  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( state . has ( " grid_offset " ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										grid_offset  =  state [ " grid_offset " ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( state . has ( " grid_step " ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										grid_step  =  state [ " grid_step " ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-02 17:13:46 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# ifndef DISABLE_DEPRECATED 
  
						 
					
						
							
								
									
										
										
										
											2019-10-15 10:23:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( state . has ( " primary_grid_steps " ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-02 17:13:46 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										primary_grid_step . x  =  state [ " primary_grid_steps " ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										primary_grid_step . y  =  state [ " primary_grid_steps " ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								# endif  // DISABLE_DEPRECATED
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( state . has ( " primary_grid_step " ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										primary_grid_step  =  state [ " primary_grid_step " ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-15 10:23:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( state . has ( " snap_rotation_step " ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										snap_rotation_step  =  state [ " snap_rotation_step " ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( state . has ( " snap_rotation_offset " ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										snap_rotation_offset  =  state [ " snap_rotation_offset " ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-10-30 15:18:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( state . has ( " snap_scale_step " ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										snap_scale_step  =  state [ " snap_scale_step " ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-10-10 19:41:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( state . has ( " smart_snap_active " ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										smart_snap_active  =  state [ " smart_snap_active " ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										smart_snap_button - > set_pressed ( smart_snap_active ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( state . has ( " grid_snap_active " ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										grid_snap_active  =  state [ " grid_snap_active " ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-14 11:40:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										grid_snap_button - > set_pressed ( grid_snap_active ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( state . has ( " snap_node_parent " ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										snap_node_parent  =  state [ " snap_node_parent " ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										int  idx  =  smartsnap_config_popup - > get_item_index ( SNAP_USE_NODE_PARENT ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										smartsnap_config_popup - > set_item_checked ( idx ,  snap_node_parent ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( state . has ( " snap_node_anchors " ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										snap_node_anchors  =  state [ " snap_node_anchors " ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										int  idx  =  smartsnap_config_popup - > get_item_index ( SNAP_USE_NODE_ANCHORS ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										smartsnap_config_popup - > set_item_checked ( idx ,  snap_node_anchors ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( state . has ( " snap_node_sides " ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										snap_node_sides  =  state [ " snap_node_sides " ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										int  idx  =  smartsnap_config_popup - > get_item_index ( SNAP_USE_NODE_SIDES ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										smartsnap_config_popup - > set_item_checked ( idx ,  snap_node_sides ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( state . has ( " snap_node_center " ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										snap_node_center  =  state [ " snap_node_center " ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										int  idx  =  smartsnap_config_popup - > get_item_index ( SNAP_USE_NODE_CENTER ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										smartsnap_config_popup - > set_item_checked ( idx ,  snap_node_center ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( state . has ( " snap_other_nodes " ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										snap_other_nodes  =  state [ " snap_other_nodes " ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										int  idx  =  smartsnap_config_popup - > get_item_index ( SNAP_USE_OTHER_NODES ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										smartsnap_config_popup - > set_item_checked ( idx ,  snap_other_nodes ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( state . has ( " snap_guides " ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										snap_guides  =  state [ " snap_guides " ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										int  idx  =  smartsnap_config_popup - > get_item_index ( SNAP_USE_GUIDES ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										smartsnap_config_popup - > set_item_checked ( idx ,  snap_guides ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-09 17:53:39 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( state . has ( " grid_visibility " ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										grid_visibility  =  ( GridVisibility ) ( int ) ( state [ " grid_visibility " ] ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-03-02 03:52:13 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( state . has ( " show_origin " ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										show_origin  =  state [ " show_origin " ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										int  idx  =  view_menu - > get_popup ( ) - > get_item_index ( SHOW_ORIGIN ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										view_menu - > get_popup ( ) - > set_item_checked ( idx ,  show_origin ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( state . has ( " show_viewport " ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										show_viewport  =  state [ " show_viewport " ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										int  idx  =  view_menu - > get_popup ( ) - > get_item_index ( SHOW_VIEWPORT ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										view_menu - > get_popup ( ) - > set_item_checked ( idx ,  show_viewport ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( state . has ( " show_rulers " ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										show_rulers  =  state [ " show_rulers " ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										int  idx  =  view_menu - > get_popup ( ) - > get_item_index ( SHOW_RULERS ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										view_menu - > get_popup ( ) - > set_item_checked ( idx ,  show_rulers ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-05-20 22:35:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										update_scrollbars  =  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( state . has ( " show_guides " ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										show_guides  =  state [ " show_guides " ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										int  idx  =  view_menu - > get_popup ( ) - > get_item_index ( SHOW_GUIDES ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										view_menu - > get_popup ( ) - > set_item_checked ( idx ,  show_guides ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( state . has ( " show_helpers " ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										show_helpers  =  state [ " show_helpers " ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										int  idx  =  view_menu - > get_popup ( ) - > get_item_index ( SHOW_HELPERS ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										view_menu - > get_popup ( ) - > set_item_checked ( idx ,  show_helpers ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-10-25 12:41:37 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( state . has ( " show_position_gizmos " ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										show_position_gizmos  =  state [ " show_position_gizmos " ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										int  idx  =  gizmos_menu - > get_item_index ( SHOW_POSITION_GIZMOS ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										gizmos_menu - > set_item_checked ( idx ,  show_position_gizmos ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( state . has ( " show_lock_gizmos " ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										show_lock_gizmos  =  state [ " show_lock_gizmos " ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										int  idx  =  gizmos_menu - > get_item_index ( SHOW_LOCK_GIZMOS ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										gizmos_menu - > set_item_checked ( idx ,  show_lock_gizmos ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( state . has ( " show_group_gizmos " ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										show_group_gizmos  =  state [ " show_group_gizmos " ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										int  idx  =  gizmos_menu - > get_item_index ( SHOW_GROUP_GIZMOS ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										gizmos_menu - > set_item_checked ( idx ,  show_group_gizmos ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-20 02:41:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-11-10 10:07:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( state . has ( " show_transformation_gizmos " ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										show_transformation_gizmos  =  state [ " show_transformation_gizmos " ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-25 12:41:37 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										int  idx  =  gizmos_menu - > get_item_index ( SHOW_TRANSFORMATION_GIZMOS ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										gizmos_menu - > set_item_checked ( idx ,  show_transformation_gizmos ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-11-10 10:07:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-05-20 22:36:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( state . has ( " show_zoom_control " ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										// This one is not user-controllable, but instrumentable
 
							 
						 
					
						
							
								
									
										
										
										
											2021-05-07 15:41:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										zoom_widget - > set_visible ( state [ " show_zoom_control " ] ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-05-20 22:36:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( state . has ( " snap_rotation " ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										snap_rotation  =  state [ " snap_rotation " ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										int  idx  =  snap_config_menu - > get_popup ( ) - > get_item_index ( SNAP_USE_ROTATION ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										snap_config_menu - > get_popup ( ) - > set_item_checked ( idx ,  snap_rotation ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-10-30 15:18:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( state . has ( " snap_scale " ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										snap_scale  =  state [ " snap_scale " ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										int  idx  =  snap_config_menu - > get_popup ( ) - > get_item_index ( SNAP_USE_SCALE ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										snap_config_menu - > get_popup ( ) - > set_item_checked ( idx ,  snap_scale ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( state . has ( " snap_relative " ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										snap_relative  =  state [ " snap_relative " ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										int  idx  =  snap_config_menu - > get_popup ( ) - > get_item_index ( SNAP_RELATIVE ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										snap_config_menu - > get_popup ( ) - > set_item_checked ( idx ,  snap_relative ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( state . has ( " snap_pixel " ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										snap_pixel  =  state [ " snap_pixel " ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										int  idx  =  snap_config_menu - > get_popup ( ) - > get_item_index ( SNAP_USE_PIXEL ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										snap_config_menu - > get_popup ( ) - > set_item_checked ( idx ,  snap_pixel ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-05-20 22:35:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( update_scrollbars )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										_update_scrollbars ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-13 23:21:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									viewport - > queue_redraw ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-03-09 21:12:26 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : clear ( )  {  
						 
					
						
							
								
									
										
										
										
											2023-04-01 15:18:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									zoom  =  1.0  /  MAX ( 1 ,  EDSCALE ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									zoom_widget - > set_zoom ( zoom ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									view_offset  =  Point2 ( - 150  -  RULER_WIDTH ,  - 95  -  RULER_WIDTH ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									previous_update_view_offset  =  view_offset ;  // Moves the view a little bit to the left so that (0,0) is visible. The values a relative to a 16/10 screen.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									_update_scrollbars ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-03-09 21:12:26 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									grid_offset  =  EditorSettings : : get_singleton ( ) - > get_project_metadata ( " 2d_editor " ,  " grid_offset " ,  Vector2 ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									grid_step  =  EditorSettings : : get_singleton ( ) - > get_project_metadata ( " 2d_editor " ,  " grid_step " ,  Vector2 ( 8 ,  8 ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-02 17:13:46 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									primary_grid_step  =  EditorSettings : : get_singleton ( ) - > get_project_metadata ( " 2d_editor " ,  " primary_grid_step " ,  Vector2i ( 8 ,  8 ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-09 21:12:26 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									snap_rotation_step  =  EditorSettings : : get_singleton ( ) - > get_project_metadata ( " 2d_editor " ,  " snap_rotation_step " ,  Math : : deg_to_rad ( 15.0 ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									snap_rotation_offset  =  EditorSettings : : get_singleton ( ) - > get_project_metadata ( " 2d_editor " ,  " snap_rotation_offset " ,  0.0 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									snap_scale_step  =  EditorSettings : : get_singleton ( ) - > get_project_metadata ( " 2d_editor " ,  " snap_scale_step " ,  0.1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : add_control_to_menu_panel ( Control  * p_control )  {  
						 
					
						
							
								
									
										
										
										
											2023-09-11 23:50:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_NULL ( p_control ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_COND ( p_control - > get_parent ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-11 23:50:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									VSeparator  * sep  =  memnew ( VSeparator ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									context_toolbar_hbox - > add_child ( sep ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									context_toolbar_hbox - > add_child ( p_control ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									context_toolbar_separators [ p_control ]  =  sep ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-13 16:56:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									p_control - > connect ( SceneStringName ( visibility_changed ) ,  callable_mp ( this ,  & CanvasItemEditor : : _update_context_toolbar ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-11 23:50:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									_update_context_toolbar ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-02-13 19:21:19 -02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : remove_control_from_menu_panel ( Control  * p_control )  {  
						 
					
						
							
								
									
										
										
										
											2023-09-11 23:50:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_NULL ( p_control ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_COND ( p_control - > get_parent ( )  ! =  context_toolbar_hbox ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-13 16:56:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									p_control - > disconnect ( SceneStringName ( visibility_changed ) ,  callable_mp ( this ,  & CanvasItemEditor : : _update_context_toolbar ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-11 23:50:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-23 14:01:52 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									VSeparator  * sep  =  context_toolbar_separators [ p_control ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									context_toolbar_hbox - > remove_child ( sep ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-11 23:50:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									context_toolbar_hbox - > remove_child ( p_control ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									context_toolbar_separators . erase ( p_control ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-23 14:01:52 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									memdelete ( sep ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-11 23:50:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									_update_context_toolbar ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : _update_context_toolbar ( )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									bool  has_visible  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									bool  first_visible  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									for  ( int  i  =  0 ;  i  <  context_toolbar_hbox - > get_child_count ( ) ;  i + + )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										Control  * child  =  Object : : cast_to < Control > ( context_toolbar_hbox - > get_child ( i ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if  ( ! child  | |  ! context_toolbar_separators . has ( child ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if  ( child - > is_visible ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											first_visible  =  ! has_visible ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											has_visible  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										VSeparator  * sep  =  context_toolbar_separators [ child ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										sep - > set_visible ( ! first_visible  & &  child - > is_visible ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									context_toolbar_panel - > set_visible ( has_visible ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-02-13 19:21:19 -02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-08 20:31:22 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : add_control_to_left_panel ( Control  * p_control )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									left_panel_split - > add_child ( p_control ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									left_panel_split - > move_child ( p_control ,  0 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : add_control_to_right_panel ( Control  * p_control )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									right_panel_split - > add_child ( p_control ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									right_panel_split - > move_child ( p_control ,  1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : remove_control_from_left_panel ( Control  * p_control )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									left_panel_split - > remove_child ( p_control ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : remove_control_from_right_panel ( Control  * p_control )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									right_panel_split - > remove_child ( p_control ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-12-29 08:37:25 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-01-11 20:52:42 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								VSplitContainer  * CanvasItemEditor : : get_bottom_split ( )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return  bottom_split ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-07-28 14:37:52 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : focus_selection ( )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									_focus_selection ( VIEW_CENTER_TO_SELECTION ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-01-12 15:04:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditor : : center_at ( const  Point2  & p_pos )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Vector2  offset  =  viewport - > get_size ( )  /  2  -  EditorNode : : get_singleton ( ) - > get_scene_root ( ) - > get_global_canvas_transform ( ) . xform ( p_pos ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									view_offset  - =  ( offset  /  zoom ) . round ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									update_viewport ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 10:36:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								CanvasItemEditor : : CanvasItemEditor ( )  {  
						 
					
						
							
								
									
										
										
										
											2019-09-20 22:26:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									snap_target [ 0 ]  =  SNAP_TARGET_NONE ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									snap_target [ 1 ]  =  SNAP_TARGET_NONE ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-11-11 17:32:47 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 10:36:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									editor_selection  =  EditorNode : : get_singleton ( ) - > get_editor_selection ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									editor_selection - > add_editor_plugin ( this ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-13 23:21:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									editor_selection - > connect ( " selection_changed " ,  callable_mp ( ( CanvasItem  * ) this ,  & CanvasItem : : queue_redraw ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-21 18:28:45 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									editor_selection - > connect ( " selection_changed " ,  callable_mp ( this ,  & CanvasItemEditor : : _selection_changed ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 10:13:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									SceneTreeDock : : get_singleton ( ) - > connect ( " node_created " ,  callable_mp ( this ,  & CanvasItemEditor : : _adjust_new_node_position ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-17 21:08:55 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									SceneTreeDock : : get_singleton ( ) - > connect ( " add_node_used " ,  callable_mp ( this ,  & CanvasItemEditor : : _reset_create_position ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-25 01:32:58 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-07-05 16:03:01 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// Add some margin to the sides for better aesthetics.
 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-11 23:50:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// This prevents the first button's hover/pressed effect from "touching" the panel's border,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									// which looks ugly.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									MarginContainer  * toolbar_margin  =  memnew ( MarginContainer ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									toolbar_margin - > add_theme_constant_override ( " margin_left " ,  4  *  EDSCALE ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									toolbar_margin - > add_theme_constant_override ( " margin_right " ,  4  *  EDSCALE ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									add_child ( toolbar_margin ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 04:00:25 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// A fluid container for all toolbars.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									HFlowContainer  * main_flow  =  memnew ( HFlowContainer ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-11 23:50:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									toolbar_margin - > add_child ( main_flow ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 04:00:25 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									// Main toolbars.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									HBoxContainer  * main_menu_hbox  =  memnew ( HBoxContainer ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									main_menu_hbox - > set_anchors_and_offsets_preset ( Control : : PRESET_FULL_RECT ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									main_flow - > add_child ( main_menu_hbox ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-01-11 20:52:42 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									bottom_split  =  memnew ( VSplitContainer ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									add_child ( bottom_split ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-06 14:00:16 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									bottom_split - > set_v_size_flags ( Control : : SIZE_EXPAND_FILL ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-11 20:52:42 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-08 20:31:22 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									left_panel_split  =  memnew ( HSplitContainer ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									bottom_split - > add_child ( left_panel_split ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									left_panel_split - > set_v_size_flags ( Control : : SIZE_EXPAND_FILL ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									right_panel_split  =  memnew ( HSplitContainer ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									left_panel_split - > add_child ( right_panel_split ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									right_panel_split - > set_v_size_flags ( Control : : SIZE_EXPAND_FILL ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-12-29 08:37:25 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-08-29 21:50:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									viewport_scrollable  =  memnew ( Control ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-08 20:31:22 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									right_panel_split - > add_child ( viewport_scrollable ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-29 21:50:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									viewport_scrollable - > set_mouse_filter ( MOUSE_FILTER_PASS ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									viewport_scrollable - > set_clip_contents ( true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-06 14:00:16 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									viewport_scrollable - > set_v_size_flags ( Control : : SIZE_EXPAND_FILL ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									viewport_scrollable - > set_h_size_flags ( Control : : SIZE_EXPAND_FILL ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-13 16:56:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									viewport_scrollable - > connect ( SceneStringName ( draw ) ,  callable_mp ( this ,  & CanvasItemEditor : : _update_scrollbars ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-04-01 15:28:09 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									SubViewportContainer  * scene_tree  =  memnew ( SubViewportContainer ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-29 21:50:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									viewport_scrollable - > add_child ( scene_tree ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-28 21:51:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									scene_tree - > set_stretch ( true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-18 19:02:57 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									scene_tree - > set_anchors_and_offsets_preset ( Control : : PRESET_FULL_RECT ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 10:36:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									scene_tree - > add_child ( EditorNode : : get_singleton ( ) - > get_scene_root ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-11-18 10:49:37 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									controls_vb  =  memnew ( VBoxContainer ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									controls_vb - > set_begin ( Point2 ( 5 ,  5 ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-10-18 19:07:44 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									ED_SHORTCUT ( " canvas_item_editor/cancel_transform " ,  TTRC ( " Cancel Transformation " ) ,  Key : : ESCAPE ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-26 08:24:58 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-07 21:11:36 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// To ensure that scripts can parse the list of shortcuts correctly, we have to define
 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-10 15:07:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// those shortcuts one by one. Define shortcut before using it (by EditorZoomWidget).
 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-18 19:07:44 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									ED_SHORTCUT_ARRAY ( " canvas_item_editor/zoom_3.125_percent " ,  TTRC ( " Zoom to 3.125% " ) , 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-10 15:07:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											{  int32_t ( KeyModifierMask : : SHIFT  |  Key : : KEY_5 ) ,  int32_t ( KeyModifierMask : : SHIFT  |  Key : : KP_5 )  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-10-18 19:07:44 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									ED_SHORTCUT_ARRAY ( " canvas_item_editor/zoom_6.25_percent " ,  TTRC ( " Zoom to 6.25% " ) , 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-10 15:07:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											{  int32_t ( KeyModifierMask : : SHIFT  |  Key : : KEY_4 ) ,  int32_t ( KeyModifierMask : : SHIFT  |  Key : : KP_4 )  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-10-18 19:07:44 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									ED_SHORTCUT_ARRAY ( " canvas_item_editor/zoom_12.5_percent " ,  TTRC ( " Zoom to 12.5% " ) , 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-10 15:07:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											{  int32_t ( KeyModifierMask : : SHIFT  |  Key : : KEY_3 ) ,  int32_t ( KeyModifierMask : : SHIFT  |  Key : : KP_3 )  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-10-18 19:07:44 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									ED_SHORTCUT_ARRAY ( " canvas_item_editor/zoom_25_percent " ,  TTRC ( " Zoom to 25% " ) , 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-10 15:07:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											{  int32_t ( KeyModifierMask : : SHIFT  |  Key : : KEY_2 ) ,  int32_t ( KeyModifierMask : : SHIFT  |  Key : : KP_2 )  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-10-18 19:07:44 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									ED_SHORTCUT_ARRAY ( " canvas_item_editor/zoom_50_percent " ,  TTRC ( " Zoom to 50% " ) , 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-10 15:07:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											{  int32_t ( KeyModifierMask : : SHIFT  |  Key : : KEY_1 ) ,  int32_t ( KeyModifierMask : : SHIFT  |  Key : : KP_1 )  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-10-18 19:07:44 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									ED_SHORTCUT_ARRAY ( " canvas_item_editor/zoom_100_percent " ,  TTRC ( " Zoom to 100% " ) , 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-02 12:37:48 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											{  int32_t ( Key : : KEY_1 ) ,  int32_t ( KeyModifierMask : : CMD_OR_CTRL  |  Key : : KEY_0 ) ,  int32_t ( Key : : KP_1 ) ,  int32_t ( KeyModifierMask : : CMD_OR_CTRL  |  Key : : KP_0 )  } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-10 15:07:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-10-18 19:07:44 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									ED_SHORTCUT_ARRAY ( " canvas_item_editor/zoom_200_percent " ,  TTRC ( " Zoom to 200% " ) , 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-10 15:07:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											{  int32_t ( Key : : KEY_2 ) ,  int32_t ( Key : : KP_2 )  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-10-18 19:07:44 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									ED_SHORTCUT_ARRAY ( " canvas_item_editor/zoom_400_percent " ,  TTRC ( " Zoom to 400% " ) , 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-10 15:07:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											{  int32_t ( Key : : KEY_3 ) ,  int32_t ( Key : : KP_3 )  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-10-18 19:07:44 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									ED_SHORTCUT_ARRAY ( " canvas_item_editor/zoom_800_percent " ,  TTRC ( " Zoom to 800% " ) , 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-10 15:07:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											{  int32_t ( Key : : KEY_4 ) ,  int32_t ( Key : : KP_4 )  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-10-18 19:07:44 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									ED_SHORTCUT_ARRAY ( " canvas_item_editor/zoom_1600_percent " ,  TTRC ( " Zoom to 1600% " ) , 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-10 15:07:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											{  int32_t ( Key : : KEY_5 ) ,  int32_t ( Key : : KP_5 )  } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-07 21:11:36 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 15:27:30 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									HBoxContainer  * controls_hb  =  memnew ( HBoxContainer ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									controls_vb - > add_child ( controls_hb ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									button_center_view  =  memnew ( Button ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									controls_hb - > add_child ( button_center_view ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									button_center_view - > set_flat ( true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									button_center_view - > set_tooltip_text ( TTR ( " Center View " ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-14 09:40:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									button_center_view - > connect ( SceneStringName ( pressed ) ,  callable_mp ( this ,  & CanvasItemEditor : : _popup_callback ) . bind ( VIEW_CENTER_TO_SELECTION ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 15:27:30 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 00:07:54 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									zoom_widget  =  memnew ( EditorZoomWidget ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									zoom_widget - > set_anchors_and_offsets_preset ( Control : : PRESET_TOP_LEFT ,  Control : : PRESET_MODE_MINSIZE ,  2  *  EDSCALE ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-24 23:03:43 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									zoom_widget - > set_shortcut_context ( this ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-17 18:33:02 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									controls_hb - > add_child ( zoom_widget ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 00:07:54 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									zoom_widget - > connect ( " zoom_changed " ,  callable_mp ( this ,  & CanvasItemEditor : : _update_zoom ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-19 19:59:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									panner . instantiate ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-19 17:50:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									panner - > set_callbacks ( callable_mp ( this ,  & CanvasItemEditor : : _pan_callback ) ,  callable_mp ( this ,  & CanvasItemEditor : : _zoom_callback ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-19 19:59:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 10:36:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									viewport  =  memnew ( CanvasItemEditorViewport ( this ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-29 21:50:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									viewport_scrollable - > add_child ( viewport ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									viewport - > set_mouse_filter ( MOUSE_FILTER_PASS ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-18 19:02:57 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									viewport - > set_anchors_and_offsets_preset ( Control : : PRESET_FULL_RECT ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-01-09 15:50:08 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									viewport - > set_clip_contents ( true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									viewport - > set_focus_mode ( FOCUS_ALL ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-13 16:56:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									viewport - > connect ( SceneStringName ( draw ) ,  callable_mp ( this ,  & CanvasItemEditor : : _draw_viewport ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									viewport - > connect ( SceneStringName ( gui_input ) ,  callable_mp ( this ,  & CanvasItemEditor : : _gui_input_viewport ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									viewport - > connect ( SceneStringName ( focus_exited ) ,  callable_mp ( panner . ptr ( ) ,  & ViewPanner : : release_pan_key ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-29 21:50:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-08-19 18:29:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									h_scroll  =  memnew ( HScrollBar ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									viewport - > add_child ( h_scroll ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-14 11:42:00 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									h_scroll - > connect ( SceneStringName ( value_changed ) ,  callable_mp ( this ,  & CanvasItemEditor : : _update_scroll ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									h_scroll - > hide ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-19 18:29:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									v_scroll  =  memnew ( VScrollBar ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									viewport - > add_child ( v_scroll ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-14 11:42:00 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									v_scroll - > connect ( SceneStringName ( value_changed ) ,  callable_mp ( this ,  & CanvasItemEditor : : _update_scroll ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									v_scroll - > hide ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-19 18:29:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-11-18 10:49:37 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									viewport - > add_child ( controls_vb ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-19 18:29:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-19 20:49:04 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									select_button  =  memnew ( Button ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-12-05 17:13:20 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									select_button - > set_theme_type_variation ( SceneStringName ( FlatButton ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 04:00:25 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									main_menu_hbox - > add_child ( select_button ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-19 18:29:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									select_button - > set_toggle_mode ( true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-14 09:40:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									select_button - > connect ( SceneStringName ( pressed ) ,  callable_mp ( this ,  & CanvasItemEditor : : _button_tool_select ) . bind ( TOOL_SELECT ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									select_button - > set_pressed ( true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-18 19:07:44 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									select_button - > set_shortcut ( ED_SHORTCUT ( " canvas_item_editor/select_mode " ,  TTRC ( " Select Mode " ) ,  Key : : Q ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-17 11:40:00 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									select_button - > set_shortcut_context ( this ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-27 19:34:40 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									select_button - > set_tooltip_text ( keycode_get_string ( ( Key ) KeyModifierMask : : CMD_OR_CTRL )  +  TTR ( " Drag: Rotate selected node around pivot. " )  +  " \n "  +  TTR ( " Alt+Drag: Move selected node. " )  +  " \n "  +  keycode_get_string ( ( Key ) KeyModifierMask : : CMD_OR_CTRL )  +  TTR ( " Alt+Drag: Scale selected node. " )  +  " \n "  +  TTR ( " V: Set selected node's pivot position. " )  +  " \n "  +  TTR ( " Alt+RMB: Show list of all nodes at position clicked, including locked. " )  +  " \n "  +  TTR ( " (Available in all modes.) " )  +  " \n "  +  TTR ( " RMB: Add node at position clicked. " ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-12-13 17:16:13 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 04:00:25 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									main_menu_hbox - > add_child ( memnew ( VSeparator ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-10 14:39:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-19 20:49:04 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									move_button  =  memnew ( Button ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-12-05 17:13:20 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									move_button - > set_theme_type_variation ( SceneStringName ( FlatButton ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 04:00:25 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									main_menu_hbox - > add_child ( move_button ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-19 18:29:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									move_button - > set_toggle_mode ( true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-14 09:40:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									move_button - > connect ( SceneStringName ( pressed ) ,  callable_mp ( this ,  & CanvasItemEditor : : _button_tool_select ) . bind ( TOOL_MOVE ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-18 19:07:44 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									move_button - > set_shortcut ( ED_SHORTCUT ( " canvas_item_editor/move_mode " ,  TTRC ( " Move Mode " ) ,  Key : : W ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-17 11:40:00 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									move_button - > set_shortcut_context ( this ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-18 19:07:44 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									move_button - > set_tooltip_text ( TTRC ( " Move Mode " ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-19 20:49:04 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									rotate_button  =  memnew ( Button ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-12-05 17:13:20 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									rotate_button - > set_theme_type_variation ( SceneStringName ( FlatButton ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 04:00:25 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									main_menu_hbox - > add_child ( rotate_button ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-19 18:29:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									rotate_button - > set_toggle_mode ( true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-14 09:40:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									rotate_button - > connect ( SceneStringName ( pressed ) ,  callable_mp ( this ,  & CanvasItemEditor : : _button_tool_select ) . bind ( TOOL_ROTATE ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-18 19:07:44 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									rotate_button - > set_shortcut ( ED_SHORTCUT ( " canvas_item_editor/rotate_mode " ,  TTRC ( " Rotate Mode " ) ,  Key : : E ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-17 11:40:00 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									rotate_button - > set_shortcut_context ( this ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-18 19:07:44 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									rotate_button - > set_tooltip_text ( TTRC ( " Rotate Mode " ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-19 20:49:04 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									scale_button  =  memnew ( Button ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-12-05 17:13:20 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									scale_button - > set_theme_type_variation ( SceneStringName ( FlatButton ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 04:00:25 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									main_menu_hbox - > add_child ( scale_button ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-15 18:44:26 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									scale_button - > set_toggle_mode ( true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-14 09:40:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									scale_button - > connect ( SceneStringName ( pressed ) ,  callable_mp ( this ,  & CanvasItemEditor : : _button_tool_select ) . bind ( TOOL_SCALE ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-18 19:07:44 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									scale_button - > set_shortcut ( ED_SHORTCUT ( " canvas_item_editor/scale_mode " ,  TTRC ( " Scale Mode " ) ,  Key : : S ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-17 11:40:00 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									scale_button - > set_shortcut_context ( this ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-18 19:07:44 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									scale_button - > set_tooltip_text ( TTRC ( " Shift: Scale proportionally. " ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-15 18:44:26 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 04:00:25 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									main_menu_hbox - > add_child ( memnew ( VSeparator ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-19 20:49:04 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									list_select_button  =  memnew ( Button ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-12-05 17:13:20 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									list_select_button - > set_theme_type_variation ( SceneStringName ( FlatButton ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 04:00:25 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									main_menu_hbox - > add_child ( list_select_button ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-19 18:29:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									list_select_button - > set_toggle_mode ( true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-14 09:40:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									list_select_button - > connect ( SceneStringName ( pressed ) ,  callable_mp ( this ,  & CanvasItemEditor : : _button_tool_select ) . bind ( TOOL_LIST_SELECT ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-25 12:42:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									list_select_button - > set_tooltip_text ( TTR ( " Show list of selectable nodes at position clicked. " ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-12-13 17:16:13 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-19 20:49:04 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									pivot_button  =  memnew ( Button ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-12-05 17:13:20 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									pivot_button - > set_theme_type_variation ( SceneStringName ( FlatButton ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 04:00:25 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									main_menu_hbox - > add_child ( pivot_button ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-19 18:29:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									pivot_button - > set_toggle_mode ( true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-14 09:40:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									pivot_button - > connect ( SceneStringName ( pressed ) ,  callable_mp ( this ,  & CanvasItemEditor : : _button_tool_select ) . bind ( TOOL_EDIT_PIVOT ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-25 16:34:32 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									pivot_button - > set_tooltip_text ( TTR ( " Click to change object's pivot. " )  +  " \n "  +  TTR ( " Shift: Set temporary pivot. " )  +  " \n "  +  TTR ( " Click this button while holding Shift to put the temporary pivot in the center of the selected nodes. " ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-12-28 09:38:15 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-19 20:49:04 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									pan_button  =  memnew ( Button ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-12-05 17:13:20 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									pan_button - > set_theme_type_variation ( SceneStringName ( FlatButton ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 04:00:25 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									main_menu_hbox - > add_child ( pan_button ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-19 18:29:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									pan_button - > set_toggle_mode ( true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-14 09:40:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									pan_button - > connect ( SceneStringName ( pressed ) ,  callable_mp ( this ,  & CanvasItemEditor : : _button_tool_select ) . bind ( TOOL_PAN ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-18 19:07:44 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									pan_button - > set_shortcut ( ED_SHORTCUT ( " canvas_item_editor/pan_mode " ,  TTRC ( " Pan Mode " ) ,  Key : : G ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-17 11:40:00 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									pan_button - > set_shortcut_context ( this ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-18 19:07:44 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									pan_button - > set_tooltip_text ( TTRC ( " You can also use Pan View shortcut (Space by default) to pan in any mode. " ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-05-02 19:39:12 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-19 20:49:04 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									ruler_button  =  memnew ( Button ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-12-05 17:13:20 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									ruler_button - > set_theme_type_variation ( SceneStringName ( FlatButton ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 04:00:25 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									main_menu_hbox - > add_child ( ruler_button ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-08-30 22:49:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									ruler_button - > set_toggle_mode ( true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-14 09:40:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									ruler_button - > connect ( SceneStringName ( pressed ) ,  callable_mp ( this ,  & CanvasItemEditor : : _button_tool_select ) . bind ( TOOL_RULER ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-18 19:07:44 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									ruler_button - > set_shortcut ( ED_SHORTCUT ( " canvas_item_editor/ruler_mode " ,  TTRC ( " Ruler Mode " ) ,  Key : : R ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-17 11:40:00 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									ruler_button - > set_shortcut_context ( this ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-18 19:07:44 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									ruler_button - > set_tooltip_text ( TTRC ( " Ruler Mode " ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-08-30 22:49:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 04:00:25 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									main_menu_hbox - > add_child ( memnew ( VSeparator ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-05-02 19:39:12 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-19 20:49:04 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									smart_snap_button  =  memnew ( Button ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-12-05 17:13:20 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									smart_snap_button - > set_theme_type_variation ( SceneStringName ( FlatButton ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 04:00:25 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									main_menu_hbox - > add_child ( smart_snap_button ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-10 19:41:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									smart_snap_button - > set_toggle_mode ( true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-01 13:15:13 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									smart_snap_button - > connect ( SceneStringName ( toggled ) ,  callable_mp ( this ,  & CanvasItemEditor : : _button_toggle_smart_snap ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-18 19:07:44 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									smart_snap_button - > set_tooltip_text ( TTRC ( " Toggle smart snapping. " ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									smart_snap_button - > set_shortcut ( ED_SHORTCUT ( " canvas_item_editor/use_smart_snap " ,  TTRC ( " Use Smart Snap " ) ,  KeyModifierMask : : SHIFT  |  Key : : S ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-17 11:40:00 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									smart_snap_button - > set_shortcut_context ( this ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-10 19:41:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-19 20:49:04 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									grid_snap_button  =  memnew ( Button ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-12-05 17:13:20 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									grid_snap_button - > set_theme_type_variation ( SceneStringName ( FlatButton ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 04:00:25 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									main_menu_hbox - > add_child ( grid_snap_button ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-10 19:41:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									grid_snap_button - > set_toggle_mode ( true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-01 13:15:13 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									grid_snap_button - > connect ( SceneStringName ( toggled ) ,  callable_mp ( this ,  & CanvasItemEditor : : _button_toggle_grid_snap ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-18 19:07:44 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									grid_snap_button - > set_tooltip_text ( TTRC ( " Toggle grid snapping. " ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									grid_snap_button - > set_shortcut ( ED_SHORTCUT ( " canvas_item_editor/use_grid_snap " ,  TTRC ( " Use Grid Snap " ) ,  KeyModifierMask : : SHIFT  |  Key : : G ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-17 11:40:00 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									grid_snap_button - > set_shortcut_context ( this ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-17 22:52:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									snap_config_menu  =  memnew ( MenuButton ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-19 18:03:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									snap_config_menu - > set_flat ( false ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									snap_config_menu - > set_theme_type_variation ( " FlatMenuButton " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-17 11:40:00 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									snap_config_menu - > set_shortcut_context ( this ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 04:00:25 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									main_menu_hbox - > add_child ( snap_config_menu ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-17 22:52:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									snap_config_menu - > set_h_size_flags ( SIZE_SHRINK_END ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-25 12:42:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									snap_config_menu - > set_tooltip_text ( TTR ( " Snapping Options " ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-20 15:52:01 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									snap_config_menu - > set_switch_on_hover ( true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-17 22:52:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									PopupMenu  * p  =  snap_config_menu - > get_popup ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-14 14:13:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									p - > connect ( SceneStringName ( id_pressed ) ,  callable_mp ( this ,  & CanvasItemEditor : : _popup_callback ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-17 22:52:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									p - > set_hide_on_checkable_item_selection ( false ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-18 19:07:44 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									p - > add_check_shortcut ( ED_SHORTCUT ( " canvas_item_editor/use_rotation_snap " ,  TTRC ( " Use Rotation Snap " ) ) ,  SNAP_USE_ROTATION ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									p - > add_check_shortcut ( ED_SHORTCUT ( " canvas_item_editor/use_scale_snap " ,  TTRC ( " Use Scale Snap " ) ) ,  SNAP_USE_SCALE ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									p - > add_check_shortcut ( ED_SHORTCUT ( " canvas_item_editor/snap_relative " ,  TTRC ( " Snap Relative " ) ) ,  SNAP_RELATIVE ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									p - > add_check_shortcut ( ED_SHORTCUT ( " canvas_item_editor/use_pixel_snap " ,  TTRC ( " Use Pixel Snap " ) ) ,  SNAP_USE_PIXEL ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-08-12 22:23:00 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-09-17 22:52:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									smartsnap_config_popup  =  memnew ( PopupMenu ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-14 14:13:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									smartsnap_config_popup - > connect ( SceneStringName ( id_pressed ) ,  callable_mp ( this ,  & CanvasItemEditor : : _popup_callback ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-17 22:52:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									smartsnap_config_popup - > set_hide_on_checkable_item_selection ( false ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-18 19:07:44 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									smartsnap_config_popup - > add_check_shortcut ( ED_SHORTCUT ( " canvas_item_editor/snap_node_parent " ,  TTRC ( " Snap to Parent " ) ) ,  SNAP_USE_NODE_PARENT ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									smartsnap_config_popup - > add_check_shortcut ( ED_SHORTCUT ( " canvas_item_editor/snap_node_anchors " ,  TTRC ( " Snap to Node Anchor " ) ) ,  SNAP_USE_NODE_ANCHORS ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									smartsnap_config_popup - > add_check_shortcut ( ED_SHORTCUT ( " canvas_item_editor/snap_node_sides " ,  TTRC ( " Snap to Node Sides " ) ) ,  SNAP_USE_NODE_SIDES ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									smartsnap_config_popup - > add_check_shortcut ( ED_SHORTCUT ( " canvas_item_editor/snap_node_center " ,  TTRC ( " Snap to Node Center " ) ) ,  SNAP_USE_NODE_CENTER ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									smartsnap_config_popup - > add_check_shortcut ( ED_SHORTCUT ( " canvas_item_editor/snap_other_nodes " ,  TTRC ( " Snap to Other Nodes " ) ) ,  SNAP_USE_OTHER_NODES ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									smartsnap_config_popup - > add_check_shortcut ( ED_SHORTCUT ( " canvas_item_editor/snap_guides " ,  TTRC ( " Snap to Guides " ) ) ,  SNAP_USE_GUIDES ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-28 17:33:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									p - > add_submenu_node_item ( TTR ( " Smart Snapping " ) ,  smartsnap_config_popup ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									p - > add_separator ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-18 19:07:44 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									p - > add_shortcut ( ED_SHORTCUT ( " canvas_item_editor/configure_snap " ,  TTRC ( " Configure Snap... " ) ) ,  SNAP_CONFIGURE ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-17 22:52:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 04:00:25 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									main_menu_hbox - > add_child ( memnew ( VSeparator ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-17 22:52:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-19 20:49:04 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									lock_button  =  memnew ( Button ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-12-05 17:13:20 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									lock_button - > set_theme_type_variation ( SceneStringName ( FlatButton ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 04:00:25 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									main_menu_hbox - > add_child ( lock_button ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-14 09:40:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									lock_button - > connect ( SceneStringName ( pressed ) ,  callable_mp ( this ,  & CanvasItemEditor : : _popup_callback ) . bind ( LOCK_SELECTED ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-18 19:07:44 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									lock_button - > set_tooltip_text ( TTRC ( " Lock selected node, preventing selection and movement. " ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-30 23:09:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// Define the shortcut globally (without a context) so that it works if the Scene tree dock is currently focused.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-21 22:11:50 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									lock_button - > set_shortcut ( ED_GET_SHORTCUT ( " editor/lock_selected_nodes " ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-19 20:49:04 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									unlock_button  =  memnew ( Button ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-12-05 17:13:20 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									unlock_button - > set_theme_type_variation ( SceneStringName ( FlatButton ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 04:00:25 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									main_menu_hbox - > add_child ( unlock_button ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-14 09:40:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									unlock_button - > connect ( SceneStringName ( pressed ) ,  callable_mp ( this ,  & CanvasItemEditor : : _popup_callback ) . bind ( UNLOCK_SELECTED ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-18 19:07:44 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									unlock_button - > set_tooltip_text ( TTRC ( " Unlock selected node, allowing selection and movement. " ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-30 23:09:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// Define the shortcut globally (without a context) so that it works if the Scene tree dock is currently focused.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-21 22:11:50 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									unlock_button - > set_shortcut ( ED_GET_SHORTCUT ( " editor/unlock_selected_nodes " ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-19 20:49:04 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									group_button  =  memnew ( Button ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-12-05 17:13:20 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									group_button - > set_theme_type_variation ( SceneStringName ( FlatButton ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 04:00:25 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									main_menu_hbox - > add_child ( group_button ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-14 09:40:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									group_button - > connect ( SceneStringName ( pressed ) ,  callable_mp ( this ,  & CanvasItemEditor : : _popup_callback ) . bind ( GROUP_SELECTED ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-18 19:07:44 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									group_button - > set_tooltip_text ( TTRC ( " Groups the selected node with its children. This causes the parent to be selected when any child node is clicked in 2D and 3D view. " ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-30 23:09:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// Define the shortcut globally (without a context) so that it works if the Scene tree dock is currently focused.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-21 22:11:50 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									group_button - > set_shortcut ( ED_GET_SHORTCUT ( " editor/group_selected_nodes " ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-19 20:49:04 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									ungroup_button  =  memnew ( Button ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-12-05 17:13:20 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									ungroup_button - > set_theme_type_variation ( SceneStringName ( FlatButton ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 04:00:25 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									main_menu_hbox - > add_child ( ungroup_button ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-14 09:40:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									ungroup_button - > connect ( SceneStringName ( pressed ) ,  callable_mp ( this ,  & CanvasItemEditor : : _popup_callback ) . bind ( UNGROUP_SELECTED ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-18 19:07:44 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									ungroup_button - > set_tooltip_text ( TTRC ( " Ungroups the selected node from its children. Child nodes will be individual items in 2D and 3D view. " ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-30 23:09:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// Define the shortcut globally (without a context) so that it works if the Scene tree dock is currently focused.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-21 22:11:50 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									ungroup_button - > set_shortcut ( ED_GET_SHORTCUT ( " editor/ungroup_selected_nodes " ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 04:00:25 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									main_menu_hbox - > add_child ( memnew ( VSeparator ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-09-17 22:52:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									skeleton_menu  =  memnew ( MenuButton ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-19 18:03:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									skeleton_menu - > set_flat ( false ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									skeleton_menu - > set_theme_type_variation ( " FlatMenuButton " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-17 11:40:00 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									skeleton_menu - > set_shortcut_context ( this ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 04:00:25 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									main_menu_hbox - > add_child ( skeleton_menu ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-25 12:42:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									skeleton_menu - > set_tooltip_text ( TTR ( " Skeleton Options " ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-20 15:52:01 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									skeleton_menu - > set_switch_on_hover ( true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-09-17 22:52:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									p  =  skeleton_menu - > get_popup ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-04-14 14:49:50 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									p - > set_hide_on_checkable_item_selection ( false ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-18 19:07:44 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									p - > add_shortcut ( ED_SHORTCUT ( " canvas_item_editor/skeleton_show_bones " ,  TTRC ( " Show Bones " ) ) ,  SKELETON_SHOW_BONES ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-05-04 16:46:32 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									p - > add_separator ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-18 19:07:44 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									p - > add_shortcut ( ED_SHORTCUT ( " canvas_item_editor/skeleton_make_bones " ,  TTRC ( " Make Bone2D Node(s) from Node(s) " ) ,  KeyModifierMask : : CMD_OR_CTRL  |  KeyModifierMask : : SHIFT  |  Key : : B ) ,  SKELETON_MAKE_BONES ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-14 14:13:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									p - > connect ( SceneStringName ( id_pressed ) ,  callable_mp ( this ,  & CanvasItemEditor : : _popup_callback ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-17 22:52:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 04:00:25 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									main_menu_hbox - > add_child ( memnew ( VSeparator ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									view_menu  =  memnew ( MenuButton ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-19 18:03:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									view_menu - > set_flat ( false ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									view_menu - > set_theme_type_variation ( " FlatMenuButton " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-08 11:42:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// TRANSLATORS: Noun, name of the 2D/3D View menus.
 
							 
						 
					
						
							
								
									
										
										
										
											2016-05-03 22:25:37 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									view_menu - > set_text ( TTR ( " View " ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-08 11:42:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									view_menu - > set_switch_on_hover ( true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									view_menu - > set_shortcut_context ( this ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 04:00:25 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									main_menu_hbox - > add_child ( view_menu ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									p  =  view_menu - > get_popup ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-23 12:55:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									p - > connect ( SceneStringName ( id_pressed ) ,  callable_mp ( this ,  & CanvasItemEditor : : _popup_callback ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									p - > connect ( " about_to_popup " ,  callable_mp ( this ,  & CanvasItemEditor : : _prepare_view_menu ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-20 15:52:01 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									p - > set_hide_on_checkable_item_selection ( false ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-09 17:53:39 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									grid_menu  =  memnew ( PopupMenu ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									grid_menu - > connect ( " about_to_popup " ,  callable_mp ( this ,  & CanvasItemEditor : : _prepare_grid_menu ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-14 14:13:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									grid_menu - > connect ( SceneStringName ( id_pressed ) ,  callable_mp ( this ,  & CanvasItemEditor : : _on_grid_menu_id_pressed ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-09 17:53:39 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									grid_menu - > add_radio_check_item ( TTR ( " Show " ) ,  GRID_VISIBILITY_SHOW ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									grid_menu - > add_radio_check_item ( TTR ( " Show When Snapping " ) ,  GRID_VISIBILITY_SHOW_WHEN_SNAPPING ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									grid_menu - > add_radio_check_item ( TTR ( " Hide " ) ,  GRID_VISIBILITY_HIDE ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									grid_menu - > add_separator ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-18 19:07:44 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									grid_menu - > add_shortcut ( ED_SHORTCUT ( " canvas_item_editor/toggle_grid " ,  TTRC ( " Toggle Grid " ) ,  KeyModifierMask : : CMD_OR_CTRL  |  Key : : APOSTROPHE ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-28 17:33:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									p - > add_submenu_node_item ( TTR ( " Grid " ) ,  grid_menu ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-09 17:53:39 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-10-18 19:07:44 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									p - > add_check_shortcut ( ED_SHORTCUT ( " canvas_item_editor/show_helpers " ,  TTRC ( " Show Helpers " ) ,  Key : : H ) ,  SHOW_HELPERS ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									p - > add_check_shortcut ( ED_SHORTCUT ( " canvas_item_editor/show_rulers " ,  TTRC ( " Show Rulers " ) ) ,  SHOW_RULERS ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									p - > add_check_shortcut ( ED_SHORTCUT ( " canvas_item_editor/show_guides " ,  TTRC ( " Show Guides " ) ,  Key : : Y ) ,  SHOW_GUIDES ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									p - > add_check_shortcut ( ED_SHORTCUT ( " canvas_item_editor/show_origin " ,  TTRC ( " Show Origin " ) ) ,  SHOW_ORIGIN ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									p - > add_check_shortcut ( ED_SHORTCUT ( " canvas_item_editor/show_viewport " ,  TTRC ( " Show Viewport " ) ) ,  SHOW_VIEWPORT ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-25 12:41:37 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									p - > add_separator ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									gizmos_menu  =  memnew ( PopupMenu ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									gizmos_menu - > set_name ( " GizmosMenu " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-14 14:13:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									gizmos_menu - > connect ( SceneStringName ( id_pressed ) ,  callable_mp ( this ,  & CanvasItemEditor : : _popup_callback ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-25 12:41:37 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									gizmos_menu - > set_hide_on_checkable_item_selection ( false ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-18 19:07:44 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									gizmos_menu - > add_check_shortcut ( ED_SHORTCUT ( " canvas_item_editor/show_position_gizmos " ,  TTRC ( " Position " ) ) ,  SHOW_POSITION_GIZMOS ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									gizmos_menu - > add_check_shortcut ( ED_SHORTCUT ( " canvas_item_editor/show_lock_gizmos " ,  TTRC ( " Lock " ) ) ,  SHOW_LOCK_GIZMOS ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									gizmos_menu - > add_check_shortcut ( ED_SHORTCUT ( " canvas_item_editor/show_group_gizmos " ,  TTRC ( " Group " ) ) ,  SHOW_GROUP_GIZMOS ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									gizmos_menu - > add_check_shortcut ( ED_SHORTCUT ( " canvas_item_editor/show_transformation_gizmos " ,  TTRC ( " Transformation " ) ) ,  SHOW_TRANSFORMATION_GIZMOS ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-25 12:41:37 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									p - > add_child ( gizmos_menu ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									p - > add_submenu_item ( TTR ( " Gizmos " ) ,  " GizmosMenu " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-20 02:41:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-07-06 11:49:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									p - > add_separator ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-18 19:07:44 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									p - > add_shortcut ( ED_SHORTCUT ( " canvas_item_editor/center_selection " ,  TTRC ( " Center Selection " ) ,  Key : : F ) ,  VIEW_CENTER_TO_SELECTION ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									p - > add_shortcut ( ED_SHORTCUT ( " canvas_item_editor/frame_selection " ,  TTRC ( " Frame Selection " ) ,  KeyModifierMask : : SHIFT  |  Key : : F ) ,  VIEW_FRAME_TO_SELECTION ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									p - > add_shortcut ( ED_SHORTCUT ( " canvas_item_editor/clear_guides " ,  TTRC ( " Clear Guides " ) ) ,  CLEAR_GUIDES ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-05 10:24:54 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									p - > add_separator ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-18 19:07:44 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									p - > add_check_shortcut ( ED_SHORTCUT ( " canvas_item_editor/preview_canvas_scale " ,  TTRC ( " Preview Canvas Scale " ) ) ,  PREVIEW_CANVAS_SCALE ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-06 16:11:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									theme_menu  =  memnew ( PopupMenu ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-14 14:13:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									theme_menu - > connect ( SceneStringName ( id_pressed ) ,  callable_mp ( this ,  & CanvasItemEditor : : _switch_theme_preview ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-06 16:11:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									theme_menu - > add_radio_check_item ( TTR ( " Project theme " ) ,  THEME_PREVIEW_PROJECT ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									theme_menu - > add_radio_check_item ( TTR ( " Editor theme " ) ,  THEME_PREVIEW_EDITOR ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									theme_menu - > add_radio_check_item ( TTR ( " Default theme " ) ,  THEME_PREVIEW_DEFAULT ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-28 17:33:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									p - > add_submenu_node_item ( TTR ( " Preview Theme " ) ,  theme_menu ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-06 16:11:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									theme_preview  =  ( ThemePreviewMode ) ( int ) EditorSettings : : get_singleton ( ) - > get_project_metadata ( " 2d_editor " ,  " theme_preview " ,  THEME_PREVIEW_PROJECT ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									for  ( int  i  =  0 ;  i  <  THEME_PREVIEW_MAX ;  i + + )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										theme_menu - > set_item_checked ( i ,  i  = =  theme_preview ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 04:00:25 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									main_menu_hbox - > add_child ( memnew ( VSeparator ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-03 20:07:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 04:00:25 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// Contextual toolbars.
 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-11 23:50:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									context_toolbar_panel  =  memnew ( PanelContainer ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									context_toolbar_hbox  =  memnew ( HBoxContainer ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									context_toolbar_panel - > add_child ( context_toolbar_hbox ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									main_flow - > add_child ( context_toolbar_panel ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-03 20:07:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-08 23:53:41 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// Animation controls.
 
							 
						 
					
						
							
								
									
										
										
										
											2014-07-06 11:49:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									animation_hb  =  memnew ( HBoxContainer ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-11 23:50:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									add_control_to_menu_panel ( animation_hb ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-07-06 11:49:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									animation_hb - > hide ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-10-12 13:59:25 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									key_loc_button  =  memnew ( Button ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-12-05 17:13:20 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									key_loc_button - > set_theme_type_variation ( SceneStringName ( FlatButton ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-07-06 11:49:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									key_loc_button - > set_toggle_mode ( true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									key_loc_button - > set_pressed ( true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									key_loc_button - > set_focus_mode ( FOCUS_NONE ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-14 09:40:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									key_loc_button - > connect ( SceneStringName ( pressed ) ,  callable_mp ( this ,  & CanvasItemEditor : : _popup_callback ) . bind ( ANIM_INSERT_POS ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-25 12:42:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									key_loc_button - > set_tooltip_text ( TTR ( " Translation mask for inserting keys. " ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-07-06 11:49:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									animation_hb - > add_child ( key_loc_button ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-17 11:40:00 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-10-12 13:59:25 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									key_rot_button  =  memnew ( Button ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-12-05 17:13:20 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									key_rot_button - > set_theme_type_variation ( SceneStringName ( FlatButton ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-07-06 11:49:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									key_rot_button - > set_toggle_mode ( true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									key_rot_button - > set_pressed ( true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									key_rot_button - > set_focus_mode ( FOCUS_NONE ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-14 09:40:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									key_rot_button - > connect ( SceneStringName ( pressed ) ,  callable_mp ( this ,  & CanvasItemEditor : : _popup_callback ) . bind ( ANIM_INSERT_ROT ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-25 12:42:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									key_rot_button - > set_tooltip_text ( TTR ( " Rotation mask for inserting keys. " ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-07-06 11:49:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									animation_hb - > add_child ( key_rot_button ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-17 11:40:00 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-10-12 13:59:25 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									key_scale_button  =  memnew ( Button ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-12-05 17:13:20 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									key_scale_button - > set_theme_type_variation ( SceneStringName ( FlatButton ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-07-06 11:49:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									key_scale_button - > set_toggle_mode ( true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									key_scale_button - > set_focus_mode ( FOCUS_NONE ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-14 09:40:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									key_scale_button - > connect ( SceneStringName ( pressed ) ,  callable_mp ( this ,  & CanvasItemEditor : : _popup_callback ) . bind ( ANIM_INSERT_SCALE ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-25 12:42:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									key_scale_button - > set_tooltip_text ( TTR ( " Scale mask for inserting keys. " ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-07-06 11:49:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									animation_hb - > add_child ( key_scale_button ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-17 11:40:00 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-05-03 06:02:06 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									key_insert_button  =  memnew ( Button ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-12-05 17:13:20 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									key_insert_button - > set_theme_type_variation ( SceneStringName ( FlatButton ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-07-06 11:49:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									key_insert_button - > set_focus_mode ( FOCUS_NONE ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-14 09:40:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									key_insert_button - > connect ( SceneStringName ( pressed ) ,  callable_mp ( this ,  & CanvasItemEditor : : _popup_callback ) . bind ( ANIM_INSERT_KEY ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-18 19:07:44 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									key_insert_button - > set_tooltip_text ( TTRC ( " Insert keys (based on mask). " ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									key_insert_button - > set_shortcut ( ED_SHORTCUT ( " canvas_item_editor/anim_insert_key " ,  TTRC ( " Insert Key " ) ,  Key : : INSERT ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-17 11:40:00 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									key_insert_button - > set_shortcut_context ( this ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-07-06 11:49:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									animation_hb - > add_child ( key_insert_button ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-17 11:40:00 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-04-15 00:49:03 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									key_auto_insert_button  =  memnew ( Button ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-12-05 17:13:20 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									key_auto_insert_button - > set_theme_type_variation ( SceneStringName ( FlatButton ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-15 00:49:03 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									key_auto_insert_button - > set_toggle_mode ( true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									key_auto_insert_button - > set_focus_mode ( FOCUS_NONE ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-18 19:07:44 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									key_auto_insert_button - > set_tooltip_text ( TTRC ( " Auto insert keys when objects are translated, rotated or scaled (based on mask). \n Keys are only added to existing tracks, no new tracks will be created. \n Keys must be inserted manually for the first time. " ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									key_auto_insert_button - > set_shortcut ( ED_SHORTCUT ( " canvas_item_editor/anim_auto_insert_key " ,  TTRC ( " Auto Insert Key " ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-17 11:40:00 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									key_auto_insert_button - > set_shortcut_context ( this ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-15 00:49:03 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									animation_hb - > add_child ( key_auto_insert_button ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-07-06 11:49:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									animation_menu  =  memnew ( MenuButton ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-19 18:03:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									animation_menu - > set_flat ( false ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									animation_menu - > set_theme_type_variation ( " FlatMenuButton " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-17 11:40:00 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									animation_menu - > set_shortcut_context ( this ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-25 12:42:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									animation_menu - > set_tooltip_text ( TTR ( " Animation Key and Pose Options " ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-07-06 11:49:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									animation_hb - > add_child ( animation_menu ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-14 14:13:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									animation_menu - > get_popup ( ) - > connect ( SceneStringName ( id_pressed ) ,  callable_mp ( this ,  & CanvasItemEditor : : _popup_callback ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-20 15:52:01 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									animation_menu - > set_switch_on_hover ( true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									p  =  animation_menu - > get_popup ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-06-29 15:02:26 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									p - > add_shortcut ( ED_GET_SHORTCUT ( " canvas_item_editor/anim_insert_key " ) ,  ANIM_INSERT_KEY ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-18 19:07:44 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									p - > add_shortcut ( ED_SHORTCUT ( " canvas_item_editor/anim_insert_key_existing_tracks " ,  TTRC ( " Insert Key (Existing Tracks) " ) ,  KeyModifierMask : : CMD_OR_CTRL  +  Key : : INSERT ) ,  ANIM_INSERT_KEY_EXISTING ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									p - > add_separator ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-18 19:07:44 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									p - > add_shortcut ( ED_SHORTCUT ( " canvas_item_editor/anim_copy_pose " ,  TTRC ( " Copy Pose " ) ) ,  ANIM_COPY_POSE ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									p - > add_shortcut ( ED_SHORTCUT ( " canvas_item_editor/anim_paste_pose " ,  TTRC ( " Paste Pose " ) ) ,  ANIM_PASTE_POSE ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									p - > add_shortcut ( ED_SHORTCUT ( " canvas_item_editor/anim_clear_pose " ,  TTRC ( " Clear Pose " ) ,  KeyModifierMask : : SHIFT  |  Key : : K ) ,  ANIM_CLEAR_POSE ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-10-18 13:31:44 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									snap_dialog  =  memnew ( SnapDialog ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-14 14:28:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									snap_dialog - > connect ( SceneStringName ( confirmed ) ,  callable_mp ( this ,  & CanvasItemEditor : : _snap_changed ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-02-15 18:00:55 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									add_child ( snap_dialog ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-06-09 15:21:41 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									select_sb . instantiate ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-11-04 22:39:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									selection_menu  =  memnew ( PopupMenu ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									add_child ( selection_menu ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-12 09:37:40 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									selection_menu - > set_min_size ( Vector2 ( 100 ,  0 ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-23 18:29:45 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									selection_menu - > set_auto_translate_mode ( AUTO_TRANSLATE_MODE_DISABLED ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-14 14:13:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									selection_menu - > connect ( SceneStringName ( id_pressed ) ,  callable_mp ( this ,  & CanvasItemEditor : : _selection_result_pressed ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-28 22:56:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									selection_menu - > connect ( " popup_hide " ,  callable_mp ( this ,  & CanvasItemEditor : : _selection_menu_hide ) ,  CONNECT_DEFERRED ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-11-04 22:39:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-08-25 01:32:58 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									add_node_menu  =  memnew ( PopupMenu ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									add_child ( add_node_menu ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-14 14:13:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									add_node_menu - > connect ( SceneStringName ( id_pressed ) ,  callable_mp ( this ,  & CanvasItemEditor : : _add_node_pressed ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-25 01:32:58 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-10-18 19:07:44 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									multiply_grid_step_shortcut  =  ED_SHORTCUT ( " canvas_item_editor/multiply_grid_step " ,  TTRC ( " Multiply grid step by 2 " ) ,  Key : : KP_MULTIPLY ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									divide_grid_step_shortcut  =  ED_SHORTCUT ( " canvas_item_editor/divide_grid_step " ,  TTRC ( " Divide grid step by 2 " ) ,  Key : : KP_DIVIDE ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-31 21:54:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-09-17 22:52:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									skeleton_menu - > get_popup ( ) - > set_item_checked ( skeleton_menu - > get_popup ( ) - > get_item_index ( SKELETON_SHOW_BONES ) ,  true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-08 23:53:41 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									// Store the singleton instance.
 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									singleton  =  this ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-02-09 16:09:29 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-11 15:59:52 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									set_process_shortcut_input ( true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-08 00:01:29 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									clear ( ) ;  // Make sure values are initialized.
 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-07 08:58:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-04-01 15:18:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// Update the menus' checkboxes.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-27 13:29:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									callable_mp ( this ,  & CanvasItemEditor : : set_state ) . call_deferred ( get_state ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-04-02 01:20:12 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								CanvasItemEditor  * CanvasItemEditor : : singleton  =  nullptr ;  
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditorPlugin : : edit ( Object  * p_object )  {  
						 
					
						
							
								
									
										
										
										
											2017-08-24 22:58:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									canvas_item_editor - > edit ( Object : : cast_to < CanvasItem > ( p_object ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								bool  CanvasItemEditorPlugin : : handles ( Object  * p_object )  const  {  
						 
					
						
							
								
									
										
										
										
											2017-01-02 23:03:46 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									return  p_object - > is_class ( " CanvasItem " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditorPlugin : : make_visible ( bool  p_visible )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( p_visible )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										canvas_item_editor - > show ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-02 19:14:48 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										canvas_item_editor - > set_process ( true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 10:36:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										RenderingServer : : get_singleton ( ) - > viewport_set_disable_2d ( EditorNode : : get_singleton ( ) - > get_scene_root ( ) - > get_viewport_rid ( ) ,  false ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-29 16:04:39 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										RenderingServer : : get_singleton ( ) - > viewport_set_environment_mode ( EditorNode : : get_singleton ( ) - > get_scene_root ( ) - > get_viewport_rid ( ) ,  RS : : VIEWPORT_ENVIRONMENT_ENABLED ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										canvas_item_editor - > hide ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-02 19:14:48 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										canvas_item_editor - > set_process ( false ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 10:36:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										RenderingServer : : get_singleton ( ) - > viewport_set_disable_2d ( EditorNode : : get_singleton ( ) - > get_scene_root ( ) - > get_viewport_rid ( ) ,  true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-29 16:04:39 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										RenderingServer : : get_singleton ( ) - > viewport_set_environment_mode ( EditorNode : : get_singleton ( ) - > get_scene_root ( ) - > get_viewport_rid ( ) ,  RS : : VIEWPORT_ENVIRONMENT_DISABLED ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								Dictionary  CanvasItemEditorPlugin : : get_state ( )  const  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return  canvas_item_editor - > get_state ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2020-05-14 14:29:06 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditorPlugin : : set_state ( const  Dictionary  & p_state )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									canvas_item_editor - > set_state ( p_state ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-03-09 21:12:26 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditorPlugin : : clear ( )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									canvas_item_editor - > clear ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-10-14 00:22:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditorPlugin : : _notification ( int  p_what )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									switch  ( p_what )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case  NOTIFICATION_ENTER_TREE :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											connect ( " scene_changed " ,  callable_mp ( ( CanvasItem  * ) canvas_item_editor - > get_viewport_control ( ) ,  & CanvasItem : : queue_redraw ) . unbind ( 1 ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											connect ( " scene_closed " ,  callable_mp ( ( CanvasItem  * ) canvas_item_editor - > get_viewport_control ( ) ,  & CanvasItem : : queue_redraw ) . unbind ( 1 ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}  break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 10:36:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								CanvasItemEditorPlugin : : CanvasItemEditorPlugin ( )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									canvas_item_editor  =  memnew ( CanvasItemEditor ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-02-08 13:01:54 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									canvas_item_editor - > set_v_size_flags ( Control : : SIZE_EXPAND_FILL ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-19 18:08:31 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									EditorNode : : get_singleton ( ) - > get_editor_main_screen ( ) - > get_control ( ) - > add_child ( canvas_item_editor ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-18 19:02:57 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									canvas_item_editor - > set_anchors_and_offsets_preset ( Control : : PRESET_FULL_RECT ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									canvas_item_editor - > hide ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-10-26 04:27:24 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditorViewport : : _on_mouse_exit ( )  {  
						 
					
						
							
								
									
										
										
										
											2024-05-16 10:13:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( ! texture_node_type_selector - > is_visible ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-26 04:27:24 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										_remove_preview ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 10:13:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditorViewport : : _on_select_texture_node_type ( Object  * selected )  {  
						 
					
						
							
								
									
										
										
										
											2017-08-24 22:58:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									CheckBox  * check  =  Object : : cast_to < CheckBox > ( selected ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-26 04:27:24 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									String  type  =  check - > get_text ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 10:13:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									texture_node_type_selector - > set_title ( vformat ( TTR ( " Add %s " ) ,  type ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-26 04:27:24 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									label - > set_text ( vformat ( TTR ( " Adding %s... " ) ,  type ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-12 10:50:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditorViewport : : _on_change_type_confirmed ( )  {  
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( ! button_group - > get_pressed_button ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-01-10 01:04:31 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2017-01-10 01:04:31 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-08-24 22:58:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									CheckBox  * check  =  Object : : cast_to < CheckBox > ( button_group - > get_pressed_button ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-29 02:46:38 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									default_texture_node_type  =  check - > get_text ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-26 04:27:24 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									_perform_drop_data ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 10:13:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									texture_node_type_selector - > hide ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-26 04:27:24 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-12 10:50:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditorViewport : : _on_change_type_closed ( )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									_remove_preview ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-10-26 04:27:24 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditorViewport : : _create_preview ( const  Vector < String >  & files )  const  {  
						 
					
						
							
								
									
										
										
										
											2018-01-09 01:05:15 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									bool  add_preview  =  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-26 04:27:24 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									for  ( int  i  =  0 ;  i  <  files . size ( ) ;  i + + )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-13 11:06:14 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Ref < Resource >  res  =  ResourceLoader : : load ( files [ i ] ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 10:13:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										ERR_CONTINUE ( res . is_null ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										Ref < Texture2D >  texture  =  res ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if  ( texture . is_valid ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											Sprite2D  * sprite  =  memnew ( Sprite2D ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											sprite - > set_texture ( texture ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											sprite - > set_modulate ( Color ( 1 ,  1 ,  1 ,  0.7f ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											preview_node - > add_child ( sprite ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											add_preview  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										Ref < PackedScene >  scene  =  res ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if  ( scene . is_valid ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											Node  * instance  =  scene - > instantiate ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if  ( instance )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												preview_node - > add_child ( instance ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-26 04:27:24 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-09 01:05:15 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											add_preview  =  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-26 04:27:24 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 10:13:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										Ref < AudioStream >  audio  =  res ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if  ( audio . is_valid ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											Sprite2D  * sprite  =  memnew ( Sprite2D ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											sprite - > set_texture ( get_editor_theme_icon ( SNAME ( " AudioStreamPlayer2D " ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											sprite - > set_modulate ( Color ( 1 ,  1 ,  1 ,  0.7f ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											sprite - > set_position ( Vector2 ( 0 ,  - sprite - > get_texture ( ) - > get_size ( ) . height )  *  EDSCALE ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											preview_node - > add_child ( sprite ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											add_preview  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-26 04:27:24 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-09 01:05:15 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( add_preview )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 10:36:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										EditorNode : : get_singleton ( ) - > get_scene_root ( ) - > add_child ( preview_node ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-26 04:27:24 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditorViewport : : _remove_preview ( )  {  
						 
					
						
							
								
									
										
										
										
											2024-03-05 22:45:39 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( ! canvas_item_editor - > message . is_empty ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-25 13:36:42 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										canvas_item_editor - > message  =  " " ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-05 22:45:39 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										canvas_item_editor - > update_viewport ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( preview_node - > get_parent ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-02 20:47:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										for  ( int  i  =  preview_node - > get_child_count ( )  -  1 ;  i  > =  0 ;  i - - )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											Node  * node  =  preview_node - > get_child ( i ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-24 22:07:02 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											node - > queue_free ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-02 20:47:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											preview_node - > remove_child ( node ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-26 04:27:24 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 10:36:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										EditorNode : : get_singleton ( ) - > get_scene_root ( ) - > remove_child ( preview_node ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-02 20:47:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-10-26 04:27:24 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										label - > hide ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										label_desc - > hide ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-03-05 22:45:39 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								bool  CanvasItemEditorViewport : : _cyclical_dependency_exists ( const  String  & p_target_scene_path ,  Node  * p_desired_node )  const  {  
						 
					
						
							
								
									
										
										
										
											2021-09-30 16:30:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( p_desired_node - > get_scene_file_path ( )  = =  p_target_scene_path )  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-26 04:27:24 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									int  childCount  =  p_desired_node - > get_child_count ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									for  ( int  i  =  0 ;  i  <  childCount ;  i + + )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										Node  * child  =  p_desired_node - > get_child ( i ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if  ( _cyclical_dependency_exists ( p_target_scene_path ,  child ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 10:13:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditorViewport : : _create_texture_node ( Node  * p_parent ,  Node  * p_child ,  const  String  & p_path ,  const  Point2  & p_point )  {  
						 
					
						
							
								
									
										
										
										
											2021-07-29 00:26:34 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// Adjust casing according to project setting. The file name is expected to be in snake_case, but will work for others.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 10:13:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									const  String  & node_name  =  Node : : adjust_name_casing ( p_path . get_file ( ) . get_basename ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( ! node_name . is_empty ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										p_child - > set_name ( node_name ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-29 00:26:34 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-12-23 23:53:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									EditorUndoRedoManager  * undo_redo  =  EditorUndoRedoManager : : get_singleton ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 10:13:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Ref < Texture2D >  texture  =  ResourceCache : : get_ref ( p_path ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-26 04:27:24 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 10:13:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( p_parent )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										undo_redo - > add_do_method ( p_parent ,  " add_child " ,  p_child ,  true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										undo_redo - > add_do_method ( p_child ,  " set_owner " ,  EditorNode : : get_singleton ( ) - > get_edited_scene ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										undo_redo - > add_do_reference ( p_child ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										undo_redo - > add_undo_method ( p_parent ,  " remove_child " ,  p_child ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-29 02:46:38 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									}  else  {  // If no parent is selected, set as root node of the scene.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 10:13:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										undo_redo - > add_do_method ( EditorNode : : get_singleton ( ) ,  " set_edited_scene " ,  p_child ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										undo_redo - > add_do_method ( p_child ,  " set_owner " ,  EditorNode : : get_singleton ( ) - > get_edited_scene ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										undo_redo - > add_do_reference ( p_child ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-29 12:10:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										undo_redo - > add_undo_method ( EditorNode : : get_singleton ( ) ,  " set_edited_scene " ,  ( Object  * ) nullptr ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-22 05:28:02 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-26 04:27:24 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 10:13:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( p_parent )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										String  new_name  =  p_parent - > validate_child_name ( p_child ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-07 02:52:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										EditorDebuggerNode  * ed  =  EditorDebuggerNode : : get_singleton ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 10:13:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										undo_redo - > add_do_method ( ed ,  " live_debug_create_node " ,  EditorNode : : get_singleton ( ) - > get_edited_scene ( ) - > get_path_to ( p_parent ) ,  p_child - > get_class ( ) ,  new_name ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										undo_redo - > add_undo_method ( ed ,  " live_debug_remove_node " ,  NodePath ( String ( EditorNode : : get_singleton ( ) - > get_edited_scene ( ) - > get_path_to ( p_parent ) )  +  " / "  +  new_name ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-22 05:28:02 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-26 04:27:24 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 10:13:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( Object : : cast_to < TouchScreenButton > ( p_child )  | |  Object : : cast_to < TextureButton > ( p_child ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										undo_redo - > add_do_property ( p_child ,  " texture_normal " ,  texture ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-29 02:46:38 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 10:13:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										undo_redo - > add_do_property ( p_child ,  " texture " ,  texture ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-26 04:27:24 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									// make visible for certain node type
 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 10:13:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( Object : : cast_to < Control > ( p_child ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-29 02:46:38 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Size2  texture_size  =  texture - > get_size ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 10:13:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										undo_redo - > add_do_property ( p_child ,  " size " ,  texture_size ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}  else  if  ( Object : : cast_to < Polygon2D > ( p_child ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-29 02:46:38 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Size2  texture_size  =  texture - > get_size ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-11 21:12:39 +05:45 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Vector < Vector2 >  list  =  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											Vector2 ( 0 ,  0 ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											Vector2 ( texture_size . width ,  0 ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											Vector2 ( texture_size . width ,  texture_size . height ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											Vector2 ( 0 ,  texture_size . height ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 10:13:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										undo_redo - > add_do_property ( p_child ,  " polygon " ,  list ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-26 04:27:24 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-11-16 16:55:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// Compute the global position
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Transform2D  xform  =  canvas_item_editor - > get_canvas_transform ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Point2  target_position  =  xform . affine_inverse ( ) . xform ( p_point ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-11-30 16:28:49 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// Adjust position for Control and TouchScreenButton
 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 10:13:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( Object : : cast_to < Control > ( p_child )  | |  Object : : cast_to < TouchScreenButton > ( p_child ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-30 16:28:49 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										target_position  - =  texture - > get_size ( )  /  2 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 10:13:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// There's nothing to be used as source position, so snapping will work as absolute if enabled.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									target_position  =  canvas_item_editor - > snap_point ( target_position ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									CanvasItem  * parent_ci  =  Object : : cast_to < CanvasItem > ( p_parent ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Point2  local_target_pos  =  parent_ci  ?  parent_ci - > get_global_transform ( ) . affine_inverse ( ) . xform ( target_position )  :  target_position ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									undo_redo - > add_do_method ( p_child ,  " set_position " ,  local_target_pos ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditorViewport : : _create_audio_node ( Node  * p_parent ,  const  String  & p_path ,  const  Point2  & p_point )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									AudioStreamPlayer2D  * child  =  memnew ( AudioStreamPlayer2D ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									child - > set_stream ( ResourceCache : : get_ref ( p_path ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									// Adjust casing according to project setting. The file name is expected to be in snake_case, but will work for others.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									const  String  & node_name  =  Node : : adjust_name_casing ( p_path . get_file ( ) . get_basename ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( ! node_name . is_empty ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										child - > set_name ( node_name ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									EditorUndoRedoManager  * undo_redo  =  EditorUndoRedoManager : : get_singleton ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( p_parent )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										undo_redo - > add_do_method ( p_parent ,  " add_child " ,  child ,  true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										undo_redo - > add_do_method ( child ,  " set_owner " ,  EditorNode : : get_singleton ( ) - > get_edited_scene ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										undo_redo - > add_do_reference ( child ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										undo_redo - > add_undo_method ( p_parent ,  " remove_child " ,  child ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}  else  {  // If no parent is selected, set as root node of the scene.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										undo_redo - > add_do_method ( EditorNode : : get_singleton ( ) ,  " set_edited_scene " ,  child ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										undo_redo - > add_do_method ( child ,  " set_owner " ,  EditorNode : : get_singleton ( ) - > get_edited_scene ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										undo_redo - > add_do_reference ( child ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										undo_redo - > add_undo_method ( EditorNode : : get_singleton ( ) ,  " set_edited_scene " ,  ( Object  * ) nullptr ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( p_parent )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										String  new_name  =  p_parent - > validate_child_name ( child ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										EditorDebuggerNode  * ed  =  EditorDebuggerNode : : get_singleton ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										undo_redo - > add_do_method ( ed ,  " live_debug_create_node " ,  EditorNode : : get_singleton ( ) - > get_edited_scene ( ) - > get_path_to ( p_parent ) ,  child - > get_class ( ) ,  new_name ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										undo_redo - > add_undo_method ( ed ,  " live_debug_remove_node " ,  NodePath ( String ( EditorNode : : get_singleton ( ) - > get_edited_scene ( ) - > get_path_to ( p_parent ) )  +  " / "  +  new_name ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									// Compute the global position
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Transform2D  xform  =  canvas_item_editor - > get_canvas_transform ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Point2  target_position  =  xform . affine_inverse ( ) . xform ( p_point ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									// There's nothing to be used as source position, so snapping will work as absolute if enabled.
 
							 
						 
					
						
							
								
									
										
										
										
											2018-11-16 16:55:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									target_position  =  canvas_item_editor - > snap_point ( target_position ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-30 20:00:41 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 10:13:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									CanvasItem  * parent_ci  =  Object : : cast_to < CanvasItem > ( p_parent ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-13 13:52:37 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Point2  local_target_pos  =  parent_ci  ?  parent_ci - > get_global_transform ( ) . affine_inverse ( ) . xform ( target_position )  :  target_position ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-30 20:00:41 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									undo_redo - > add_do_method ( child ,  " set_position " ,  local_target_pos ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 10:13:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									EditorSelection  * editor_selection  =  EditorNode : : get_singleton ( ) - > get_editor_selection ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									undo_redo - > add_do_method ( editor_selection ,  " add_node " ,  child ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-26 04:27:24 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 10:13:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								bool  CanvasItemEditorViewport : : _create_instance ( Node  * p_parent ,  const  String  & p_path ,  const  Point2  & p_point )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Ref < PackedScene >  sdata  =  ResourceLoader : : load ( p_path ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-25 14:15:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( sdata . is_null ( ) )  {  // invalid scene
 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-26 04:27:24 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-06-17 16:03:09 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Node  * instantiated_scene  =  sdata - > instantiate ( PackedScene : : GEN_EDIT_STATE_INSTANCE ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-16 00:13:39 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( ! instantiated_scene )  {  // Error on instantiation.
 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-26 04:27:24 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 10:36:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Node  * edited_scene  =  EditorNode : : get_singleton ( ) - > get_edited_scene ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-11-16 00:13:39 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( ! edited_scene - > get_scene_file_path ( ) . is_empty ( ) )  {  // Cyclic instantiation.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 10:36:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( _cyclical_dependency_exists ( edited_scene - > get_scene_file_path ( ) ,  instantiated_scene ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-17 16:03:09 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											memdelete ( instantiated_scene ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-26 04:27:24 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 10:13:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									instantiated_scene - > set_scene_file_path ( ProjectSettings : : get_singleton ( ) - > localize_path ( p_path ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-26 04:27:24 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-12-23 23:53:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									EditorUndoRedoManager  * undo_redo  =  EditorUndoRedoManager : : get_singleton ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-02 11:07:29 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									EditorSelection  * editor_selection  =  EditorNode : : get_singleton ( ) - > get_editor_selection ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 10:13:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									undo_redo - > add_do_method ( p_parent ,  " add_child " ,  instantiated_scene ,  true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-29 12:10:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									undo_redo - > add_do_method ( instantiated_scene ,  " set_owner " ,  edited_scene ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									undo_redo - > add_do_reference ( instantiated_scene ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 10:13:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									undo_redo - > add_undo_method ( p_parent ,  " remove_child " ,  instantiated_scene ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-02 11:07:29 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									undo_redo - > add_do_method ( editor_selection ,  " add_node " ,  instantiated_scene ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-26 04:27:24 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 10:13:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									String  new_name  =  p_parent - > validate_child_name ( instantiated_scene ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-07 02:52:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									EditorDebuggerNode  * ed  =  EditorDebuggerNode : : get_singleton ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 10:13:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									undo_redo - > add_do_method ( ed ,  " live_debug_instantiate_node " ,  edited_scene - > get_path_to ( p_parent ) ,  p_path ,  new_name ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									undo_redo - > add_undo_method ( ed ,  " live_debug_remove_node " ,  NodePath ( String ( edited_scene - > get_path_to ( p_parent ) )  +  " / "  +  new_name ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-26 04:27:24 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-20 22:36:14 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									CanvasItem  * instance_ci  =  Object : : cast_to < CanvasItem > ( instantiated_scene ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( instance_ci )  { 
							 
						 
					
						
							
								
									
										
										
										
											2018-11-16 16:55:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Vector2  target_pos  =  canvas_item_editor - > get_canvas_transform ( ) . affine_inverse ( ) . xform ( p_point ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										target_pos  =  canvas_item_editor - > snap_point ( target_pos ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-20 22:36:14 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 10:13:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										CanvasItem  * parent_ci  =  Object : : cast_to < CanvasItem > ( p_parent ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-20 22:36:14 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( parent_ci )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											target_pos  =  parent_ci - > get_global_transform_with_canvas ( ) . affine_inverse ( ) . xform ( target_pos ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-22 14:16:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-20 22:36:14 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										// Preserve instance position of the original scene.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										target_pos  + =  instance_ci - > _edit_get_position ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-29 12:10:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										undo_redo - > add_do_method ( instantiated_scene ,  " set_position " ,  target_pos ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-26 04:27:24 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditorViewport : : _perform_drop_data ( )  {  
						 
					
						
							
								
									
										
										
										
											2024-04-12 14:48:29 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_COND ( selected_files . size ( )  < =  0 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-10-26 04:27:24 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									_remove_preview ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-04-12 14:48:29 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( ! target_node )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 10:13:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										// Should already be handled by `can_drop_data`.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										ERR_FAIL_COND_MSG ( selected_files . size ( )  >  1 ,  " Can't instantiate multiple nodes without root. " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-12 14:48:29 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										const  String  & path  =  selected_files [ 0 ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										Ref < Resource >  res  =  ResourceLoader : : load ( path ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if  ( res . is_null ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										Ref < PackedScene >  scene  =  res ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if  ( scene . is_valid ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											// Without root node act the same as "Load Inherited Scene".
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											Error  err  =  EditorNode : : get_singleton ( ) - > load_scene ( path ,  false ,  true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if  ( err  ! =  OK )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												accept - > set_text ( vformat ( TTR ( " Error instantiating scene from %s. " ) ,  path . get_file ( ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												accept - > popup_centered ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-09 01:05:15 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-03-05 22:45:39 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									PackedStringArray  error_files ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-26 04:27:24 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-12-23 23:53:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									EditorUndoRedoManager  * undo_redo  =  EditorUndoRedoManager : : get_singleton ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-07 18:03:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									undo_redo - > create_action_for_history ( TTR ( " Create Node " ) ,  EditorNode : : get_editor_data ( ) . get_current_edited_scene_history_id ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-02 11:07:29 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									EditorSelection  * editor_selection  =  EditorNode : : get_singleton ( ) - > get_editor_selection ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									undo_redo - > add_do_method ( editor_selection ,  " clear " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-26 04:27:24 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									for  ( int  i  =  0 ;  i  <  selected_files . size ( ) ;  i + + )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										String  path  =  selected_files [ i ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-05-03 01:43:50 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Ref < Resource >  res  =  ResourceLoader : : load ( path ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-26 04:27:24 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( res . is_null ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-12 14:48:29 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										Ref < PackedScene >  scene  =  res ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if  ( scene . is_valid ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											bool  success  =  _create_instance ( target_node ,  path ,  drop_pos ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if  ( ! success )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												error_files . push_back ( path . get_file ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-26 04:27:24 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-12 14:48:29 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										Ref < Texture2D >  texture  =  res ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if  ( texture . is_valid ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											Node  * child  =  Object : : cast_to < Node > ( ClassDB : : instantiate ( default_texture_node_type ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 10:13:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											_create_texture_node ( target_node ,  child ,  path ,  drop_pos ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-12 14:48:29 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											undo_redo - > add_do_method ( editor_selection ,  " add_node " ,  child ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-26 04:27:24 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 10:13:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										Ref < AudioStream >  audio  =  res ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if  ( audio . is_valid ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											_create_audio_node ( target_node ,  path ,  drop_pos ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-26 04:27:24 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-29 12:10:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									undo_redo - > commit_action ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-26 04:27:24 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( error_files . size ( )  >  0 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-05 22:45:39 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										accept - > set_text ( vformat ( TTR ( " Error instantiating scene from %s. " ) ,  String ( " ,  " ) . join ( error_files ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-06 14:00:16 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										accept - > popup_centered ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-26 04:27:24 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								bool  CanvasItemEditorViewport : : can_drop_data ( const  Point2  & p_point ,  const  Variant  & p_data )  const  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Dictionary  d  =  p_data ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-03 18:43:37 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( ! d . has ( " type " )  | |  ( String ( d [ " type " ] )  ! =  " files " ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										label - > hide ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Vector < String >  files  =  d [ " files " ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 10:13:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									const  Node  * edited_scene  =  EditorNode : : get_singleton ( ) - > get_edited_scene ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( ! edited_scene  & &  files . size ( )  >  1 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										canvas_item_editor - > message  =  TTR ( " Can't instantiate multiple nodes without root. " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										canvas_item_editor - > update_viewport ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									enum  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										SCENE  =  1  < <  0 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										TEXTURE  =  1  < <  1 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										AUDIO  =  1  < <  2 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									int  instantiate_type  =  0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-03 18:43:37 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 10:13:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									for  ( const  String  & path  :  files )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										const  String  & res_type  =  ResourceLoader : : get_resource_type ( path ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										String  error_message ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if  ( ClassDB : : is_parent_class ( res_type ,  " PackedScene " ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											Ref < PackedScene >  scn  =  ResourceLoader : : load ( path ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											ERR_CONTINUE ( scn . is_null ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											Node  * instantiated_scene  =  scn - > instantiate ( PackedScene : : GEN_EDIT_STATE_INSTANCE ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if  ( ! instantiated_scene )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-03 18:43:37 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												continue ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-26 04:27:24 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 10:13:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if  ( edited_scene  & &  ! edited_scene - > get_scene_file_path ( ) . is_empty ( )  & &  _cyclical_dependency_exists ( edited_scene - > get_scene_file_path ( ) ,  instantiated_scene ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												error_message  =  vformat ( TTR ( " Circular dependency found at %s. " ) ,  path . get_file ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-26 04:27:24 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 10:13:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											memdelete ( instantiated_scene ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											instantiate_type  | =  SCENE ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if  ( ClassDB : : is_parent_class ( res_type ,  " Texture2D " ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											instantiate_type  | =  TEXTURE ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if  ( ClassDB : : is_parent_class ( res_type ,  " AudioStream " ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											instantiate_type  | =  AUDIO ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if  ( ! error_message . is_empty ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											// TRANSLATORS: The placeholder is the error message.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											canvas_item_editor - > message  =  vformat ( TTR ( " Can't instantiate: %s " ) ,  error_message ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											canvas_item_editor - > update_viewport ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											return  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-26 04:27:24 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 10:13:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( instantiate_type  = =  0 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-05 22:45:39 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-03 18:43:37 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 10:13:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( ! preview_node - > get_parent ( ) )  {  // create preview only once
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										_create_preview ( files ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_COND_V ( preview_node - > get_child_count ( )  = =  0 ,  false ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									const  Transform2D  trans  =  canvas_item_editor - > get_canvas_transform ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									preview_node - > set_position ( ( p_point  -  trans . get_origin ( ) )  /  trans . get_scale ( ) . x ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( ! edited_scene  & &  instantiate_type  &  SCENE )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-03 18:43:37 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										String  scene_file_path  =  preview_node - > get_child ( 0 ) - > get_scene_file_path ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 10:13:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										// TRANSLATORS: The placeholder is the file path of the scene being instantiated.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										canvas_item_editor - > message  =  vformat ( TTR ( " Creating inherited scene from: %s " ) ,  scene_file_path ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										double  snap  =  EDITOR_GET ( " interface/inspector/default_float_step " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										int  snap_step_decimals  =  Math : : range_step_decimals ( snap ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-03 18:43:37 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# define FORMAT(value) (TS->format_number(String::num(value, snap_step_decimals))) 
  
						 
					
						
							
								
									
										
										
										
											2024-05-16 10:13:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Vector2  preview_node_pos  =  preview_node - > get_global_position ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										canvas_item_editor - > message  =  TTR ( " Instantiating:  " )  +  " ( "  +  FORMAT ( preview_node_pos . x )  +  " ,  "  +  FORMAT ( preview_node_pos . y )  +  " ) px " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									canvas_item_editor - > update_viewport ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( instantiate_type  &  TEXTURE  & &  instantiate_type  &  AUDIO )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										// TRANSLATORS: The placeholders are the types of nodes being instantiated.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										label - > set_text ( vformat ( TTR ( " Adding %s and %s... " ) ,  default_texture_node_type ,  " AudioStreamPlayer2D " ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										String  node_type ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if  ( instantiate_type  &  TEXTURE )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											node_type  =  default_texture_node_type ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}  else  if  ( instantiate_type  &  AUDIO )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											node_type  =  " AudioStreamPlayer2D " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if  ( ! node_type . is_empty ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											// TRANSLATORS: The placeholder is the type of node being instantiated.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											label - > set_text ( vformat ( TTR ( " Adding %s... " ) ,  node_type ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-03 18:43:37 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 10:13:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									label - > set_visible ( instantiate_type  &  ~ SCENE ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-03 18:43:37 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 10:13:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									String  desc  =  TTR ( " Drag and drop to add as sibling of selected node (except when root is selected). " )  + 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											" \n "  +  TTR ( " Hold Shift when dropping to add as child of selected node. " )  + 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											" \n "  +  TTR ( " Hold Alt when dropping to add as child of root node. " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( instantiate_type  &  TEXTURE )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										desc  + =  " \n "  +  TTR ( " Hold Alt + Shift when dropping to add as different node type. " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-03 18:43:37 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 10:13:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									label_desc - > set_text ( desc ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									label_desc - > show ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-26 04:27:24 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 10:13:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditorViewport : : _show_texture_node_type_selector ( )  {  
						 
					
						
							
								
									
										
										
										
											2018-01-09 01:05:15 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									_remove_preview ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-22 05:28:02 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									List < BaseButton  * >  btn_list ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									button_group - > get_buttons ( & btn_list ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-04-15 15:18:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									for  ( BaseButton  * btn  :  btn_list )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										CheckBox  * check  =  Object : : cast_to < CheckBox > ( btn ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-29 02:46:38 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										check - > set_pressed ( check - > get_text ( )  = =  default_texture_node_type ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-22 05:28:02 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 10:13:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									texture_node_type_selector - > set_title ( vformat ( TTR ( " Add %s " ) ,  default_texture_node_type ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									texture_node_type_selector - > popup_centered ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-22 05:28:02 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 10:13:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								bool  CanvasItemEditorViewport : : _is_any_texture_selected ( )  const  {  
						 
					
						
							
								
									
										
										
										
											2018-01-09 01:05:15 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									for  ( int  i  =  0 ;  i  <  selected_files . size ( ) ;  + + i )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 10:13:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( ClassDB : : is_parent_class ( ResourceLoader : : get_resource_type ( selected_files [ i ] ) ,  " Texture2D " ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											return  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-09 01:05:15 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 10:13:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									return  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-09 01:05:15 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-10-26 04:27:24 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditorViewport : : drop_data ( const  Point2  & p_point ,  const  Variant  & p_data )  {  
						 
					
						
							
								
									
										
										
										
											2021-08-13 16:31:57 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									bool  is_shift  =  Input : : get_singleton ( ) - > is_key_pressed ( Key : : SHIFT ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									bool  is_alt  =  Input : : get_singleton ( ) - > is_key_pressed ( Key : : ALT ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-26 04:27:24 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									selected_files . clear ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Dictionary  d  =  p_data ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( d . has ( " type " )  & &  String ( d [ " type " ] )  = =  " files " )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										selected_files  =  d [ " files " ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( selected_files . size ( )  = =  0 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-09 01:05:15 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-26 04:27:24 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-12-01 06:40:29 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									List < Node  * >  selected_nodes  =  EditorNode : : get_singleton ( ) - > get_editor_selection ( ) - > get_top_selected_node_list ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 10:36:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Node  * root_node  =  EditorNode : : get_singleton ( ) - > get_edited_scene ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-29 07:15:46 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( selected_nodes . size ( )  >  0 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-15 15:18:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Node  * selected_node  =  selected_nodes . front ( ) - > get ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-26 18:02:46 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( is_alt )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											target_node  =  root_node ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-12 14:00:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}  else  if  ( is_shift )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											target_node  =  selected_node ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}  else  {  // Default behavior.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											target_node  =  ( selected_node  ! =  root_node )  ?  selected_node - > get_parent ( )  :  root_node ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-29 07:15:46 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-02 20:47:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( root_node )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-29 07:15:46 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											target_node  =  root_node ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-02 20:47:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-04-02 01:20:12 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											target_node  =  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-02 20:47:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-26 04:27:24 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									drop_pos  =  p_point ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 10:13:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( is_alt  & &  is_shift  & &  _is_any_texture_selected ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										_show_texture_node_type_selector ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-26 04:27:24 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										_perform_drop_data ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-29 11:04:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditorViewport : : _update_theme ( )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									List < BaseButton  * >  btn_list ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									button_group - > get_buttons ( & btn_list ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-04-15 15:18:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									for  ( BaseButton  * btn  :  btn_list )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										CheckBox  * check  =  Object : : cast_to < CheckBox > ( btn ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-09 15:21:47 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										check - > set_button_icon ( get_editor_theme_icon ( check - > get_text ( ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-29 11:04:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-14 15:57:29 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									label - > add_theme_color_override ( SceneStringName ( font_color ) ,  get_theme_color ( SNAME ( " warning_color " ) ,  EditorStringName ( Editor ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-29 11:04:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-15 21:44:22 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  CanvasItemEditorViewport : : _notification ( int  p_what )  {  
						 
					
						
							
								
									
										
										
										
											2017-08-10 11:40:28 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									switch  ( p_what )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-15 21:44:22 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										case  NOTIFICATION_THEME_CHANGED :  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-29 11:04:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											_update_theme ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-15 21:44:22 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}  break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-08-10 11:40:28 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										case  NOTIFICATION_ENTER_TREE :  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-29 11:04:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											_update_theme ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-13 16:56:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											connect ( SceneStringName ( mouse_exited ) ,  callable_mp ( this ,  & CanvasItemEditorViewport : : _on_mouse_exit ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-10 11:40:28 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}  break ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-15 21:44:22 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-08-10 11:40:28 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										case  NOTIFICATION_EXIT_TREE :  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-13 16:56:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											disconnect ( SceneStringName ( mouse_exited ) ,  callable_mp ( this ,  & CanvasItemEditorViewport : : _on_mouse_exit ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-10 11:40:28 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}  break ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-12 12:49:10 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case  NOTIFICATION_DRAG_END :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											_remove_preview ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}  break ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-26 04:27:24 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 10:36:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								CanvasItemEditorViewport : : CanvasItemEditorViewport ( CanvasItemEditor  * p_canvas_item_editor )  {  
						 
					
						
							
								
									
										
										
										
											2021-07-29 02:46:38 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									default_texture_node_type  =  " Sprite2D " ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-26 04:27:24 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// Node2D
 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-29 02:46:38 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									texture_node_types . push_back ( " Sprite2D " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									texture_node_types . push_back ( " PointLight2D " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									texture_node_types . push_back ( " CPUParticles2D " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									texture_node_types . push_back ( " GPUParticles2D " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									texture_node_types . push_back ( " Polygon2D " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									texture_node_types . push_back ( " TouchScreenButton " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-26 04:27:24 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// Control
 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-29 02:46:38 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									texture_node_types . push_back ( " TextureRect " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									texture_node_types . push_back ( " TextureButton " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									texture_node_types . push_back ( " NinePatchRect " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-26 04:27:24 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-04-02 01:20:12 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									target_node  =  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-11-16 16:55:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									canvas_item_editor  =  p_canvas_item_editor ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-12 18:05:59 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									preview_node  =  memnew ( Control ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-19 18:29:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-10-26 04:27:24 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									accept  =  memnew ( AcceptDialog ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 10:36:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									EditorNode : : get_singleton ( ) - > get_gui_base ( ) - > add_child ( accept ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-26 04:27:24 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 10:13:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									texture_node_type_selector  =  memnew ( AcceptDialog ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									EditorNode : : get_singleton ( ) - > get_gui_base ( ) - > add_child ( texture_node_type_selector ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									texture_node_type_selector - > set_title ( TTR ( " Change Default Type " ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-14 14:28:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									texture_node_type_selector - > connect ( SceneStringName ( confirmed ) ,  callable_mp ( this ,  & CanvasItemEditorViewport : : _on_change_type_confirmed ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 10:13:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									texture_node_type_selector - > connect ( " canceled " ,  callable_mp ( this ,  & CanvasItemEditorViewport : : _on_change_type_closed ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-26 04:27:24 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									VBoxContainer  * vbc  =  memnew ( VBoxContainer ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 10:13:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									texture_node_type_selector - > add_child ( vbc ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-06 14:00:16 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									vbc - > set_h_size_flags ( Control : : SIZE_EXPAND_FILL ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									vbc - > set_v_size_flags ( Control : : SIZE_EXPAND_FILL ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-11 12:21:45 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									vbc - > set_custom_minimum_size ( Size2 ( 240 ,  260 )  *  EDSCALE ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-26 04:27:24 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 10:13:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									VBoxContainer  * btn_group  =  memnew ( VBoxContainer ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-19 18:29:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									vbc - > add_child ( btn_group ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-05 12:28:16 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									btn_group - > set_h_size_flags ( SIZE_EXPAND_FILL ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-26 04:27:24 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-06-17 16:03:09 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									button_group . instantiate ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-29 02:46:38 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									for  ( int  i  =  0 ;  i  <  texture_node_types . size ( ) ;  i + + )  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-26 04:27:24 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										CheckBox  * check  =  memnew ( CheckBox ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-19 18:29:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										btn_group - > add_child ( check ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-29 02:46:38 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										check - > set_text ( texture_node_types [ i ] ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 10:13:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										check - > connect ( " button_down " ,  callable_mp ( this ,  & CanvasItemEditorViewport : : _on_select_texture_node_type ) . bind ( check ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-01-10 01:04:31 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										check - > set_button_group ( button_group ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-26 04:27:24 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									label  =  memnew ( Label ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-08 10:14:58 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									label - > add_theme_color_override ( " font_shadow_color " ,  Color ( 0 ,  0 ,  0 ,  1 ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									label - > add_theme_constant_override ( " shadow_outline_size " ,  1  *  EDSCALE ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-26 04:27:24 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									label - > hide ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-11-18 10:49:37 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									canvas_item_editor - > get_controls_container ( ) - > add_child ( label ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-26 04:27:24 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									label_desc  =  memnew ( Label ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-14 15:57:29 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									label_desc - > add_theme_color_override ( SceneStringName ( font_color ) ,  Color ( 0.6f ,  0.6f ,  0.6f ,  1 ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-08 10:14:58 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									label_desc - > add_theme_color_override ( " font_shadow_color " ,  Color ( 0.2f ,  0.2f ,  0.2f ,  1 ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									label_desc - > add_theme_constant_override ( " shadow_outline_size " ,  1  *  EDSCALE ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									label_desc - > add_theme_constant_override ( " line_spacing " ,  0 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-26 04:27:24 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									label_desc - > hide ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-11-18 10:49:37 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									canvas_item_editor - > get_controls_container ( ) - > add_child ( label_desc ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-27 15:21:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									RS : : get_singleton ( ) - > canvas_set_disable_scale ( true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-26 04:27:24 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2017-08-24 12:51:28 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								CanvasItemEditorViewport : : ~ CanvasItemEditorViewport ( )  {  
						 
					
						
							
								
									
										
										
										
											2017-09-02 20:47:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									memdelete ( preview_node ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-24 12:51:28 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}