Merge pull request #381 from marynate/PR-scene-tree-icons

Add lock and group icon to scene tree editor
This commit is contained in:
reduz 2014-05-08 10:03:09 -03:00
commit 76d44e9dbc
4 changed files with 48 additions and 7 deletions

View file

@ -1673,7 +1673,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
continue;
canvas_item->set_meta("_edit_lock_",true);
emit_signal("item_lock_status_changed");
}
viewport->update();
} break;
@ -1691,7 +1691,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
canvas_item->set_meta("_edit_lock_",Variant());
emit_signal("item_lock_status_changed");
}
viewport->update();
@ -1710,7 +1710,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
continue;
canvas_item->set_meta("_edit_group_",true);
emit_signal("item_group_status_changed");
}
viewport->update();
} break;
@ -1726,9 +1726,8 @@ void CanvasItemEditor::_popup_callback(int p_op) {
if (!canvas_item->is_visible())
continue;
canvas_item->set_meta("_edit_group_",Variant());
emit_signal("item_group_status_changed");
}
viewport->update();
@ -2054,7 +2053,8 @@ void CanvasItemEditor::_bind_methods() {
ObjectTypeDB::bind_method("_viewport_draw",&CanvasItemEditor::_viewport_draw);
ObjectTypeDB::bind_method("_viewport_input_event",&CanvasItemEditor::_viewport_input_event);
ADD_SIGNAL( MethodInfo("item_lock_status_changed") );
ADD_SIGNAL( MethodInfo("item_group_status_changed") );
}

View file

@ -32,6 +32,7 @@
#include "os/keyboard.h"
#include "scene/resources/packed_scene.h"
#include "editor_settings.h"
#include "tools/editor/plugins/canvas_item_editor_plugin.h"
void SceneTreeDock::_unhandled_key_input(InputEvent p_event) {
@ -374,6 +375,15 @@ void SceneTreeDock::_notification(int p_what) {
tool_buttons[i]->set_icon(get_icon(button_names[i],"EditorIcons"));
} break;
case NOTIFICATION_READY: {
CanvasItemEditorPlugin *canvas_item_plugin = editor_data->get_editor("2D")->cast_to<CanvasItemEditorPlugin>();
if (canvas_item_plugin) {
canvas_item_plugin->get_canvas_item_editor()->connect("item_lock_status_changed", scene_tree, "_update_tree");
canvas_item_plugin->get_canvas_item_editor()->connect("item_group_status_changed", scene_tree, "_update_tree");
scene_tree->connect("node_changed", canvas_item_plugin->get_canvas_item_editor()->get_viewport_control(), "update");
}
} break;
}
}

View file

@ -32,6 +32,7 @@
#include "print_string.h"
#include "message_queue.h"
#include "scene/main/viewport.h"
#include "tools/editor/plugins/canvas_item_editor_plugin.h"
Node *SceneTreeEditor::get_scene_node() {
@ -85,6 +86,21 @@ void SceneTreeEditor::_cell_button_pressed(Object *p_item,int p_column,int p_id)
undo_redo->add_undo_method(n,v?"show":"hide");
undo_redo->commit_action();
}
} else if (p_id==BUTTON_LOCK) {
if (n->is_type("CanvasItem")) {
n->set_meta("_edit_lock_", Variant());
_update_tree();
emit_signal("node_changed");
}
} else if (p_id==BUTTON_GROUP) {
if (n->is_type("CanvasItem")) {
n->set_meta("_edit_group_", Variant());
_update_tree();
emit_signal("node_changed");
}
}
}
@ -165,6 +181,16 @@ void SceneTreeEditor::_add_nodes(Node *p_node,TreeItem *p_parent) {
if (!p_node->is_connected("visibility_changed",this,"_node_visibility_changed"))
p_node->connect("visibility_changed",this,"_node_visibility_changed",varray(p_node));
bool is_locked = p_node->has_meta("_edit_lock_");//_edit_group_
if (is_locked)
item->add_button(0,get_icon("Lock", "EditorIcons"), BUTTON_LOCK);
bool is_grouped = p_node->has_meta("_edit_group_");
if (is_grouped)
item->add_button(0,get_icon("Group", "EditorIcons"), BUTTON_GROUP);
} else if (p_node->is_type("GeometryInstance")) {
@ -627,10 +653,12 @@ void SceneTreeEditor::_bind_methods() {
ADD_SIGNAL( MethodInfo("node_selected") );
ADD_SIGNAL( MethodInfo("node_renamed") );
ADD_SIGNAL( MethodInfo("node_prerename") );
ADD_SIGNAL( MethodInfo("node_changed") );
ADD_SIGNAL( MethodInfo("open") );
ADD_SIGNAL( MethodInfo("open_script") );
}
@ -729,6 +757,7 @@ void SceneTreeDialog::_bind_methods() {
ObjectTypeDB::bind_method("_cancel",&SceneTreeDialog::_cancel);
ADD_SIGNAL( MethodInfo("selected",PropertyInfo(Variant::NODE_PATH,"path")));
}

View file

@ -46,7 +46,9 @@ class SceneTreeEditor : public Control {
enum {
BUTTON_SUBSCENE=0,
BUTTON_VISIBILITY=1,
BUTTON_SCRIPT=2
BUTTON_SCRIPT=2,
BUTTON_LOCK=3,
BUTTON_GROUP=4,
};
Tree *tree;