summaryrefslogtreecommitdiff
path: root/tools/editor/property_editor.cpp
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/editor/property_editor.cpp
parent7f82c8d7c5cbcb07bddf98a5006706d1f77c4444 (diff)
Better search for SectionedPropertyEditor, added "All" section
Diffstat (limited to 'tools/editor/property_editor.cpp')
-rw-r--r--tools/editor/property_editor.cpp68
1 files changed, 63 insertions, 5 deletions
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);