diff options
author | Joshua Leung <aligorith@gmail.com> | 2010-04-23 08:16:08 +0400 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2010-04-23 08:16:08 +0400 |
commit | 967c2d55f76b41c688fc1a705baa81117160bf0b (patch) | |
tree | dda418153ba0161ebcc5936fb1fbaaa4c56b8f1c /source/blender/editors/space_outliner | |
parent | eba8672f123d2e5d91c8b3b8b5d97b33c122797e (diff) |
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).
Diffstat (limited to 'source/blender/editors/space_outliner')
-rw-r--r-- | source/blender/editors/space_outliner/outliner.c | 37 | ||||
-rw-r--r-- | source/blender/editors/space_outliner/outliner_intern.h | 16 |
2 files changed, 27 insertions, 26 deletions
diff --git a/source/blender/editors/space_outliner/outliner.c b/source/blender/editors/space_outliner/outliner.c index 98dc62695fc..8d28054fdae 100644 --- a/source/blender/editors/space_outliner/outliner.c +++ b/source/blender/editors/space_outliner/outliner.c @@ -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); } diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h index 43e5517ecbc..fa3078a365b 100644 --- a/source/blender/editors/space_outliner/outliner_intern.h +++ b/source/blender/editors/space_outliner/outliner_intern.h @@ -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 */ |