Outliner Live-Search Bugfixes:
authorJoshua Leung <aligorith@gmail.com>
Fri, 23 Apr 2010 03:53:05 +0000 (03:53 +0000)
committerJoshua Leung <aligorith@gmail.com>
Fri, 23 Apr 2010 03:53:05 +0000 (03:53 +0000)
Ton's commits missed the RNA changes needed to make this work (i.e. the search field was un-defined). This has now been added, and the search field has the 'search eyeglass' icon to make its purpose clearer.

I've also taken this opportunity to restore the search matching flags (i.e. case sensitivity and complete vs partial matches), making these separate toggle options instead. The old searching operator stuff can probably be removed now?

release/scripts/ui/space_outliner.py
source/blender/editors/space_outliner/outliner.c
source/blender/editors/space_outliner/outliner_intern.h
source/blender/makesdna/DNA_space_types.h
source/blender/makesrna/intern/rna_space.c

index 129202117a17ea4619d8a827294aa415b56145ab..a0f8f41f58a4ba63b412dc5a4a264ec4acc1164b 100644 (file)
@@ -36,12 +36,13 @@ class OUTLINER_HT_header(bpy.types.Header):
         if context.area.show_menus:
             sub = row.row(align=True)
             sub.menu("OUTLINER_MT_view")
+            sub.menu("OUTLINER_MT_search")
             if space.display_mode == 'DATABLOCKS':
                 sub.menu("OUTLINER_MT_edit_datablocks")
 
         layout.prop(space, "display_mode", text="")
 
-        layout.prop(space, "display_filter", text="")
+        layout.prop(space, "display_filter", icon='VIEWZOOM', text="")
 
         layout.separator()
 
@@ -84,6 +85,18 @@ class OUTLINER_MT_view(bpy.types.Menu):
         layout.operator("screen.area_dupli")
         layout.operator("screen.screen_full_area")
 
+class OUTLINER_MT_search(bpy.types.Menu):
+    bl_label = "Search"
+
+    def draw(self, context):
+        layout = self.layout
+
+        space = context.space_data
+
+        col = layout.column()
+
+        col.prop(space, "match_case_sensitive")
+        col.prop(space, "match_complete")
 
 class OUTLINER_MT_edit_datablocks(bpy.types.Menu):
     bl_label = "Edit"
@@ -105,6 +118,7 @@ class OUTLINER_MT_edit_datablocks(bpy.types.Menu):
 classes = [
     OUTLINER_HT_header,
     OUTLINER_MT_view,
+       OUTLINER_MT_search,
     OUTLINER_MT_edit_datablocks]
 
 
index 349a158898de55a567f709d397c8848c3c7b81e5..98dc62695fcc46c17b1c78a2de0c329c205f3a7a 100644 (file)
@@ -1240,14 +1240,18 @@ static int outliner_filter_has_name(TreeElement *te, char *name, int flags)
        int found= 0;
        
        /* determine if match */
-       if(flags==OL_FIND)
-               found= BLI_strcasestr(te->name, name)!=NULL;
-       else if(flags==OL_FIND_CASE)
-               found= strstr(te->name, name)!=NULL;
-       else if(flags==OL_FIND_COMPLETE)
-               found= BLI_strcasecmp(te->name, name)==0;
-       else
-               found= strcmp(te->name, name)==0;
+       if (flags & SO_FIND_CASE_SENSITIVE) {
+               if (flags & SO_FIND_COMPLETE)
+                       found= strcmp(te->name, name) == 0;
+               else
+                       found= strstr(te->name, name) != NULL;
+       }
+       else {
+               if (flags & SO_FIND_COMPLETE)
+                       found= BLI_strcasecmp(te->name, name) == 0;
+               else
+                       found= BLI_strcasestr(te->name, name) != NULL;
+       }
        
        return found;
 }
