diff options
author | Tomasz Chabora <kobewi4e@gmail.com> | 2020-02-17 18:29:14 +0100 |
---|---|---|
committer | kobewi <kobewi4e@gmail.com> | 2022-08-16 19:44:41 +0200 |
commit | 2bdd7e9ea0383c06fe6a83445469e41222477abc (patch) | |
tree | 70c22e25063e0b608344ca5d02debc252c589a28 /scene/gui | |
parent | d5d22ab035a611a567f73a2ee2d61a81c99c61b5 (diff) |
Add methods for node reparenting
Diffstat (limited to 'scene/gui')
-rw-r--r-- | scene/gui/control.cpp | 8 | ||||
-rw-r--r-- | scene/gui/control.h | 1 |
2 files changed, 9 insertions, 0 deletions
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index 6d0380c898..954c20f713 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -184,6 +184,14 @@ Size2 Control::_edit_get_minimum_size() const { } #endif +void Control::reparent(Node *p_parent, bool p_keep_global_transform) { + Transform2D temp = get_global_transform(); + Node::reparent(p_parent); + if (p_keep_global_transform) { + set_global_position(temp.get_origin()); + } +} + // Editor integration. void Control::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const { diff --git a/scene/gui/control.h b/scene/gui/control.h index db19d09b11..009b9e1c6f 100644 --- a/scene/gui/control.h +++ b/scene/gui/control.h @@ -384,6 +384,7 @@ public: virtual Size2 _edit_get_minimum_size() const override; #endif + virtual void reparent(Node *p_parent, bool p_keep_global_transform = true) override; // Editor integration. |