summaryrefslogtreecommitdiff
path: root/tools/editor
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2014-12-20 12:32:32 -0300
committerJuan Linietsky <reduzio@gmail.com>2014-12-20 12:32:32 -0300
commit9783f6fc969947fdbf666950ab3da21ac462c57e (patch)
tree44e8458cc19c4f5bfe230a7972a3958732b54c77 /tools/editor
parentcf0a419efae977eba3ed17437f0475a0d7a11bbe (diff)
parent7dbc19f32db7b63062e715381923c873bf18683e (diff)
Merge branch 'master' of https://github.com/okamstudio/godot
Diffstat (limited to 'tools/editor')
-rw-r--r--tools/editor/plugins/script_editor_plugin.cpp2
-rw-r--r--tools/editor/scene_tree_dock.cpp51
2 files changed, 43 insertions, 10 deletions
diff --git a/tools/editor/plugins/script_editor_plugin.cpp b/tools/editor/plugins/script_editor_plugin.cpp
index d9b3ec1d4f..2e5f267d5c 100644
--- a/tools/editor/plugins/script_editor_plugin.cpp
+++ b/tools/editor/plugins/script_editor_plugin.cpp
@@ -1599,7 +1599,7 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
edit_menu->get_popup()->add_item("Move Down",EDIT_MOVE_LINE_DOWN,KEY_MASK_ALT|KEY_DOWN);
edit_menu->get_popup()->add_item("Indent Left",EDIT_INDENT_LEFT,KEY_MASK_ALT|KEY_LEFT);
edit_menu->get_popup()->add_item("Indent Right",EDIT_INDENT_RIGHT,KEY_MASK_ALT|KEY_RIGHT);
- edit_menu->get_popup()->add_item("Toggle Comment",EDIT_TOGGLE_COMMENT,KEY_MASK_CMD|KEY_SLASH);
+ edit_menu->get_popup()->add_item("Toggle Comment",EDIT_TOGGLE_COMMENT,KEY_MASK_CMD|KEY_K);
edit_menu->get_popup()->add_item("Clone Down",EDIT_CLONE_DOWN,KEY_MASK_CMD|KEY_B);
edit_menu->get_popup()->add_separator();
edit_menu->get_popup()->add_item("Complete Symbol",EDIT_COMPLETE,KEY_MASK_CMD|KEY_SPACE);
diff --git a/tools/editor/scene_tree_dock.cpp b/tools/editor/scene_tree_dock.cpp
index 3455582bbc..f5d9e83bf8 100644
--- a/tools/editor/scene_tree_dock.cpp
+++ b/tools/editor/scene_tree_dock.cpp
@@ -212,17 +212,50 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
if (!_validate_no_foreign())
break;
- Node * node=scene_tree->get_selected();
- ERR_FAIL_COND(!node->get_parent());
- int current_pos = node->get_index();
- int next_pos = current_pos + ((p_tool==TOOL_MOVE_DOWN)?1:-1);
+ bool MOVING_DOWN = (p_tool == TOOL_MOVE_DOWN);
+ bool MOVING_UP = !MOVING_DOWN;
- if (next_pos< 0 || next_pos>=node->get_parent()->get_child_count())
- break; // invalid position
+ Node *common_parent = scene_tree->get_selected()->get_parent();
+ List<Node*> selection = editor_selection->get_selected_node_list();
+ selection.sort_custom<Node::Comparator>(); // sort by index
+ if (MOVING_DOWN)
+ selection.invert();
+
+ int lowest_id = common_parent->get_child_count() - 1;
+ int highest_id = 0;
+ for (List<Node*>::Element *E = selection.front(); E; E = E->next()) {
+ int index = E->get()->get_index();
+
+ if (index > highest_id) highest_id = index;
+ if (index < lowest_id) lowest_id = index;
+
+ if (E->get()->get_parent() != common_parent)
+ common_parent = NULL;
+ }
+
+ if (!common_parent || (MOVING_DOWN && highest_id >= common_parent->get_child_count() - MOVING_DOWN) || (MOVING_UP && lowest_id == 0))
+ break; // one or more nodes can not be moved
+
+ if (selection.size() == 1) editor_data->get_undo_redo().create_action("Move Node In Parent");
+ if (selection.size() > 1) editor_data->get_undo_redo().create_action("Move Nodes In Parent");
+
+ for (int i = 0; i < selection.size(); i++) {
+ Node *top_node = selection[i];
+ Node *bottom_node = selection[selection.size() - 1 - i];
+
+ ERR_FAIL_COND(!top_node->get_parent());
+ ERR_FAIL_COND(!bottom_node->get_parent());
+
+ int top_node_pos = top_node->get_index();
+ int bottom_node_pos = bottom_node->get_index();
+
+ int top_node_pos_next = top_node_pos + (MOVING_DOWN ? 1 : -1);
+ int bottom_node_pos_next = bottom_node_pos + (MOVING_DOWN ? 1 : -1);
+
+ editor_data->get_undo_redo().add_do_method(top_node->get_parent(), "move_child", top_node, top_node_pos_next);
+ editor_data->get_undo_redo().add_undo_method(bottom_node->get_parent(), "move_child", bottom_node, bottom_node_pos);
+ }
- editor_data->get_undo_redo().create_action("Move Node In Parent");
- editor_data->get_undo_redo().add_do_method(node->get_parent(),"move_child",node,next_pos);
- editor_data->get_undo_redo().add_undo_method(node->get_parent(),"move_child",node,current_pos);
editor_data->get_undo_redo().commit_action();
} break;