diff options
Diffstat (limited to 'tools/editor/scene_tree_dock.cpp')
-rw-r--r-- | tools/editor/scene_tree_dock.cpp | 41 |
1 files changed, 39 insertions, 2 deletions
diff --git a/tools/editor/scene_tree_dock.cpp b/tools/editor/scene_tree_dock.cpp index 8b5bf8c1e1..75f1597b20 100644 --- a/tools/editor/scene_tree_dock.cpp +++ b/tools/editor/scene_tree_dock.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 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 */ @@ -889,7 +889,7 @@ bool SceneTreeDock::_validate_no_foreign() { return true; } -void SceneTreeDock::_node_reparent(NodePath p_path,bool p_node_only) { +void SceneTreeDock::_node_reparent(NodePath p_path,bool p_keep_global_xform) { Node *node = scene_tree->get_selected(); @@ -948,6 +948,23 @@ void SceneTreeDock::_node_reparent(NodePath p_path,bool p_node_only) { editor_data->get_undo_redo().add_do_method(sed,"live_debug_reparent_node",edited_scene->get_path_to(node),edited_scene->get_path_to(new_parent),new_name,-1); editor_data->get_undo_redo().add_undo_method(sed,"live_debug_reparent_node",NodePath(String(edited_scene->get_path_to(new_parent))+"/"+new_name),edited_scene->get_path_to(node->get_parent()),node->get_name(),node->get_index()); + if (p_keep_global_xform) { + if (node->cast_to<Node2D>()) + editor_data->get_undo_redo().add_do_method(node,"set_global_transform",node->cast_to<Node2D>()->get_global_transform()); + if (node->cast_to<Spatial>()) + editor_data->get_undo_redo().add_do_method(node,"set_global_transform",node->cast_to<Spatial>()->get_global_transform()); + if (node->cast_to<Control>()) { + bool can_do_it=false; + Control *c=node->cast_to<Control>(); + if (c->get_parent()->cast_to<Container>()) + can_do_it=false; + for(int i=0;i<4;i++) { + if (c->get_anchor(Margin(i))!=ANCHOR_BEGIN) + can_do_it=false; + } + editor_data->get_undo_redo().add_do_method(node,"set_global_pos",node->cast_to<Control>()->get_global_pos()); + } + } editor_data->get_undo_redo().add_do_method(this,"_set_owners",edited_scene,owners); @@ -982,6 +999,26 @@ void SceneTreeDock::_node_reparent(NodePath p_path,bool p_node_only) { if (editor->get_animation_editor()->get_root()==node) editor_data->get_undo_redo().add_undo_method(editor->get_animation_editor(),"set_root",node); + if (p_keep_global_xform) { + if (node->cast_to<Node2D>()) + editor_data->get_undo_redo().add_undo_method(node,"set_transform",node->cast_to<Node2D>()->get_transform()); + if (node->cast_to<Spatial>()) + editor_data->get_undo_redo().add_undo_method(node,"set_transform",node->cast_to<Spatial>()->get_transform()); + if (node->cast_to<Control>()) { + bool can_do_it=false; + Control *c=node->cast_to<Control>(); + if (c->get_parent()->cast_to<Container>()) + can_do_it=false; + for(int i=0;i<4;i++) { + if (c->get_anchor(Margin(i))!=ANCHOR_BEGIN) + can_do_it=false; + } + editor_data->get_undo_redo().add_undo_method(node,"set_pos",node->cast_to<Control>()->get_pos()); + } + } + + + } perform_node_renames(NULL,&path_renames); |