Page MenuHome

outlinersearch5.patch

Authored By
Shane Ambler (sambler)
Nov 13 2013, 2:23 PM
Size
16 KB
Subscribers
None

outlinersearch5.patch

Index: source/blender/editors/space_outliner/outliner_draw.c
===================================================================
--- source/blender/editors/space_outliner/outliner_draw.c (revision 39325)
+++ source/blender/editors/space_outliner/outliner_draw.c (working copy)
@@ -99,7 +99,7 @@ static void outliner_height(SpaceOops *soops, ListBase *lb, int *h)
TreeElement *te= lb->first;
while(te) {
TreeStoreElem *tselem= TREESTORE(te);
- if((tselem->flag & TSE_CLOSED)==0)
+ if(TSELEM_OPEN(tselem))
outliner_height(soops, &te->subtree, h);
(*h) += UI_UNIT_Y;
te= te->next;
@@ -114,7 +114,7 @@ static void outliner_width(SpaceOops *soops, ListBase *lb, int *w)
// TreeStoreElem *tselem= TREESTORE(te);
// XXX fixme... te->xend is not set yet
- if(tselem->flag & TSE_CLOSED) {
+ if(!TSELEM_OPEN(tselem)) {
if (te->xend > *w)
*w = te->xend;
}
@@ -137,7 +137,7 @@ static void outliner_rna_width(SpaceOops *soops, ListBase *lb, int *w, int start
if(startx+100 > *w)
*w = startx+100;
- if((tselem->flag & TSE_CLOSED)==0)
+ if(TSELEM_OPEN(tselem))
outliner_rna_width(soops, &te->subtree, w, startx+UI_UNIT_X);
te= te->next;
}
@@ -521,7 +521,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar
}
}
- if((tselem->flag & TSE_CLOSED)==0) outliner_draw_restrictbuts(block, scene, ar, soops, &te->subtree);
+ if(TSELEM_OPEN(tselem)) outliner_draw_restrictbuts(block, scene, ar, soops, &te->subtree);
}
}
@@ -562,7 +562,7 @@ static void outliner_draw_rnabuts(uiBlock *block, Scene *scene, ARegion *ar, Spa
ptr= &te->rnaptr;
prop= te->directdata;
- if(!(RNA_property_type(prop) == PROP_POINTER && (tselem->flag & TSE_CLOSED)==0))
+ if(!(RNA_property_type(prop) == PROP_POINTER && (TSELEM_OPEN(tselem))) )
uiDefAutoButR(block, ptr, prop, -1, "", ICON_NONE, sizex, (int)te->ys, OL_RNA_COL_SIZEX, UI_UNIT_Y-1);
}
else if(tselem->type == TSE_RNA_ARRAY_ELEM) {
@@ -573,7 +573,7 @@ static void outliner_draw_rnabuts(uiBlock *block, Scene *scene, ARegion *ar, Spa
}
}
- if((tselem->flag & TSE_CLOSED)==0) outliner_draw_rnabuts(block, scene, ar, soops, sizex, &te->subtree);
+ if(TSELEM_OPEN(tselem)) outliner_draw_rnabuts(block, scene, ar, soops, sizex, &te->subtree);
}
}
@@ -830,7 +830,7 @@ static void outliner_draw_keymapbuts(uiBlock *block, ARegion *ar, SpaceOops *soo
}
}
- if((tselem->flag & TSE_CLOSED)==0) outliner_draw_keymapbuts(block, ar, soops, &te->subtree);
+ if(TSELEM_OPEN(tselem)) outliner_draw_keymapbuts(block, ar, soops, &te->subtree);
}
}
@@ -873,7 +873,7 @@ static void outliner_buttons(const bContext *C, uiBlock *block, ARegion *ar, Spa
}
}
- if((tselem->flag & TSE_CLOSED)==0) outliner_buttons(C, block, ar, soops, &te->subtree);
+ if(TSELEM_OPEN(tselem)) outliner_buttons(C, block, ar, soops, &te->subtree);
}
}
@@ -1257,6 +1257,15 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene
glEnable(GL_BLEND);
+ /* start by highlighting search matches */
+ /* we don't expand items when searching in the datablocks but we
+ still want to highlight any filter matches. */
+ if( (searching || (soops->outlinevis==SO_DATABLOCKS && soops->search_string[0]!=0)) && (tselem->flag & TSE_SEARCHMATCH) ) {
+ /* TODO - add search highlight colour to theme? */
+ glColor4f(0.0f, 0.8f, 0.0f, 0.3f);
+ glRecti(startx, *starty, xmax, *starty+UI_UNIT_Y);
+ }
+
/* colors for active/selected data */
if(tselem->type==0) {
if(te->idcode==ID_SCE) {
@@ -1337,10 +1346,10 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene
icon_x = startx+5*ufac;
// icons a bit higher
- if(tselem->flag & TSE_CLOSED)
- UI_icon_draw((float)icon_x, (float)*starty+2*ufac, ICON_DISCLOSURE_TRI_RIGHT);
- else
+ if(TSELEM_OPEN(tselem))
UI_icon_draw((float)icon_x, (float)*starty+2*ufac, ICON_DISCLOSURE_TRI_DOWN);
+ else
+ UI_icon_draw((float)icon_x, (float)*starty+2*ufac, ICON_DISCLOSURE_TRI_RIGHT);
}
offsx+= UI_UNIT_X;
@@ -1376,7 +1385,7 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene
offsx+= (int)(UI_UNIT_X + UI_GetStringWidth(te->name));
/* closed item, we draw the icons, not when it's a scene, or master-server list though */
- if(tselem->flag & TSE_CLOSED) {
+ if(!TSELEM_OPEN(tselem)) {
if(te->subtree.first) {
if(tselem->type==0 && te->idcode==ID_SCE);
else if(tselem->type!=TSE_R_LAYER) { /* this tree element always has same amount of branches, so dont draw */
@@ -1402,7 +1411,7 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene
te->ys= (float)*starty;
te->xend= startx+offsx;
- if((tselem->flag & TSE_CLOSED)==0) {
+ if(TSELEM_OPEN(tselem)) {
*starty-= UI_UNIT_Y;
for(ten= te->subtree.first; ten; ten= ten->next)
@@ -1435,7 +1444,7 @@ static void outliner_draw_hierarchy(SpaceOops *soops, ListBase *lb, int startx,
*starty-= UI_UNIT_Y;
- if((tselem->flag & TSE_CLOSED)==0)
+ if(TSELEM_OPEN(tselem))
outliner_draw_hierarchy(soops, &te->subtree, startx+UI_UNIT_X, starty);
}
@@ -1459,12 +1468,12 @@ static void outliner_draw_struct_marks(ARegion *ar, SpaceOops *soops, ListBase *
tselem= TREESTORE(te);
/* selection status */
- if((tselem->flag & TSE_CLOSED)==0)
+ if(TSELEM_OPEN(tselem))
if(tselem->type == TSE_RNA_STRUCT)
glRecti(0, *starty+1, (int)ar->v2d.cur.xmax+V2D_SCROLL_WIDTH, *starty+UI_UNIT_Y-1);
*starty-= UI_UNIT_Y;
- if((tselem->flag & TSE_CLOSED)==0) {
+ if(TSELEM_OPEN(tselem)) {
outliner_draw_struct_marks(ar, soops, &te->subtree, starty);
if(tselem->type == TSE_RNA_STRUCT)
fdrawline(0, (float)*starty+UI_UNIT_Y, ar->v2d.cur.xmax+V2D_SCROLL_WIDTH, (float)*starty+UI_UNIT_Y);
@@ -1485,7 +1494,7 @@ static void outliner_draw_selection(ARegion *ar, SpaceOops *soops, ListBase *lb,
glRecti(0, *starty+1, (int)ar->v2d.cur.xmax, *starty+UI_UNIT_Y-1);
}
*starty-= UI_UNIT_Y;
- if((tselem->flag & TSE_CLOSED)==0) outliner_draw_selection(ar, soops, &te->subtree, starty);
+ if(TSELEM_OPEN(tselem)) outliner_draw_selection(ar, soops, &te->subtree, starty);
}
}
Index: source/blender/editors/space_outliner/outliner_edit.c
===================================================================
--- source/blender/editors/space_outliner/outliner_edit.c (revision 39325)
+++ source/blender/editors/space_outliner/outliner_edit.c (working copy)
@@ -659,7 +659,7 @@ static void outliner_set_coordinates_element(SpaceOops *soops, TreeElement *te,
te->ys= (float)(*starty);
*starty-= UI_UNIT_Y;
- if((tselem->flag & TSE_CLOSED)==0) {
+ if(TSELEM_OPEN(tselem)) {
TreeElement *ten;
for(ten= te->subtree.first; ten; ten= ten->next) {
outliner_set_coordinates_element(soops, ten, startx+UI_UNIT_X, starty);
@@ -882,7 +882,7 @@ static void tree_element_show_hierarchy(Scene *scene, SpaceOops *soops, ListBase
}
else tselem->flag |= TSE_CLOSED;
- if(tselem->flag & TSE_CLOSED); else tree_element_show_hierarchy(scene, soops, &te->subtree);
+ if(TSELEM_OPEN(tselem)) tree_element_show_hierarchy(scene, soops, &te->subtree);
}
}
@@ -1147,7 +1147,7 @@ static void do_outliner_drivers_editop(SpaceOops *soops, ListBase *tree, ReportL
}
/* go over sub-tree */
- if ((tselem->flag & TSE_CLOSED)==0)
+ if (TSELEM_OPEN(tselem))
do_outliner_drivers_editop(soops, &te->subtree, reports, mode);
}
}
@@ -1315,7 +1315,7 @@ static void do_outliner_keyingset_editop(SpaceOops *soops, KeyingSet *ks, ListBa
}
/* go over sub-tree */
- if ((tselem->flag & TSE_CLOSED)==0)
+ if (TSELEM_OPEN(tselem))
do_outliner_keyingset_editop(soops, ks, &te->subtree, mode);
}
}
Index: source/blender/editors/space_outliner/outliner_intern.h
===================================================================
--- source/blender/editors/space_outliner/outliner_intern.h (revision 39325)
+++ source/blender/editors/space_outliner/outliner_intern.h (working copy)
@@ -128,6 +128,30 @@ typedef struct TreeElement {
#define OL_RNA_COL_SPACEX (UI_UNIT_X*2.5)
+/* Outliner Searching --
+
+ Are we looking for something in the outliner?
+ If so finding matches in child items makes it more useful
+
+ - We want to flag parents to act as being open to filter child matches
+ - and also flag matches so we can highlight them
+ - Flags are stored in TreeStoreElem->flag
+ - Flag options defined in DNA_outliner_types.h
+
+ - NOT in datablocks view - searching all datablocks takes way too long
+ to be useful
+ - not searching into RNA items helps but isn't the complete solution
+
+ - searching variable is global to outliner files so we only set it once
+ per tree build - set in outliner_build_tree
+
+ - variable definition in outliner_tree.c
+ */
+extern int searching;
+
+/* is the currrent element open? if so we also show children */
+#define TSELEM_OPEN(telm) ( (telm->flag & TSE_CLOSED)==0 || (searching && (telm->flag & TSE_CHILDSEARCH)) )
+
/* outliner_tree.c ----------------------------------------------- */
void outliner_free_tree(ListBase *lb);
Index: source/blender/editors/space_outliner/outliner_select.c
===================================================================
--- source/blender/editors/space_outliner/outliner_select.c (revision 39325)
+++ source/blender/editors/space_outliner/outliner_select.c (working copy)
@@ -133,7 +133,7 @@ void outliner_select(SpaceOops *soops, ListBase *lb, int *index, short *selectin
tselem->flag &= ~TSE_SELECTED;
}
}
- else if ((tselem->flag & TSE_CLOSED)==0) {
+ else if (TSELEM_OPEN(tselem)) {
/* Only try selecting sub-elements if we haven't hit the right element yet
*
* Hack warning:
Index: source/blender/editors/space_outliner/outliner_tools.c
===================================================================
--- source/blender/editors/space_outliner/outliner_tools.c (revision 39325)
+++ source/blender/editors/space_outliner/outliner_tools.c (working copy)
@@ -147,7 +147,7 @@ static void set_operation_types(SpaceOops *soops, ListBase *lb,
}
}
}
- if((tselem->flag & TSE_CLOSED)==0) {
+ if(TSELEM_OPEN(tselem)) {
set_operation_types(soops, &te->subtree,
scenelevel, objectlevel, idlevel, datalevel);
}
@@ -256,7 +256,7 @@ static void outliner_do_libdata_operation(bContext *C, Scene *scene, SpaceOops *
operation_cb(C, scene, te, tsep, tselem);
}
}
- if((tselem->flag & TSE_CLOSED)==0) {
+ if(TSELEM_OPEN(tselem)) {
outliner_do_libdata_operation(C, scene, soops, &te->subtree, operation_cb);
}
}
@@ -398,7 +398,7 @@ void outliner_do_object_operation(bContext *C, Scene *scene_act, SpaceOops *soop
operation_cb(C, scene_owner ? scene_owner : scene_act, te, NULL, tselem);
}
}
- if((tselem->flag & TSE_CLOSED)==0) {
+ if(TSELEM_OPEN(tselem)) {
outliner_do_object_operation(C, scene_act, soops, &te->subtree, operation_cb);
}
}
@@ -509,7 +509,7 @@ static void outliner_do_data_operation(SpaceOops *soops, int type, int event, Li
operation_cb(event, te, tselem);
}
}
- if((tselem->flag & TSE_CLOSED)==0) {
+ if(TSELEM_OPEN(tselem)) {
outliner_do_data_operation(soops, type, event, &te->subtree, operation_cb);
}
}
@@ -838,7 +838,7 @@ static void outliner_do_id_set_operation(SpaceOops *soops, int type, ListBase *l
operation_cb(te, tselem, tsep, newid);
}
}
- if ((tselem->flag & TSE_CLOSED)==0) {
+ if (TSELEM_OPEN(tselem)) {
outliner_do_id_set_operation(soops, type, &te->subtree, newid, operation_cb);
}
}
Index: source/blender/editors/space_outliner/outliner_tree.c
===================================================================
--- source/blender/editors/space_outliner/outliner_tree.c (revision 39325)
+++ source/blender/editors/space_outliner/outliner_tree.c (working copy)
@@ -119,6 +119,10 @@
/* ********************************************************* */
/* Persistant Data */
+/* see outliner_intern.h for more info */
+int searching=0;
+
+
static void outliner_storage_cleanup(SpaceOops *soops)
{
TreeStore *ts= soops->treestore;
@@ -835,6 +839,10 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i
check_persistant(soops, te, id, type, index);
tselem= TREESTORE(te);
+ /* if we are searching for something expand to see child elements */
+ if(searching)
+ tselem->flag |= TSE_CHILDSEARCH;
+
te->parent= parent;
te->index= index; // for data arays
if(ELEM3(type, TSE_SEQUENCE, TSE_SEQ_STRIP, TSE_SEQUENCE_DUP));
@@ -989,6 +997,9 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i
else
te->name= (char*)RNA_struct_ui_name(ptr->type);
+ /* If searching don't expand RNA entries */
+ if(searching && BLI_strcasecmp("RNA",te->name)==0) tselem->flag &= ~TSE_CHILDSEARCH;
+
iterprop= RNA_struct_iterator_property(ptr->type);
tot= RNA_property_collection_length(ptr, iterprop);
@@ -997,7 +1008,7 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i
if(!tselem->used)
tselem->flag &= ~TSE_CLOSED;
- if(!(tselem->flag & TSE_CLOSED)) {
+ if(TSELEM_OPEN(tselem)) {
for(a=0; a<tot; a++)
outliner_add_element(soops, &te->subtree, (void*)ptr, te, TSE_RNA_PROPERTY, a);
}
@@ -1018,11 +1029,14 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i
te->directdata= prop;
te->rnaptr= *ptr;
+ /* If searching don't expand RNA entries */
+ if(searching && BLI_strcasecmp("RNA",te->name)==0) tselem->flag &= ~TSE_CHILDSEARCH;
+
if(proptype == PROP_POINTER) {
pptr= RNA_property_pointer_get(ptr, prop);
if(pptr.data) {
- if(!(tselem->flag & TSE_CLOSED))
+ if(TSELEM_OPEN(tselem))
outliner_add_element(soops, &te->subtree, (void*)&pptr, te, TSE_RNA_STRUCT, -1);
else
te->flag |= TE_LAZY_CLOSED;
@@ -1031,7 +1045,7 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i
else if(proptype == PROP_COLLECTION) {
tot= RNA_property_collection_length(ptr, prop);
- if(!(tselem->flag & TSE_CLOSED)) {
+ if(TSELEM_OPEN(tselem)) {
for(a=0; a<tot; a++) {
RNA_property_collection_lookup_int(ptr, prop, a, &pptr);
outliner_add_element(soops, &te->subtree, (void*)&pptr, te, TSE_RNA_STRUCT, a);
@@ -1043,7 +1057,7 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i
else if(ELEM3(proptype, PROP_BOOLEAN, PROP_INT, PROP_FLOAT)) {
tot= RNA_property_array_length(ptr, prop);
- if(!(tselem->flag & TSE_CLOSED)) {
+ if(TSELEM_OPEN(tselem)) {
for(a=0; a<tot; a++)
outliner_add_element(soops, &te->subtree, (void*)ptr, te, TSE_RNA_ARRAY_ELEM, a);
}
@@ -1076,7 +1090,7 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i
te->directdata= idv;
te->name= km->idname;
- if(!(tselem->flag & TSE_CLOSED)) {
+ if(TSELEM_OPEN(tselem)) {
a= 0;
for (kmi= km->items.first; kmi; kmi= kmi->next, a++) {
@@ -1376,7 +1390,10 @@ static int outliner_filter_tree(SpaceOops *soops, ListBase *lb)
*/
tselem= TREESTORE(te);
- if ((tselem->flag & TSE_CLOSED) || outliner_filter_tree(soops, &te->subtree)==0) {
+ /* flag as not a found item */
+ tselem->flag &= ~TSE_SEARCHMATCH;
+
+ if ((!TSELEM_OPEN(tselem)) || outliner_filter_tree(soops, &te->subtree)==0) {
outliner_free_tree(&te->subtree);
BLI_remlink(lb, te);
@@ -1385,6 +1402,11 @@ static int outliner_filter_tree(SpaceOops *soops, ListBase *lb)
}
}
else {
+ tselem= TREESTORE(te);
+
+ /* flag as a found item - we can then highlight it */
+ tselem->flag |= TSE_SEARCHMATCH;
+
/* filter subtree too */
outliner_filter_tree(soops, &te->subtree);
}
@@ -1407,6 +1429,9 @@ void outliner_build_tree(Main *mainvar, Scene *scene, SpaceOops *soops)
TreeStoreElem *tselem;
int show_opened= (soops->treestore==NULL); /* on first view, we open scenes */
+ /* Are we searching -- see outliner_intern.h */
+ searching= (soops->search_string[0]!=0 && soops->outlinevis!=SO_DATABLOCKS);
+
if(soops->tree.first && (soops->storeflag & SO_TREESTORE_REDRAW))
return;
Index: source/blender/makesdna/DNA_outliner_types.h
===================================================================
--- source/blender/makesdna/DNA_outliner_types.h (revision 39325)
+++ source/blender/makesdna/DNA_outliner_types.h (working copy)
@@ -51,6 +51,8 @@ typedef struct TreeStore {
#define TSE_CLOSED 1
#define TSE_SELECTED 2
#define TSE_TEXTBUT 4
+#define TSE_CHILDSEARCH 8
+#define TSE_SEARCHMATCH 16
/* TreeStoreElem types in BIF_outliner.h */

File Metadata

Mime Type
text/x-diff
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
44/f7/542aebd91c7df511d5e15e3e56c8

Event Timeline