// TODO: this function needs to be split up! It's getting a bit too large... // Note: "ID" is not always a real ID static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *idv, TreeElement *parent, short type, short index) { TreeElement *te; TreeStoreElem *tselem; ID *id = idv; if (ELEM3(type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) { id = ((PointerRNA *)idv)->id.data; if (!id) id = ((PointerRNA *)idv)->data; } /* One exception */ if (type == TSE_ID_BASE) { /* pass */ } else if (id == NULL) { return NULL; } te = MEM_callocN(sizeof(TreeElement), "tree elem"); /* add to the visual tree */ BLI_addtail(lb, te); /* add to the storage */ check_persistent(soops, te, id, type, index); tselem = TREESTORE(te); /* if we are searching for something expand to see child elements */ if (SEARCHING_OUTLINER(soops)) tselem->flag |= TSE_CHILDSEARCH; te->parent = parent; te->index = index; // for data arays if (ELEM3(type, TSE_SEQUENCE, TSE_SEQ_STRIP, TSE_SEQUENCE_DUP)) { /* pass */ } else if (ELEM3(type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) { /* pass */ } else if (type == TSE_ANIM_DATA) { /* pass */ } else if (type == TSE_ID_BASE) { /* pass */ } else { /* do here too, for blend file viewer, own ID_LI then shows file name */ if (GS(id->name) == ID_LI) te->name = ((Library *)id)->name; else te->name = id->name + 2; // default, can be overridden by Library or non-ID data te->idcode = GS(id->name); } if (type == 0) { TreeStoreElem *tsepar = parent ? TREESTORE(parent) : NULL; /* ID datablock */ if (tsepar == NULL || tsepar->type != TSE_ID_BASE) outliner_add_id_contents(soops, te, tselem, id); } else if (type == TSE_ANIM_DATA) { IdAdtTemplate *iat = (IdAdtTemplate *)idv; AnimData *adt = (AnimData *)iat->adt; /* this element's info */ te->name = IFACE_("Animation"); te->directdata = adt; /* Action */ outliner_add_element(soops, &te->subtree, adt->action, te, 0, 0); /* Drivers */ if (adt->drivers.first) { TreeElement *ted = outliner_add_element(soops, &te->subtree, adt, te, TSE_DRIVER_BASE, 0); ID *lastadded = NULL; FCurve *fcu; ted->name = IFACE_("Drivers"); for (fcu = adt->drivers.first; fcu; fcu = fcu->next) { if (fcu->driver && fcu->driver->variables.first) { ChannelDriver *driver = fcu->driver; DriverVar *dvar; for (dvar = driver->variables.first; dvar; dvar = dvar->next) { /* loop over all targets used here */ DRIVER_TARGETS_USED_LOOPER(dvar) { if (lastadded != dtar->id) { // XXX this lastadded check is rather lame, and also fails quite badly... outliner_add_element(soops, &ted->subtree, dtar->id, ted, TSE_LINKED_OB, 0); lastadded = dtar->id; } } DRIVER_TARGETS_LOOPER_END } } }
// TODO: this function needs to be split up! It's getting a bit too large... static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *idv, TreeElement *parent, short type, short index) { TreeElement *te; TreeStoreElem *tselem; ID *id= idv; int a = 0; if(ELEM3(type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) { id= ((PointerRNA*)idv)->id.data; if(!id) id= ((PointerRNA*)idv)->data; } if(id==NULL) return NULL; te= MEM_callocN(sizeof(TreeElement), "tree elem"); /* add to the visual tree */ BLI_addtail(lb, te); /* add to the storage */ check_persistant(soops, te, id, type, index); tselem= TREESTORE(te); te->parent= parent; te->index= index; // for data arays if(ELEM3(type, TSE_SEQUENCE, TSE_SEQ_STRIP, TSE_SEQUENCE_DUP)); else if(ELEM3(type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)); else if(type==TSE_ANIM_DATA); else { te->name= id->name+2; // default, can be overridden by Library or non-ID data te->idcode= GS(id->name); } if(type==0) { /* ID datablock */ outliner_add_id_contents(soops, te, tselem, id); } else if(type==TSE_ANIM_DATA) { IdAdtTemplate *iat = (IdAdtTemplate *)idv; AnimData *adt= (AnimData *)iat->adt; /* this element's info */ te->name= "Animation"; te->directdata= adt; /* Action */ outliner_add_element(soops, &te->subtree, adt->action, te, 0, 0); /* Drivers */ if (adt->drivers.first) { TreeElement *ted= outliner_add_element(soops, &te->subtree, adt, te, TSE_DRIVER_BASE, 0); ID *lastadded= NULL; FCurve *fcu; ted->name= "Drivers"; for (fcu= adt->drivers.first; fcu; fcu= fcu->next) { if (fcu->driver && fcu->driver->variables.first) { ChannelDriver *driver= fcu->driver; DriverVar *dvar; for (dvar= driver->variables.first; dvar; dvar= dvar->next) { /* loop over all targets used here */ DRIVER_TARGETS_USED_LOOPER(dvar) { if (lastadded != dtar->id) { // XXX this lastadded check is rather lame, and also fails quite badly... outliner_add_element(soops, &ted->subtree, dtar->id, ted, TSE_LINKED_OB, 0); lastadded= dtar->id; } } DRIVER_TARGETS_LOOPER_END } } }