summaryrefslogtreecommitdiff
path: root/tools/editor/property_editor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/editor/property_editor.cpp')
-rw-r--r--tools/editor/property_editor.cpp57
1 files changed, 49 insertions, 8 deletions
diff --git a/tools/editor/property_editor.cpp b/tools/editor/property_editor.cpp
index d6eae51fbd..31393ebcbc 100644
--- a/tools/editor/property_editor.cpp
+++ b/tools/editor/property_editor.cpp
@@ -2363,6 +2363,8 @@ void PropertyEditor::update_tree() {
TreeItem * current_category=NULL;
+ String filter = search_box ? search_box->get_text() : "";
+
for (List<PropertyInfo>::Element *I=plist.front() ; I ; I=I->next()) {
PropertyInfo& p = I->get();
@@ -2426,7 +2428,24 @@ void PropertyEditor::update_tree() {
} else if ( ! (p.usage&PROPERTY_USAGE_EDITOR ) )
continue;
+ String name = (p.name.find("/")!=-1)?p.name.right( p.name.find_last("/")+1 ):p.name;
+
+ if (capitalize_paths)
+ name = name.camelcase_to_underscore().capitalize();
+
String path=p.name.left( p.name.find_last("/") ) ;
+
+ if (use_filter && filter!="") {
+
+ String cat = path;
+
+ if (capitalize_paths)
+ cat = cat.capitalize();
+
+ if (cat.findn(filter)==-1 && name.findn(filter)==-1)
+ continue;
+ }
+
//printf("property %s\n",p.name.ascii().get_data());
TreeItem * parent = get_parent_node(path,item_path,current_category?current_category:root );
//if (parent->get_parent()==root)
@@ -2448,8 +2467,6 @@ void PropertyEditor::update_tree() {
TreeItem * item = tree->create_item( parent );
- String name = (p.name.find("/")!=-1)?p.name.right( p.name.find_last("/")+1 ):p.name;
-
if (level>0) {
item->set_custom_bg_color(0,col);
//item->set_custom_bg_color(1,col);
@@ -2465,11 +2482,7 @@ void PropertyEditor::update_tree() {
item->set_checked(0,p.usage&PROPERTY_USAGE_CHECKED);
}
- if (capitalize_paths)
- item->set_text( 0, name.camelcase_to_underscore().capitalize() );
- else
- item->set_text( 0, name );
-
+ item->set_text(0, name);
item->set_tooltip(0, p.name);
if (use_doc_hints) {
@@ -3403,6 +3416,11 @@ void PropertyEditor::_draw_flags(Object *t,const Rect2& p_rect) {
}
+void PropertyEditor::_filter_changed(const String& p_text) {
+
+ update_tree();
+}
+
void PropertyEditor::_bind_methods() {
ObjectTypeDB::bind_method( "_item_edited",&PropertyEditor::_item_edited);
@@ -3415,6 +3433,7 @@ void PropertyEditor::_bind_methods() {
ObjectTypeDB::bind_method( "_changed_callback",&PropertyEditor::_changed_callbacks);
ObjectTypeDB::bind_method( "_draw_flags",&PropertyEditor::_draw_flags);
ObjectTypeDB::bind_method( "_set_range_def",&PropertyEditor::_set_range_def);
+ ObjectTypeDB::bind_method( "_filter_changed",&PropertyEditor::_filter_changed);
ADD_SIGNAL( MethodInfo("property_toggled",PropertyInfo( Variant::STRING, "property"),PropertyInfo( Variant::BOOL, "value")));
ADD_SIGNAL( MethodInfo("resource_selected", PropertyInfo( Variant::OBJECT, "res"),PropertyInfo( Variant::STRING, "prop") ) );
@@ -3469,12 +3488,32 @@ void PropertyEditor::set_show_categories(bool p_show) {
update_tree();
}
+void PropertyEditor::set_use_filter(bool p_use) {
+
+ if (p_use==use_filter)
+ return;
+
+ use_filter=p_use;
+ update_tree();
+}
+
+void PropertyEditor::register_text_enter(Node* p_line_edit) {
+
+ ERR_FAIL_NULL(p_line_edit);
+ search_box=p_line_edit->cast_to<LineEdit>();
+
+ if (search_box)
+ search_box->connect("text_changed",this,"_filter_changed");
+
+}
+
PropertyEditor::PropertyEditor() {
_prop_edited="property_edited";
_prop_edited_name.push_back(String());
undo_redo=NULL;
obj=NULL;
+ search_box=NULL;
changing=false;
update_tree_pending=false;
@@ -3527,7 +3566,9 @@ PropertyEditor::PropertyEditor() {
show_categories=false;
refresh_countdown=0;
use_doc_hints=false;
-
+
+ use_filter=false;
+
}