summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorFranklin Sobrinho <franklin_gs@hotmail.com>2016-01-11 09:41:26 -0300
committerFranklin Sobrinho <franklin_gs@hotmail.com>2016-01-12 09:40:35 -0300
commit94a60f408aeb1b5b58dff0ab7ae03fa290ce2ba1 (patch)
tree89dda5423521fffb9a992e1c5271f06e1ee0f115 /tools
parent7f82c8d7c5cbcb07bddf98a5006706d1f77c4444 (diff)
Better search for SectionedPropertyEditor, added "All" section
Diffstat (limited to 'tools')
-rw-r--r--tools/editor/project_settings.cpp77
-rw-r--r--tools/editor/project_settings.h9
-rw-r--r--tools/editor/property_editor.cpp68
-rw-r--r--tools/editor/property_editor.h10
-rw-r--r--tools/editor/settings_config_dialog.cpp46
-rw-r--r--tools/editor/settings_config_dialog.h2
6 files changed, 88 insertions, 124 deletions
diff --git a/tools/editor/project_settings.cpp b/tools/editor/project_settings.cpp
index 6c5e18ec9a..26e8919375 100644
--- a/tools/editor/project_settings.cpp
+++ b/tools/editor/project_settings.cpp
@@ -60,9 +60,6 @@ void ProjectSettings::_notification(int p_what) {
if (p_what==NOTIFICATION_ENTER_TREE) {
- search_button->set_icon(get_icon("Zoom","EditorIcons"));
- clear_button->set_icon(get_icon("Close","EditorIcons"));
-
translation_list->connect("button_pressed",this,"_translation_delete");
_update_actions();
popup_add->add_icon_item(get_icon("Keyboard","EditorIcons"),"Key",InputEvent::KEY);
@@ -93,7 +90,9 @@ void ProjectSettings::_notification(int p_what) {
autoload_file_open->add_filter("*."+E->get());
}
+ } else if (p_what==NOTIFICATION_POST_POPUP) {
+ globals_editor->clear_search_box();
}
}
@@ -1339,32 +1338,6 @@ void ProjectSettings::_update_autoload() {
}
-void ProjectSettings::_toggle_search_bar(bool p_pressed) {
-
- globals_editor->get_property_editor()->set_use_filter(p_pressed);
-
- if (p_pressed) {
-
- search_bar->show();
- add_prop_bar->hide();
- search_box->grab_focus();
- search_box->select_all();
- } else {
-
- search_bar->hide();
- add_prop_bar->show();
- }
-}
-
-void ProjectSettings::_clear_search_box() {
-
- if (search_box->get_text()=="")
- return;
-
- search_box->clear();
- globals_editor->get_property_editor()->update_tree();
-}
-
void ProjectSettings::_bind_methods() {
ObjectTypeDB::bind_method(_MD("_item_selected"),&ProjectSettings::_item_selected);
@@ -1407,9 +1380,6 @@ void ProjectSettings::_bind_methods() {
ObjectTypeDB::bind_method(_MD("_autoload_delete"),&ProjectSettings::_autoload_delete);
ObjectTypeDB::bind_method(_MD("_autoload_edited"),&ProjectSettings::_autoload_edited);
- ObjectTypeDB::bind_method(_MD("_clear_search_box"),&ProjectSettings::_clear_search_box);
- ObjectTypeDB::bind_method(_MD("_toggle_search_bar"),&ProjectSettings::_toggle_search_bar);
-
}
ProjectSettings::ProjectSettings(EditorData *p_data) {
@@ -1440,77 +1410,50 @@ ProjectSettings::ProjectSettings(EditorData *p_data) {
hbc->set_h_size_flags(Control::SIZE_EXPAND_FILL);
props_base->add_child(hbc);
- search_button = memnew( ToolButton );
- search_button->set_toggle_mode(true);
- search_button->set_pressed(false);
- search_button->set_text("Search");
- hbc->add_child(search_button);
- search_button->connect("toggled",this,"_toggle_search_bar");
-
- hbc->add_child( memnew( VSeparator ) );
-
- add_prop_bar = memnew( HBoxContainer );
- add_prop_bar->set_h_size_flags(Control::SIZE_EXPAND_FILL);
- hbc->add_child(add_prop_bar);
-
Label *l = memnew( Label );
- add_prop_bar->add_child(l);
+ hbc->add_child(l);
l->set_text("Category:");
category = memnew( LineEdit );
category->set_h_size_flags(Control::SIZE_EXPAND_FILL);
- add_prop_bar->add_child(category);
+ hbc->add_child(category);
category->connect("text_entered",this,"_item_adds");
l = memnew( Label );
- add_prop_bar->add_child(l);
+ hbc->add_child(l);
l->set_text("Property:");
property = memnew( LineEdit );
property->set_h_size_flags(Control::SIZE_EXPAND_FILL);
- add_prop_bar->add_child(property);
+ hbc->add_child(property);
property->connect("text_entered",this,"_item_adds");
l = memnew( Label );
- add_prop_bar->add_child(l);
+ hbc->add_child(l);
l->set_text("Type:");
type = memnew( OptionButton );
type->set_h_size_flags(Control::SIZE_EXPAND_FILL);
- add_prop_bar->add_child(type);
+ hbc->add_child(type);
type->add_item("bool");
type->add_item("int");
type->add_item("float");
type->add_item("string");
Button *add = memnew( Button );
- add_prop_bar->add_child(add);
+ hbc->add_child(add);
add->set_text("Add");
add->connect("pressed",this,"_item_add");
Button *del = memnew( Button );
- add_prop_bar->add_child(del);
+ hbc->add_child(del);
del->set_text("Del");
del->connect("pressed",this,"_item_del");
- search_bar = memnew( HBoxContainer );
- search_bar->set_h_size_flags(Control::SIZE_EXPAND_FILL);
- hbc->add_child(search_bar);
- search_bar->hide();
-
- search_box = memnew( LineEdit );
- search_box->set_h_size_flags(Control::SIZE_EXPAND_FILL);
- search_bar->add_child(search_box);
-
- clear_button = memnew( ToolButton );
- search_bar->add_child(clear_button);
- clear_button->connect("pressed",this,"_clear_search_box");
-
globals_editor = memnew( SectionedPropertyEditor );
props_base->add_child(globals_editor);
//globals_editor->hide_top_label();
globals_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL);
- globals_editor->get_property_editor()->register_text_enter(search_box);
globals_editor->get_property_editor()->set_capitalize_paths(false);
globals_editor->get_property_editor()->get_scene_tree()->connect("cell_selected",this,"_item_selected");
globals_editor->get_property_editor()->connect("property_toggled",this,"_item_checked",varray(),CONNECT_DEFERRED);
diff --git a/tools/editor/project_settings.h b/tools/editor/project_settings.h
index b689340fdf..cbf24e7bfd 100644
--- a/tools/editor/project_settings.h
+++ b/tools/editor/project_settings.h
@@ -48,12 +48,6 @@ class ProjectSettings : public AcceptDialog {
UndoRedo *undo_redo;
SectionedPropertyEditor *globals_editor;
- HBoxContainer *search_bar;
- ToolButton *search_button;
- LineEdit *search_box;
- ToolButton *clear_button;
-
- HBoxContainer *add_prop_bar;
ConfirmationDialog *message;
LineEdit *category;
LineEdit *property;
@@ -142,9 +136,6 @@ class ProjectSettings : public AcceptDialog {
void _translation_res_option_changed();
void _translation_res_option_delete(Object *p_item,int p_column, int p_button);
- void _toggle_search_bar(bool p_pressed);
- void _clear_search_box();
-
ProjectSettings();
diff --git a/tools/editor/property_editor.cpp b/tools/editor/property_editor.cpp
index 9743dc7202..cc7db57145 100644
--- a/tools/editor/property_editor.cpp
+++ b/tools/editor/property_editor.cpp
@@ -3777,6 +3777,10 @@ class SectionedPropertyEditorFilter : public Object {
for (List<PropertyInfo>::Element *E=pinfo.front();E;E=E->next()) {
PropertyInfo pi=E->get();
+
+ if (section=="")
+ p_list->push_back(pi);
+
int sp = pi.name.find("/");
if (sp!=-1) {
String ss = pi.name.substr(0,sp);
@@ -3786,7 +3790,7 @@ class SectionedPropertyEditorFilter : public Object {
p_list->push_back(pi);
}
} else {
- if (section=="")
+ if (section=="global")
p_list->push_back(pi);
}
}
@@ -3811,10 +3815,18 @@ public:
};
+void SectionedPropertyEditor::_notification(int p_what) {
+
+ if (p_what==NOTIFICATION_ENTER_TREE) {
+
+ clear_button->set_icon(get_icon("Close", "EditorIcons"));
+ }
+}
void SectionedPropertyEditor::_bind_methods() {
ObjectTypeDB::bind_method("_section_selected",&SectionedPropertyEditor::_section_selected);
+ ObjectTypeDB::bind_method("_clear_search_box",&SectionedPropertyEditor::clear_search_box);
}
void SectionedPropertyEditor::_section_selected(int p_which) {
@@ -3822,9 +3834,30 @@ void SectionedPropertyEditor::_section_selected(int p_which) {
filter->set_section( sections->get_item_metadata(p_which) );
}
+void SectionedPropertyEditor::clear_search_box() {
+
+ if (search_box->get_text().strip_edges()=="")
+ return;
+
+ search_box->clear();
+ editor->update_tree();
+}
+
+
String SectionedPropertyEditor::get_current_section() const {
- return sections->get_item_metadata( sections->get_current() );
+ String section = sections->get_item_metadata( sections->get_current() );
+
+ if (section=="") {
+ String name = editor->get_selected_path();
+
+ int sp = name.find("/");
+ if (sp!=-1)
+ section = name.substr(0, sp);
+
+ }
+
+ return section;
}
String SectionedPropertyEditor::get_full_item_path(const String& p_item) {
@@ -3844,11 +3877,20 @@ void SectionedPropertyEditor::edit(Object* p_object) {
sections->clear();
Set<String> existing_sections;
+
+ existing_sections.insert("");
+ sections->add_item("All");
+ sections->set_item_metadata(0, "");
+
for (List<PropertyInfo>::Element *E=pinfo.front();E;E=E->next()) {
PropertyInfo pi=E->get();
+
if (pi.usage&PROPERTY_USAGE_CATEGORY)
continue;
+ if ( !(pi.usage&PROPERTY_USAGE_EDITOR) )
+ continue;
+
if (pi.name.find(":")!=-1 || pi.name=="script/script")
continue;
int sp = pi.name.find("/");
@@ -3861,10 +3903,10 @@ void SectionedPropertyEditor::edit(Object* p_object) {
}
} else {
- if (!existing_sections.has("")) {
- existing_sections.insert("");
+ if (!existing_sections.has("global")) {
+ existing_sections.insert("global");
sections->add_item("Global");
- sections->set_item_metadata(sections->get_item_count()-1,"");
+ sections->set_item_metadata(sections->get_item_count()-1,"global");
}
}
@@ -3889,6 +3931,8 @@ PropertyEditor *SectionedPropertyEditor::get_property_editor() {
SectionedPropertyEditor::SectionedPropertyEditor() {
+ add_constant_override("separation", 8);
+
VBoxContainer *left_vb = memnew( VBoxContainer);
left_vb->set_custom_minimum_size(Size2(160,0));
add_child(left_vb);
@@ -3903,7 +3947,21 @@ SectionedPropertyEditor::SectionedPropertyEditor() {
add_child(right_vb);
filter = memnew( SectionedPropertyEditorFilter );
+
+ HBoxContainer *hbc = memnew( HBoxContainer );
+ right_vb->add_margin_child("Search:",hbc);
+
+ search_box = memnew( LineEdit );
+ search_box->set_h_size_flags(SIZE_EXPAND_FILL);
+ hbc->add_child(search_box);
+
+ clear_button = memnew( ToolButton );
+ hbc->add_child(clear_button);
+ clear_button->connect("pressed", this, "_clear_search_box");
+
editor = memnew( PropertyEditor );
+ editor->register_text_enter(search_box);
+ editor->set_use_filter(true);
editor->set_v_size_flags(SIZE_EXPAND_FILL);
right_vb->add_margin_child("Properties:",editor,true);
diff --git a/tools/editor/property_editor.h b/tools/editor/property_editor.h
index 63ad090901..5dc2f6d154 100644
--- a/tools/editor/property_editor.h
+++ b/tools/editor/property_editor.h
@@ -259,12 +259,16 @@ class SectionedPropertyEditor : public HBoxContainer {
OBJ_TYPE(SectionedPropertyEditor,HBoxContainer);
ItemList *sections;
SectionedPropertyEditorFilter *filter;
+ LineEdit *search_box;
+ ToolButton *clear_button;
PropertyEditor *editor;
-
- static void _bind_methods();
void _section_selected(int p_which);
+protected:
+
+ void _notification(int p_what);
+ static void _bind_methods();
public:
PropertyEditor *get_property_editor();
@@ -272,6 +276,8 @@ public:
String get_full_item_path(const String& p_item);
String get_current_section() const;
+ void clear_search_box();
+
SectionedPropertyEditor();
~SectionedPropertyEditor();
};
diff --git a/tools/editor/settings_config_dialog.cpp b/tools/editor/settings_config_dialog.cpp
index ebbc488ff2..3d30b3882d 100644
--- a/tools/editor/settings_config_dialog.cpp
+++ b/tools/editor/settings_config_dialog.cpp
@@ -73,9 +73,6 @@ void EditorSettingsDialog::popup_edit_settings() {
property_editor->edit(EditorSettings::get_singleton());
property_editor->get_property_editor()->update_tree();
- search_box->select_all();
- search_box->grab_focus();
-
popup_centered_ratio(0.7);
}
@@ -248,22 +245,15 @@ void EditorSettingsDialog::_update_plugins() {
}
-void EditorSettingsDialog::_clear_search_box() {
-
- if (search_box->get_text()=="")
- return;
-
- search_box->clear();
- property_editor->get_property_editor()->update_tree();
-}
-
void EditorSettingsDialog::_notification(int p_what) {
if (p_what==NOTIFICATION_ENTER_TREE) {
rescan_plugins->set_icon(get_icon("Reload","EditorIcons"));
- clear_button->set_icon(get_icon("Close","EditorIcons"));
_update_plugins();
+ } else if (p_what==NOTIFICATION_POST_POPUP) {
+
+ property_editor->clear_search_box();
}
}
@@ -275,7 +265,6 @@ void EditorSettingsDialog::_bind_methods() {
ObjectTypeDB::bind_method(_MD("_plugin_settings"),&EditorSettingsDialog::_plugin_settings);
ObjectTypeDB::bind_method(_MD("_plugin_edited"),&EditorSettingsDialog::_plugin_edited);
ObjectTypeDB::bind_method(_MD("_plugin_install"),&EditorSettingsDialog::_plugin_install);
- ObjectTypeDB::bind_method(_MD("_clear_search_box"),&EditorSettingsDialog::_clear_search_box);
}
EditorSettingsDialog::EditorSettingsDialog() {
@@ -286,38 +275,17 @@ EditorSettingsDialog::EditorSettingsDialog() {
add_child(tabs);
set_child_rect(tabs);
- VBoxContainer *vbc = memnew( VBoxContainer );
- tabs->add_child(vbc);
- vbc->set_name("General");
-
- HBoxContainer *hbc = memnew( HBoxContainer );
- hbc->set_h_size_flags(Control::SIZE_EXPAND_FILL);
- vbc->add_child(hbc);
-
- Label *l = memnew( Label );
- l->set_text("Search: ");
- hbc->add_child(l);
-
- search_box = memnew( LineEdit );
- search_box->set_h_size_flags(Control::SIZE_EXPAND_FILL);
- hbc->add_child(search_box);
-
- clear_button = memnew( ToolButton );
- hbc->add_child(clear_button);
- clear_button->connect("pressed",this,"_clear_search_box");
-
property_editor = memnew( SectionedPropertyEditor );
//property_editor->hide_top_label();
- property_editor->get_property_editor()->set_use_filter(true);
- property_editor->get_property_editor()->register_text_enter(search_box);
+ property_editor->set_name("General");
property_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL);
- vbc->add_child(property_editor);
+ tabs->add_child(property_editor);
- vbc = memnew( VBoxContainer );
+ VBoxContainer *vbc = memnew( VBoxContainer );
tabs->add_child(vbc);
vbc->set_name("Plugins");
- hbc = memnew( HBoxContainer );
+ HBoxContainer *hbc = memnew( HBoxContainer );
vbc->add_child(hbc);
hbc->add_child( memnew( Label("Plugin List: ")));
hbc->add_spacer();
diff --git a/tools/editor/settings_config_dialog.h b/tools/editor/settings_config_dialog.h
index e1c3238a64..119b4035ca 100644
--- a/tools/editor/settings_config_dialog.h
+++ b/tools/editor/settings_config_dialog.h
@@ -51,8 +51,6 @@ class EditorSettingsDialog : public AcceptDialog {
Button *rescan_plugins;
Tree *plugins;
- LineEdit *search_box;
- ToolButton *clear_button;
SectionedPropertyEditor *property_editor;
Timer *timer;