Revision: 28366
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=28366
Author:   aligorith
Date:     2010-04-23 05:53:05 +0200 (Fri, 23 Apr 2010)

Log Message:
-----------
Outliner Live-Search Bugfixes:

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?

Modified Paths:
--------------
    trunk/blender/release/scripts/ui/space_outliner.py
    trunk/blender/source/blender/editors/space_outliner/outliner.c
    trunk/blender/source/blender/editors/space_outliner/outliner_intern.h
    trunk/blender/source/blender/makesdna/DNA_space_types.h
    trunk/blender/source/blender/makesrna/intern/rna_space.c

Modified: trunk/blender/release/scripts/ui/space_outliner.py
===================================================================
--- trunk/blender/release/scripts/ui/space_outliner.py  2010-04-23 02:25:19 UTC 
(rev 28365)
+++ trunk/blender/release/scripts/ui/space_outliner.py  2010-04-23 03:53:05 UTC 
(rev 28366)
@@ -36,12 +36,13 @@
         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,7 +85,19 @@
         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 @@
 classes = [
     OUTLINER_HT_header,
     OUTLINER_MT_view,
+       OUTLINER_MT_search,
     OUTLINER_MT_edit_datablocks]
 
 

Modified: trunk/blender/source/blender/editors/space_outliner/outliner.c
===================================================================
--- trunk/blender/source/blender/editors/space_outliner/outliner.c      
2010-04-23 02:25:19 UTC (rev 28365)
+++ trunk/blender/source/blender/editors/space_outliner/outliner.c      
2010-04-23 03:53:05 UTC (rev 28366)
@@ -1240,14 +1240,18 @@
        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 @@
        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,18 +2692,8 @@
        TreeElement *te, *tes;
        
        for (te= lb->first; te; te= te->next) {
-               int found;
+               int found = outliner_filter_has_name(te, name, flags);
                
-               /* 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(found) {
                        /* name is right, but is element the previous one? */
                        if (prev) {
@@ -2752,7 +2748,7 @@
        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 @@
        /* 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 */

Modified: trunk/blender/source/blender/editors/space_outliner/outliner_intern.h
===================================================================
--- trunk/blender/source/blender/editors/space_outliner/outliner_intern.h       
2010-04-23 02:25:19 UTC (rev 28365)
+++ trunk/blender/source/blender/editors/space_outliner/outliner_intern.h       
2010-04-23 03:53:05 UTC (rev 28366)
@@ -99,12 +99,6 @@
 #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
 

Modified: trunk/blender/source/blender/makesdna/DNA_space_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_space_types.h     2010-04-23 
02:25:19 UTC (rev 28365)
+++ trunk/blender/source/blender/makesdna/DNA_space_types.h     2010-04-23 
03:53:05 UTC (rev 28366)
@@ -814,6 +814,10 @@
                /* 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

Modified: trunk/blender/source/blender/makesrna/intern/rna_space.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_space.c    2010-04-23 
02:25:19 UTC (rev 28365)
+++ trunk/blender/source/blender/makesrna/intern/rna_space.c    2010-04-23 
03:53:05 UTC (rev 28366)
@@ -759,20 +759,20 @@
        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 @@
        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)


_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to