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

Log Message:
-----------
Improved the Outliner live-search so that in the default scene, doing a simple 
search for "cu" (to show the default cube only) will show the matching item. 

Previously, because the 'Scene' item is encountered first, all sub-items like 
this would be ignored. Now, when a non-matching item is encountered, it's 
subtree is checked as per normal, as long as the item was expanded (so that its 
subtree is still visible).

Modified Paths:
--------------
    trunk/blender/source/blender/editors/space_outliner/outliner.c
    trunk/blender/source/blender/editors/space_outliner/outliner_intern.h

Modified: trunk/blender/source/blender/editors/space_outliner/outliner.c
===================================================================
--- trunk/blender/source/blender/editors/space_outliner/outliner.c      
2010-04-23 03:53:05 UTC (rev 28366)
+++ trunk/blender/source/blender/editors/space_outliner/outliner.c      
2010-04-23 04:16:08 UTC (rev 28367)
@@ -1256,28 +1256,45 @@
        return found;
 }
 
-static void outliner_filter_tree(SpaceOops *soops, ListBase *lb)
+static int outliner_filter_tree(SpaceOops *soops, ListBase *lb)
 {
        TreeElement *te, *ten;
+       TreeStoreElem *tselem;
        
-       if(soops->search_string[0]==0) return;
+       /* although we don't have any search string, we return TRUE 
+        * since the entire tree is ok then...
+        */
+       if (soops->search_string[0]==0) 
+               return 1;
 
        for (te= lb->first; te; te= ten) {
                ten= te->next;
                
-               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
+               if (0==outliner_filter_has_name(te, soops->search_string, 
soops->search_flags)) {
+                       /* item isn't something we're looking for, but...
+                        *      - if the subtree is expanded, check if there 
are any matches that can be easily found
+                        *              so that searching for "cu" in the 
default scene will still match the Cube
+                        *      - otherwise, we can't see within the subtree 
and the item doesn't match,
+                        *              so these can be safely ignored (i.e. 
the subtree can get freed)
                         */
-                       outliner_free_tree(&te->subtree);
-                       BLI_remlink(lb, te);
+                       tselem= TREESTORE(te);
                        
-                       if(te->flag & TE_FREE_NAME) MEM_freeN(te->name);
-                       MEM_freeN(te);
+                       if ((tselem->flag & TSE_CLOSED) || 
outliner_filter_tree(soops, &te->subtree)==0) { 
+                               outliner_free_tree(&te->subtree);
+                               BLI_remlink(lb, te);
+                               
+                               if(te->flag & TE_FREE_NAME) MEM_freeN(te->name);
+                               MEM_freeN(te);
+                       }
                }
-               else
+               else {
+                       /* filter subtree too */
                        outliner_filter_tree(soops, &te->subtree);
+               }
        }
+       
+       /* if there are still items in the list, that means that there were 
still some matches */
+       return (lb->first != NULL);
 }
 
 

Modified: trunk/blender/source/blender/editors/space_outliner/outliner_intern.h
===================================================================
--- trunk/blender/source/blender/editors/space_outliner/outliner_intern.h       
2010-04-23 03:53:05 UTC (rev 28366)
+++ trunk/blender/source/blender/editors/space_outliner/outliner_intern.h       
2010-04-23 04:16:08 UTC (rev 28367)
@@ -141,21 +141,5 @@
 void OUTLINER_OT_drivers_add_selected(struct wmOperatorType *ot);
 void OUTLINER_OT_drivers_delete_selected(struct wmOperatorType *ot);
 
-#if 0
-extern void outliner_mouse_event(Scene *scene, ARegion *ar, SpaceOops *soops, 
short event);
-extern void outliner_toggle_visible(SpaceOops *soops);
-extern void outliner_show_active(ARegion *ar, SpaceOops *soops);
-extern void outliner_show_hierarchy(Scene *scene, SpaceOops *soops);
-extern void outliner_one_level(SpaceOops *soops, int add);
-extern void outliner_select(Scene *scene, SpaceOops *soops);
-extern void outliner_toggle_selected(Scene *scene, SpaceOops *soops);
-extern void outliner_toggle_visibility(Scene *scene, SpaceOops *soops);
-extern void outliner_toggle_selectability(Scene *scene, SpaceOops *soops);
-extern void outliner_toggle_renderability(Scene *scene, SpaceOops *soops);
-extern void outliner_del(Scene *scene, SpaceOops *soops);
-extern void outliner_page_up_down(Scene *scene, ARegion *ar, SpaceOops *soops, 
int up);
-extern void outliner_find_panel(Scene *scene, ARegion *ar, SpaceOops *soops, 
int again, int flags);
-#endif
-
 #endif /* ED_OUTLINER_INTERN_H */
 


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

Reply via email to