1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-06 12:20:30 +00:00
This commit is contained in:
Juan Linietsky
2016-01-23 17:21:37 -03:00
6 changed files with 124 additions and 88 deletions

View File

@@ -3777,10 +3777,6 @@ 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);
@@ -3790,7 +3786,7 @@ class SectionedPropertyEditorFilter : public Object {
p_list->push_back(pi);
}
} else {
if (section=="global")
if (section=="")
p_list->push_back(pi);
}
}
@@ -3815,18 +3811,10 @@ 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) {
@@ -3834,30 +3822,9 @@ 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 {
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;
return sections->get_item_metadata( sections->get_current() );
}
String SectionedPropertyEditor::get_full_item_path(const String& p_item) {
@@ -3877,20 +3844,11 @@ 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("/");
@@ -3903,10 +3861,10 @@ void SectionedPropertyEditor::edit(Object* p_object) {
}
} else {
if (!existing_sections.has("global")) {
existing_sections.insert("global");
if (!existing_sections.has("")) {
existing_sections.insert("");
sections->add_item("Global");
sections->set_item_metadata(sections->get_item_count()-1,"global");
sections->set_item_metadata(sections->get_item_count()-1,"");
}
}
@@ -3931,8 +3889,6 @@ 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);
@@ -3947,21 +3903,7 @@ 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);