Contextualized Scene Tree menu
-Added context menu to Scene Tree Dock -Removed Buttons -Added a filter to search for nods more easily in the dock
This commit is contained in:
parent
6cf4f20590
commit
f9d615ee87
8 changed files with 129 additions and 11 deletions
|
@ -2389,8 +2389,12 @@ void Tree::_input_event(InputEvent p_event) {
|
|||
}
|
||||
|
||||
}
|
||||
if (!root)
|
||||
if (!root || (!root->get_children() && hide_root)) {
|
||||
if (b.button_index==BUTTON_RIGHT && allow_rmb_select) {
|
||||
emit_signal("empty_tree_rmb_selected",get_local_mouse_pos());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
click_handled=false;
|
||||
pressing_for_editor=false;
|
||||
|
@ -3551,9 +3555,10 @@ void Tree::_bind_methods() {
|
|||
ObjectTypeDB::bind_method(_MD("get_single_select_cell_editing_only_when_already_selected"),&Tree::get_single_select_cell_editing_only_when_already_selected);
|
||||
|
||||
ADD_SIGNAL( MethodInfo("item_selected"));
|
||||
ADD_SIGNAL( MethodInfo("item_rmb_selected",PropertyInfo(Variant::VECTOR2,"pos")));
|
||||
ADD_SIGNAL( MethodInfo("cell_selected"));
|
||||
ADD_SIGNAL( MethodInfo("multi_selected",PropertyInfo(Variant::OBJECT,"item"),PropertyInfo(Variant::INT,"column"),PropertyInfo(Variant::BOOL,"selected")) );
|
||||
ADD_SIGNAL( MethodInfo("item_rmb_selected",PropertyInfo(Variant::VECTOR2,"pos")));
|
||||
ADD_SIGNAL( MethodInfo("empty_tree_rmb_selected",PropertyInfo(Variant::VECTOR2,"pos")));
|
||||
ADD_SIGNAL( MethodInfo("item_edited"));
|
||||
ADD_SIGNAL( MethodInfo("item_collapsed",PropertyInfo(Variant::OBJECT,"item")));
|
||||
//ADD_SIGNAL( MethodInfo("item_doubleclicked" ) );
|
||||
|
|
|
@ -2037,7 +2037,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
|
|||
if (scene) {
|
||||
file->set_current_path(scene->get_filename());
|
||||
};
|
||||
file->set_title(p_option==FILE_OPEN_SCENE?TTR("Open Scene"):"Open Base Scene");
|
||||
file->set_title(p_option==FILE_OPEN_SCENE?TTR("Open Scene"):TTR("Open Base Scene"));
|
||||
file->popup_centered_ratio();
|
||||
|
||||
} break;
|
||||
|
@ -3381,6 +3381,7 @@ Dictionary EditorNode::_get_main_scene_state() {
|
|||
state["scene_tree_offset"]=scene_tree_dock->get_tree_editor()->get_scene_tree()->get_vscroll_bar()->get_val();
|
||||
state["property_edit_offset"]=get_property_editor()->get_scene_tree()->get_vscroll_bar()->get_val();
|
||||
state["saved_version"]=saved_version;
|
||||
state["node_filter"]=scene_tree_dock->get_filter();
|
||||
//print_line(" getting main tab: "+itos(state["main_tab"]));
|
||||
return state;
|
||||
}
|
||||
|
@ -3445,6 +3446,8 @@ void EditorNode::_set_main_scene_state(Dictionary p_state) {
|
|||
if (p_state.has("property_edit_offset"))
|
||||
get_property_editor()->get_scene_tree()->get_vscroll_bar()->set_val(p_state["property_edit_offset"]);
|
||||
|
||||
if (p_state.has("node_filter"))
|
||||
scene_tree_dock->set_filter(p_state["node_filter"]);
|
||||
//print_line("set current 8 ");
|
||||
|
||||
//this should only happen at the very end
|
||||
|
|
|
@ -584,6 +584,7 @@ public:
|
|||
static void add_editor_plugin(EditorPlugin *p_editor);
|
||||
static void remove_editor_plugin(EditorPlugin *p_editor);
|
||||
|
||||
void new_inherited_scene() { _menu_option_confirm(FILE_NEW_INHERITED_SCENE,false); }
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -438,6 +438,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
|
|||
|
||||
set("scenetree_editor/duplicate_node_name_num_separator",0);
|
||||
hints["scenetree_editor/duplicate_node_name_num_separator"]=PropertyInfo(Variant::INT,"scenetree_editor/duplicate_node_name_num_separator",PROPERTY_HINT_ENUM, "None,Space,Underscore,Dash");
|
||||
set("scenetree_editor/display_old_action_buttons",false);
|
||||
|
||||
set("gridmap_editor/pick_distance", 5000.0);
|
||||
|
||||
|
@ -537,6 +538,9 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
|
|||
};
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void EditorSettings::notify_changes() {
|
||||
|
|
|
@ -220,11 +220,15 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
|
|||
|
||||
if (!scene) {
|
||||
|
||||
EditorNode::get_singleton()->new_inherited_scene();
|
||||
|
||||
/* should be legal now
|
||||
current_option=-1;
|
||||
//confirmation->get_cancel()->hide();
|
||||
accept->get_ok()->set_text(TTR("I see.."));
|
||||
accept->set_text("This operation can't be done without a tree root.");
|
||||
accept->popup_centered_minsize();
|
||||
*/
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -629,6 +633,8 @@ void SceneTreeDock::_notification(int p_what) {
|
|||
for(int i=0;i<TOOL_BUTTON_MAX;i++)
|
||||
tool_buttons[i]->set_icon(get_icon(button_names[i],"EditorIcons"));
|
||||
|
||||
filter_icon->set_texture(get_icon("Zoom","EditorIcons"));
|
||||
|
||||
EditorNode::get_singleton()->get_editor_selection()->connect("selection_changed",this,"_selection_changed");
|
||||
|
||||
} break;
|
||||
|
@ -1271,7 +1277,12 @@ void SceneTreeDock::_update_tool_buttons() {
|
|||
|
||||
void SceneTreeDock::_selection_changed() {
|
||||
|
||||
tool_buttons[TOOL_MULTI_EDIT]->set_disabled(EditorNode::get_singleton()->get_editor_selection()->get_selection().size()<2);
|
||||
if (EditorNode::get_singleton()->get_editor_selection()->get_selection().size()>1) {
|
||||
//automatically turn on multi-edit
|
||||
_tool_selected(TOOL_MULTI_EDIT);
|
||||
}
|
||||
|
||||
//tool_buttons[TOOL_MULTI_EDIT]->set_disabled(EditorNode::get_singleton()->get_editor_selection()->get_selection().size()<2);
|
||||
|
||||
}
|
||||
|
||||
|
@ -1683,10 +1694,24 @@ void SceneTreeDock::_nodes_dragged(Array p_nodes,NodePath p_to,int p_type) {
|
|||
|
||||
void SceneTreeDock::_tree_rmb(const Vector2& p_menu_pos) {
|
||||
|
||||
|
||||
if (!EditorNode::get_singleton()->get_edited_scene()) {
|
||||
|
||||
menu->clear();
|
||||
menu->add_item("New Scene Root",TOOL_NEW,KEY_MASK_CMD|KEY_A);
|
||||
menu->add_item("Inherit Scene",TOOL_INSTANCE);
|
||||
|
||||
menu->set_size(Size2(1,1));
|
||||
menu->set_pos(p_menu_pos);
|
||||
menu->popup();
|
||||
return;
|
||||
}
|
||||
|
||||
List<Node*> selection = editor_selection->get_selected_node_list();
|
||||
|
||||
if (selection.size()==0)
|
||||
return;
|
||||
|
||||
menu->clear();
|
||||
|
||||
|
||||
|
@ -1722,6 +1747,23 @@ void SceneTreeDock::_tree_rmb(const Vector2& p_menu_pos) {
|
|||
|
||||
}
|
||||
|
||||
|
||||
void SceneTreeDock::_filter_changed(const String& p_filter) {
|
||||
|
||||
scene_tree->set_filter(p_filter);
|
||||
}
|
||||
|
||||
String SceneTreeDock::get_filter() {
|
||||
|
||||
return filter->get_text();
|
||||
}
|
||||
|
||||
void SceneTreeDock::set_filter(const String& p_filter){
|
||||
|
||||
filter->set_text(p_filter);
|
||||
scene_tree->set_filter(p_filter);
|
||||
}
|
||||
|
||||
void SceneTreeDock::_bind_methods() {
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("_tool_selected"),&SceneTreeDock::_tool_selected,DEFVAL(false));
|
||||
|
@ -1743,6 +1785,7 @@ void SceneTreeDock::_bind_methods() {
|
|||
ObjectTypeDB::bind_method(_MD("_nodes_dragged"),&SceneTreeDock::_nodes_dragged);
|
||||
ObjectTypeDB::bind_method(_MD("_files_dropped"),&SceneTreeDock::_files_dropped);
|
||||
ObjectTypeDB::bind_method(_MD("_tree_rmb"),&SceneTreeDock::_tree_rmb);
|
||||
ObjectTypeDB::bind_method(_MD("_filter_changed"),&SceneTreeDock::_filter_changed);
|
||||
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("instance"),&SceneTreeDock::instance);
|
||||
|
@ -1803,6 +1846,17 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor,Node *p_scene_root,EditorSelec
|
|||
hbc_top->add_child(tb);
|
||||
tool_buttons[TOOL_SCRIPT]=tb;
|
||||
|
||||
HBoxContainer *filter_hbc = memnew( HBoxContainer );
|
||||
vbc->add_child(filter_hbc);
|
||||
filter = memnew( LineEdit );
|
||||
filter->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||
filter_hbc->add_child(filter);
|
||||
filter_icon = memnew( TextureFrame );
|
||||
filter_hbc->add_child(filter_icon);
|
||||
filter->connect("text_changed",this,"_filter_changed");
|
||||
|
||||
|
||||
|
||||
|
||||
scene_tree = memnew( SceneTreeEditor(false,true,true ));
|
||||
vbc->add_child(scene_tree);
|
||||
|
@ -1917,5 +1971,12 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor,Node *p_scene_root,EditorSelec
|
|||
menu->connect("item_pressed",this,"_tool_selected");
|
||||
first_enter=true;
|
||||
|
||||
if (!EditorSettings::get_singleton()->get("scenetree_editor/display_old_action_buttons")) {
|
||||
for(int i=0;i<TOOL_BUTTON_MAX;i++) {
|
||||
tool_buttons[i]->hide();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
vbc->add_constant_override("separation",4);
|
||||
}
|
||||
|
|
|
@ -94,6 +94,9 @@ class SceneTreeDock : public VBoxContainer {
|
|||
EditorSubScene *import_subscene_dialog;
|
||||
EditorFileDialog *new_scene_from_dialog;
|
||||
|
||||
LineEdit *filter;
|
||||
TextureFrame *filter_icon;
|
||||
|
||||
PopupMenu * menu;
|
||||
|
||||
bool first_enter;
|
||||
|
@ -140,12 +143,17 @@ class SceneTreeDock : public VBoxContainer {
|
|||
|
||||
void _tree_rmb(const Vector2& p_menu_pos);
|
||||
|
||||
void _filter_changed(const String& p_filter);
|
||||
|
||||
protected:
|
||||
|
||||
void _notification(int p_what);
|
||||
static void _bind_methods();
|
||||
public:
|
||||
|
||||
String get_filter();
|
||||
void set_filter(const String& p_filter);
|
||||
|
||||
void import_subscene();
|
||||
void set_edited_scene(Node* p_scene);
|
||||
void instance(const String& p_path);
|
||||
|
|
|
@ -210,10 +210,10 @@ void SceneTreeEditor::_cell_button_pressed(Object *p_item,int p_column,int p_id)
|
|||
}
|
||||
}
|
||||
|
||||
void SceneTreeEditor::_add_nodes(Node *p_node,TreeItem *p_parent) {
|
||||
bool SceneTreeEditor::_add_nodes(Node *p_node,TreeItem *p_parent) {
|
||||
|
||||
if (!p_node)
|
||||
return;
|
||||
return false;
|
||||
|
||||
// only owned nodes are editable, since nodes can create their own (manually owned) child nodes,
|
||||
// which the editor needs not to know about.
|
||||
|
@ -227,7 +227,7 @@ void SceneTreeEditor::_add_nodes(Node *p_node,TreeItem *p_parent) {
|
|||
part_of_subscene=true;
|
||||
//allow
|
||||
} else {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
part_of_subscene = p_node!=get_scene_node() && get_scene_node()->get_scene_inherited_state().is_valid() && get_scene_node()->get_scene_inherited_state()->find_node_by_path(get_scene_node()->get_path_to(p_node))>=0;
|
||||
|
@ -345,10 +345,23 @@ void SceneTreeEditor::_add_nodes(Node *p_node,TreeItem *p_parent) {
|
|||
item->set_as_cursor(0);
|
||||
}
|
||||
|
||||
bool keep= ( filter==String() || String(p_node->get_name()).find(filter)!=-1 );
|
||||
|
||||
for (int i=0;i<p_node->get_child_count();i++) {
|
||||
|
||||
_add_nodes(p_node->get_child(i),item);
|
||||
bool child_keep = _add_nodes(p_node->get_child(i),item);
|
||||
|
||||
keep = keep || child_keep;
|
||||
|
||||
}
|
||||
|
||||
if (!keep) {
|
||||
memdelete(item);
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -700,6 +713,18 @@ void SceneTreeEditor::set_marked(Node *p_marked,bool p_selectable,bool p_childre
|
|||
|
||||
}
|
||||
|
||||
void SceneTreeEditor::set_filter(const String& p_filter) {
|
||||
|
||||
filter=p_filter;
|
||||
_update_tree();
|
||||
}
|
||||
|
||||
String SceneTreeEditor::get_filter() const {
|
||||
|
||||
return filter;
|
||||
}
|
||||
|
||||
|
||||
void SceneTreeEditor::set_display_foreign_nodes(bool p_display) {
|
||||
|
||||
display_foreign=p_display;
|
||||
|
@ -837,6 +862,9 @@ bool SceneTreeEditor::can_drop_data_fw(const Point2& p_point,const Variant& p_da
|
|||
|
||||
if (!can_rename)
|
||||
return false; //not editable tree
|
||||
if (filter!=String())
|
||||
return false; //can't rearrange tree with filter turned on
|
||||
|
||||
|
||||
Dictionary d=p_data;
|
||||
if (!d.has("type"))
|
||||
|
@ -913,6 +941,8 @@ void SceneTreeEditor::_rmb_select(const Vector2& p_pos) {
|
|||
emit_signal("rmb_pressed",tree->get_global_transform().xform(p_pos));
|
||||
}
|
||||
|
||||
|
||||
|
||||
void SceneTreeEditor::_bind_methods() {
|
||||
|
||||
ObjectTypeDB::bind_method("_tree_changed",&SceneTreeEditor::_tree_changed);
|
||||
|
@ -982,9 +1012,11 @@ SceneTreeEditor::SceneTreeEditor(bool p_label,bool p_can_rename, bool p_can_open
|
|||
add_child( tree );
|
||||
|
||||
tree->set_drag_forwarding(this);
|
||||
if (p_can_rename)
|
||||
if (p_can_rename) {
|
||||
tree->set_allow_rmb_select(true);
|
||||
tree->connect("item_rmb_selected",this,"_rmb_select");
|
||||
tree->connect("empty_tree_rmb_selected",this,"_rmb_select");
|
||||
}
|
||||
|
||||
tree->connect("cell_selected", this,"_selected_changed");
|
||||
tree->connect("item_edited", this,"_renamed",varray(),CONNECT_DEFERRED);
|
||||
|
|
|
@ -66,6 +66,8 @@ class SceneTreeEditor : public Control {
|
|||
PopupMenu *inheritance_menu;
|
||||
ObjectID instance_node;
|
||||
|
||||
String filter;
|
||||
|
||||
AcceptDialog *error;
|
||||
ConfirmationDialog *clear_inherit_confirm;
|
||||
|
||||
|
@ -73,7 +75,7 @@ class SceneTreeEditor : public Control {
|
|||
|
||||
void _compute_hash(Node *p_node,uint64_t &hash);
|
||||
|
||||
void _add_nodes(Node *p_node,TreeItem *p_parent);
|
||||
bool _add_nodes(Node *p_node,TreeItem *p_parent);
|
||||
void _test_update_tree();
|
||||
void _update_tree();
|
||||
void _tree_changed();
|
||||
|
@ -124,6 +126,8 @@ class SceneTreeEditor : public Control {
|
|||
|
||||
public:
|
||||
|
||||
void set_filter(const String& p_filter);
|
||||
String get_filter() const;
|
||||
|
||||
void set_undo_redo(UndoRedo *p_undo_redo) { undo_redo=p_undo_redo; };
|
||||
void set_display_foreign_nodes(bool p_display);
|
||||
|
|
Loading…
Reference in a new issue