Page MenuHome

outliner_search_01.patch

outliner_search_01.patch

Index: blender/include/BIF_outliner.h
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/include/BIF_outliner.h,v
retrieving revision 1.13
diff -u -r1.13 BIF_outliner.h
--- blender/include/BIF_outliner.h 20 Aug 2006 15:22:54 -0000 1.13
+++ blender/include/BIF_outliner.h 7 Sep 2006 10:38:18 -0000
@@ -86,6 +86,7 @@
extern void outliner_toggle_selected(struct ScrArea *sa);
extern void outliner_operation_menu(struct ScrArea *sa);
extern void outliner_page_up_down(struct ScrArea *sa, int up);
+extern void outliner_find_panel(struct ScrArea *sa, int again);
#endif
Index: blender/src/outliner.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/outliner.c,v
retrieving revision 1.69
diff -u -r1.69 outliner.c
--- blender/src/outliner.c 6 Sep 2006 09:51:30 -0000 1.69
+++ blender/src/outliner.c 10 Sep 2006 04:30:53 -0000
@@ -126,6 +126,8 @@
extern ListBase session_list;
#endif
+static ID *last_outliner_find_id= NULL;
+
/* ******************** PERSISTANT DATA ***************** */
static void outliner_storage_cleanup(SpaceOops *soops)
@@ -1007,6 +1009,20 @@
}
}
+/* this function opens all the levels that box it in*/
+static void outliner_open_back(SpaceOops *soops, TreeElement *te)
+{
+ TreeStoreElem *tselem;
+ te= te->parent;
+
+ while(te) {
+ tselem= TREESTORE(te);
+ if (tselem->flag & TSE_CLOSED)
+ tselem->flag &= ~TSE_CLOSED;
+ te= te->parent;
+ }
+}
+
void outliner_one_level(struct ScrArea *sa, int add)
{
SpaceOops *soops= sa->spacedata.first;
@@ -1697,6 +1713,7 @@
}
+
static TreeElement *outliner_find_id(SpaceOops *soops, ListBase *lb, ID *id)
{
TreeElement *te, *tes;
@@ -1730,6 +1747,138 @@
so->v2d.cur.ymax= ytop;
so->v2d.cur.ymin= ytop-(so->v2d.mask.ymax-so->v2d.mask.ymin);
scrarea_queue_redraw(sa);
+ }
+}
+
+/* find next element that has this name */
+static TreeElement *outliner_find_named(SpaceOops *soops, ListBase *lb, char *name, TreeElement *prev)
+{
+ TreeElement *te, *tes;
+ char searchName[33];
+
+ BLI_strncpy(searchName, name, 33);
+
+ te= lb->first;
+ while(te) {
+ char teName[33];
+
+ BLI_strncpy(teName, te->name, 33);
+
+ /* see if this is a single element */
+ if (BLI_streq(teName, searchName)) {
+ /* name is right, but is element the previous one? */
+ if (prev) {
+ if (te != prev)
+ return te;
+ }
+ else
+ return te;
+ }
+ else {
+ tes= outliner_find_named(soops, &te->subtree, name, prev);
+ if(tes) return tes;
+ }
+
+ te= te->next;
+ }
+
+ /* check if no more was due to no more matches past prev */
+ if (prev) {
+ /* go through list one more time to try and find the first entry. no more past last */
+ te= lb->first;
+ while(te) {
+ char teName[33];
+
+ BLI_strncpy(teName, te->name, 33);
+
+ /* see if this is a single element */
+ if (BLI_streq(teName, searchName)) {
+ /* name is right, but is element the previous one? */
+ if (te != prev) return te;
+ }
+
+ /* try to find in subtree if exists */
+ tes= outliner_find_named(soops, &te->subtree, name, prev);
+ if(tes) return tes;
+
+ te= te->next;
+ }
+ }
+
+ /* nothing valid found */
+ return NULL;
+}
+
+/* Called to find an item based on name.
+ * again==0: get a name from user, then find
+ * again==1: try to find based on name of previous
+ */
+void outliner_find_panel(struct ScrArea *sa, int again)
+{
+ SpaceOops *soops= sa->spacedata.first;
+
+ TreeElement *te;
+ TreeElement *last_find;
+ TreeStoreElem *tselem;
+
+ char name[33];
+ int ytop;
+
+ /* get last found tree-element */
+ last_find= outliner_find_id(soops, &soops->tree, last_outliner_find_id);
+
+ /* 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, last_find->name, 33);
+ te= outliner_find_named(soops, &soops->tree, name, last_find);
+
+ /* deselect last if match */
+ if (te) {
+ TreeStoreElem *tsel;
+ tsel= TREESTORE(last_find);
+ if (tsel->flag & TSE_SELECTED)
+ tsel->flag &= ~TSE_SELECTED;
+ }
+ }
+ else {
+ /* pop up panel - no previous, or user didn't want search after previous */
+ if (sbutton(name, 0, sizeof(name)-1, "Find: ") && name[0])
+ te= outliner_find_named(soops, &soops->tree, name, NULL);
+ else
+ return;
+ }
+
+ /* do selection */
+ if (te) {
+ tselem= TREESTORE(te);
+ if (tselem) {
+ /* outliner highlight/select */
+ if ((tselem->flag & TSE_SELECTED)==0)
+ tselem->flag |= TSE_SELECTED;
+
+ /* expand branches so that it will be visible */
+ outliner_open_back(soops, te);
+
+ /* make te->ys center of view */
+ ytop= te->ys + (soops->v2d.mask.ymax-soops->v2d.mask.ymin)/2;
+ if(ytop>0) ytop= 0;
+ soops->v2d.cur.ymax= ytop;
+ soops->v2d.cur.ymin= ytop-(soops->v2d.mask.ymax-soops->v2d.mask.ymin);
+
+ /* store selection */
+ last_outliner_find_id= tselem->id;
+
+ /* redraw and undo stack */
+ BIF_undo_push("Outliner find item");
+ scrarea_queue_redraw(sa);
+ }
+ else
+ last_outliner_find_id= NULL;
+ }
+ else {
+ if (name) error("Not found: %s", name);
+ last_outliner_find_id= NULL;
}
}
Index: blender/src/space.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/space.c,v
retrieving revision 1.376
diff -u -r1.376 space.c
--- blender/src/space.c 4 Sep 2006 12:48:25 -0000 1.376
+++ blender/src/space.c 8 Sep 2006 10:55:30 -0000
@@ -4349,6 +4349,12 @@
else
outliner_toggle_visible(sa);
break;
+ case FKEY:
+ if(G.qual==LR_CTRLKEY)
+ outliner_find_panel(sa, 0);
+ else if(G.qual==LR_SHIFTKEY)
+ outliner_find_panel(sa, 1);
+ break;
case WKEY:
outliner_operation_menu(sa);
break;

File Metadata

Mime Type
text/x-diff
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
0a/bd/a9fab14a880d44aacc9c58f10384

Event Timeline