summaryrefslogtreecommitdiffstats
path: root/editor/scene_tree_dock.cpp
diff options
context:
space:
mode:
authorSofox <sofoxx@gmail.com>2023-11-21 15:54:26 +0000
committerSofox <sofoxx@gmail.com>2023-11-22 09:37:17 +0000
commit5614e6d61ca5de6c75af2adf5c55e70f4bcd5ec5 (patch)
tree2b98dac95b262fde7001c0fd896a1f75b37aa962 /editor/scene_tree_dock.cpp
parent7022271291a3d2a9cbd6a223d22a29fd775dfc5d (diff)
downloadredot-engine-5614e6d61ca5de6c75af2adf5c55e70f4bcd5ec5.tar.gz
Restored Control layout properties you undo a parenting of a Control to a Container
Diffstat (limited to 'editor/scene_tree_dock.cpp')
-rw-r--r--editor/scene_tree_dock.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp
index a94c978a1a..615e5edf98 100644
--- a/editor/scene_tree_dock.cpp
+++ b/editor/scene_tree_dock.cpp
@@ -2176,6 +2176,7 @@ void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, V
}
int child_pos = node->get_index(false);
+ bool reparented_to_container = Object::cast_to<Container>(new_parent) && Object::cast_to<Control>(node);
undo_redo->add_undo_method(node->get_parent(), "add_child", node, true);
undo_redo->add_undo_method(node->get_parent(), "move_child", node, child_pos);
@@ -2191,10 +2192,14 @@ void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, V
if (Object::cast_to<Node3D>(node)) {
undo_redo->add_undo_method(node, "set_transform", Object::cast_to<Node3D>(node)->get_transform());
}
- if (Object::cast_to<Control>(node)) {
+ if (!reparented_to_container && Object::cast_to<Control>(node)) {
undo_redo->add_undo_method(node, "set_position", Object::cast_to<Control>(node)->get_position());
}
}
+
+ if (reparented_to_container) {
+ undo_redo->add_undo_method(node, "_edit_set_state", Object::cast_to<Control>(node)->_edit_get_state());
+ }
}
perform_node_renames(nullptr, &path_renames);