@@ -1261,8 +1265,10 @@ static void outliner_filter_tree(SpaceOops *soops, ListBase *lb)
        for (te= lb->first; te; te= ten) {
                ten= te->next;
                
-               if(0==outliner_filter_has_name(te, soops->search_string, OL_FIND)) {
-                       
+               if(0==outliner_filter_has_name(te, soops->search_string, soops->search_flags)) {
+                       /* FIXME: users probably expect to be able to matches nested inside these non-matches... 
+                        *      i.e. searching for "Cu" under the default scene, users want the Cube, but scene fails so nothing appears
+                        */
                        outliner_free_tree(&te->subtree);
                        BLI_remlink(lb, te);
                        
@@ -2686,17 +2692,7 @@ static TreeElement *outliner_find_named(SpaceOops *soops, ListBase *lb, char *na
        TreeElement *te, *tes;
        
        for (te= lb->first; te; te= te->next) {
-               int found;
-               
-               /* determine if match */
-               if(flags==OL_FIND)
-                       found= BLI_strcasestr(te->name, name)!=NULL;
-               else if(flags==OL_FIND_CASE)
-                       found= strstr(te->name, name)!=NULL;
-               else if(flags==OL_FIND_COMPLETE)
-                       found= BLI_strcasecmp(te->name, name)==0;
-               else
-                       found= strcmp(te->name, name)==0;
+               int found = outliner_filter_has_name(te, name, flags);
                
                if(found) {
                        /* name is right, but is element the previous one? */
@@ -2752,7 +2748,7 @@ void outliner_find_panel(Scene *scene, ARegion *ar, SpaceOops *soops, int again,
        TreeElement *last_find;
        TreeStoreElem *tselem;
        int ytop, xdelta, prevFound=0;
-       char name[33];
+       char name[32];
        
        /* get last found tree-element based on stored search_tse */
        last_find= outliner_find_tse(soops, &soops->search_tse);
@@ -2760,7 +2756,7 @@ void outliner_find_panel(Scene *scene, ARegion *ar, SpaceOops *soops, int again,
        /* determine which type of search to do */
        if (again && last_find) {
                /* no popup panel - previous + user wanted to search for next after previous */         
-               BLI_strncpy(name, soops->search_string, 33);
+               BLI_strncpy(name, soops->search_string, sizeof(name));
                flags= soops->search_flags;
                
                /* try to find matching element */
index 1c34cb5ef871097651797d1a9ed8c30fea1f03f7..43e5517ecbc2841af453bac31c658cadfd587fa1 100644 (file)
@@ -99,12 +99,6 @@ typedef struct TreeElement {
 #define TSE_KEYMAP                     34
 #define TSE_KEYMAP_ITEM                35
 
-/* outliner search flags */
-#define OL_FIND                                        0
-#define OL_FIND_CASE                   1
-#define OL_FIND_COMPLETE               2
-#define OL_FIND_COMPLETE_CASE  3
-
 /* button events */
 #define OL_NAMEBUTTON          1
 
index aba56fbf52d0ab94eef7bc9afedf009a866bc3b5..e7ee04b23287d8b8933948fce5c3c02ef95c0156 100644 (file)
@@ -814,6 +814,10 @@ enum {
                /* if set, it allows redraws. gets set for some allqueue events */
 #define SO_TREESTORE_REDRAW            2
 
+/* outliner search flags (SpaceOops->search_flags) */
+#define SO_FIND_CASE_SENSITIVE         (1<<0)
+#define SO_FIND_COMPLETE                       (1<<1)
+
 /* headerbuttons: 450-499 */
 
 #define B_IMASELHOME           451
index d16e136bb94d844b90d8a7f044b61b2f5320b585..e816dbe94939bdca7322d5cc85bcf9c38e1c36b1 100644 (file)
@@ -759,20 +759,20 @@ static void rna_def_space_outliner(BlenderRNA *brna)
        PropertyRNA *prop;
 
        static EnumPropertyItem display_mode_items[] = {
-               {0, "ALL_SCENES", 0, "All Scenes", ""},
-               {1, "CURRENT_SCENE", 0, "Current Scene", ""},
-               {2, "VISIBLE_LAYERS", 0, "Visible Layers", ""},
-               {3, "SELECTED", 0, "Selected", ""},
-               {4, "ACTIVE", 0, "Active", ""},
-               {5, "SAME_TYPES", 0, "Same Types", ""},
-               {6, "GROUPS", 0, "Groups", ""},
-               {7, "LIBRARIES", 0, "Libraries", ""},
-               {10, "SEQUENCE", 0, "Sequence", ""},
-               {11, "DATABLOCKS", 0, "Datablocks", ""},
-               {12, "USER_PREFERENCES", 0, "User Preferences", ""},
-               {13, "KEYMAPS", 0, "Key Maps", ""},
+               {SO_ALL_SCENES, "ALL_SCENES", 0, "All Scenes", ""},
+               {SO_CUR_SCENE, "CURRENT_SCENE", 0, "Current Scene", ""},
+               {SO_VISIBLE, "VISIBLE_LAYERS", 0, "Visible Layers", ""},
+               {SO_SELECTED, "SELECTED", 0, "Selected", ""},
+               {SO_ACTIVE, "ACTIVE", 0, "Active", ""},
+               {SO_SAME_TYPE, "SAME_TYPES", 0, "Same Types", ""},
+               {SO_GROUPS, "GROUPS", 0, "Groups", ""},
+               {SO_LIBRARIES, "LIBRARIES", 0, "Libraries", ""},
+               {SO_SEQUENCE, "SEQUENCE", 0, "Sequence", ""},
+               {SO_DATABLOCKS, "DATABLOCKS", 0, "Datablocks", ""},
+               {SO_USERDEF, "USER_PREFERENCES", 0, "User Preferences", ""},
+               {SO_KEYMAP, "KEYMAPS", 0, "Key Maps", ""},
                {0, NULL, 0, NULL, NULL}};
-
+       
        srna= RNA_def_struct(brna, "SpaceOutliner", "Space");
        RNA_def_struct_sdna(srna, "SpaceOops");
        RNA_def_struct_ui_text(srna, "Space Outliner", "Outliner space data");
@@ -782,12 +782,26 @@ static void rna_def_space_outliner(BlenderRNA *brna)
        RNA_def_property_enum_items(prop, display_mode_items);
        RNA_def_property_ui_text(prop, "Display Mode", "Type of information to display");
        RNA_def_property_update(prop, NC_SPACE|ND_SPACE_OUTLINER, NULL);
-
+       
+       prop= RNA_def_property(srna, "display_filter", PROP_STRING, PROP_NONE);
+       RNA_def_property_string_sdna(prop, NULL, "search_string");
+       RNA_def_property_ui_text(prop, "Display Filter", "Live search filtering string");
+       RNA_def_property_update(prop, NC_SPACE|ND_SPACE_OUTLINER, NULL);
+       
+       prop= RNA_def_property(srna, "match_case_sensitive", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "search_flags", SO_FIND_CASE_SENSITIVE);
+       RNA_def_property_ui_text(prop, "Case Sensitive Matches Only", "Only use case sensitive matches of search string");
+       RNA_def_property_update(prop, NC_SPACE|ND_SPACE_OUTLINER, NULL);
+       
+       prop= RNA_def_property(srna, "match_complete", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "search_flags", SO_FIND_COMPLETE);
+       RNA_def_property_ui_text(prop, "Complete Matches Only", "Only use complete matches of search string");
+       RNA_def_property_update(prop, NC_SPACE|ND_SPACE_OUTLINER, NULL);
+       
        prop= RNA_def_property(srna, "show_restriction_columns", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SO_HIDE_RESTRICTCOLS);
-       RNA_def_property_ui_text(prop, "Show Restriction Columns", "Show colum");
+       RNA_def_property_ui_text(prop, "Show Restriction Columns", "Show column");
        RNA_def_property_update(prop, NC_SPACE|ND_SPACE_OUTLINER, NULL);
-
 }
 
 static void rna_def_background_image(BlenderRNA *brna)