diff options
author | Keetz <rkketelsen@gmail.com> | 2016-11-02 16:23:03 +0100 |
---|---|---|
committer | Keetz <rkketelsen@gmail.com> | 2016-11-03 13:59:36 +0100 |
commit | 2afcbc4b1f4bc0aee4df3fa1747fa3f73b160676 (patch) | |
tree | 5260a52053ad7c28dfe07dcb7034e1b4f9cb0ba3 /tools/editor/scene_tree_dock.cpp | |
parent | 8321e48ab0ac0700e1aef8f829140052c1ba4c6d (diff) |
Fix scene tree drag & drop places node as child (#6912)
Diffstat (limited to 'tools/editor/scene_tree_dock.cpp')
-rw-r--r-- | tools/editor/scene_tree_dock.cpp | 35 |
1 files changed, 4 insertions, 31 deletions
diff --git a/tools/editor/scene_tree_dock.cpp b/tools/editor/scene_tree_dock.cpp index 56f10ff7f8..c73fef4170 100644 --- a/tools/editor/scene_tree_dock.cpp +++ b/tools/editor/scene_tree_dock.cpp @@ -1564,7 +1564,7 @@ static bool _is_node_visible(Node* p_node) { static bool _has_visible_children(Node* p_node) { - bool collapsed = p_node->has_meta("_editor_collapsed") ? (bool)p_node->get_meta("_editor_collapsed") : false; + bool collapsed = p_node->is_displayed_folded(); if (collapsed) return false; @@ -1587,7 +1587,7 @@ static Node* _find_last_visible(Node* p_node) { Node* last=NULL; - bool collapsed = p_node->has_meta("_editor_collapsed") ? (bool)p_node->get_meta("_editor_collapsed") : false; + bool collapsed = p_node->is_displayed_folded(); if (!collapsed) { for(int i=0;i<p_node->get_child_count();i++) { @@ -1622,36 +1622,9 @@ void SceneTreeDock::_normalize_drop(Node*& to_node, int &to_pos, int p_type) { ERR_EXPLAIN("Cannot perform drop above the root node!"); ERR_FAIL(); } - Node* upper_sibling=NULL; - for(int i=0;i<to_node->get_index();i++) { - Node *c =to_node->get_parent()->get_child(i); - if (_is_node_visible(c)) { - upper_sibling=c; - } - } - - - if (upper_sibling) { - //quite complicated, look for next visible in tree - upper_sibling=_find_last_visible(upper_sibling); - - if (upper_sibling->get_parent()==to_node->get_parent()) { - //just insert over this node because nothing is above at an upper level - to_pos=to_node->get_index(); - to_node=to_node->get_parent(); - } else { - to_pos=-1; //insert last in whathever is up - to_node=upper_sibling->get_parent(); //insert at a parent of whathever is up - } - - - } else { - //just insert over this node because nothing is above at the same level - to_pos=to_node->get_index(); - to_node=to_node->get_parent(); - - } + to_pos=to_node->get_index(); + to_node=to_node->get_parent(); } else if (p_type==1) { //drop at below selected node |