Improved the Outliner live-search so that in the default scene, doing a simple search...
authorJoshua Leung <aligorith@gmail.com>
Fri, 23 Apr 2010 04:16:08 +0000 (04:16 +0000)
committerJoshua Leung <aligorith@gmail.com>
Fri, 23 Apr 2010 04:16:08 +0000 (04:16 +0000)
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).

source/blender/editors/space_outliner/outliner.c
source/blender/editors/space_outliner/outliner_intern.h

index 98dc62695fcc46c17b1c78a2de0c329c205f3a7a..8d28054fdaef24fce7859c411f3fe711a09e92fa 100644 (file)
@@ -1256,28 +1256,45 @@ static int outliner_filter_has_name(TreeElement *te, char *name, int flags)
        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);
 }
 
 
index 43e5517ecbc2841af453bac31c658cadfd587fa1..fa3078a365b966a0f6c281199a11a9427df57b8a 100644 (file)
@@ -141,21 +141,5 @@ void OUTLINER_OT_keyingset_remove_selected(struct wmOperatorType *ot);
 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 */