Merged changes in the trunk up to revision 39826.
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>
Sat, 3 Sep 2011 20:48:43 +0000 (20:48 +0000)
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>
Sat, 3 Sep 2011 20:48:43 +0000 (20:48 +0000)
Made a major amount of conflict resolution for code adaptation to
the animation system updates introduced in the Pepper branch recently
merged to the trunk.

Resolved conflicts:
source/blender/blenkernel/intern/anim_sys.c
source/blender/blenkernel/intern/library.c
source/blender/editors/animation/anim_channels_defines.c
source/blender/editors/animation/anim_channels_edit.c
source/blender/editors/animation/anim_filter.c
source/blender/editors/animation/keyframes_draw.c
source/blender/editors/animation/keyframes_edit.c
source/blender/editors/include/ED_anim_api.h
source/blender/editors/space_nla/nla_buttons.c
source/blender/editors/space_nla/nla_channels.c
source/blender/makesdna/DNA_action_types.h
source/blender/makesdna/intern/makesdna.c
source/blender/makesrna/intern/rna_main_api.c

39 files changed:
1  2 
build_files/scons/tools/Blender.py
doc/python_api/sphinx_doc_gen.py
release/scripts/startup/bl_ui/properties_render.py
source/blender/CMakeLists.txt
source/blender/blenkernel/BKE_main.h
source/blender/blenkernel/CMakeLists.txt
source/blender/blenkernel/intern/anim_sys.c
source/blender/blenkernel/intern/idcode.c
source/blender/blenkernel/intern/library.c
source/blender/blenkernel/intern/object.c
source/blender/blenkernel/intern/scene.c
source/blender/blenloader/intern/readfile.c
source/blender/blenloader/intern/writefile.c
source/blender/editors/animation/anim_channels_defines.c
source/blender/editors/animation/anim_channels_edit.c
source/blender/editors/animation/anim_filter.c
source/blender/editors/include/ED_anim_api.h
source/blender/editors/interface/interface_templates.c
source/blender/editors/render/render_shading.c
source/blender/editors/space_nla/nla_buttons.c
source/blender/editors/space_nla/nla_channels.c
source/blender/editors/transform/transform.c
source/blender/makesdna/DNA_ID.h
source/blender/makesdna/DNA_action_types.h
source/blender/makesdna/DNA_scene_types.h
source/blender/makesdna/intern/makesdna.c
source/blender/makesrna/RNA_access.h
source/blender/makesrna/RNA_enum_types.h
source/blender/makesrna/intern/CMakeLists.txt
source/blender/makesrna/intern/makesrna.c
source/blender/makesrna/intern/rna_ID.c
source/blender/makesrna/intern/rna_action.c
source/blender/makesrna/intern/rna_internal.h
source/blender/makesrna/intern/rna_main.c
source/blender/makesrna/intern/rna_main_api.c
source/blender/makesrna/intern/rna_scene.c
source/blender/render/extern/include/RE_pipeline.h
source/blender/render/intern/source/pipeline.c
source/blenderplayer/bad_level_call_stubs/stubs.c

Simple merge
Simple merge
Simple merge
Simple merge
index dde0df398eba19785d7ec64eb9a83e1579b166da,b690c9b4a91be0b020cb231f3e39568074a54387..e85c56a44feb5838a6d8732bb902ef8b88cd16e3
@@@ -84,7 -83,7 +83,8 @@@ short id_type_can_have_animdata (ID *id
                case ID_PA:
                case ID_MA: case ID_TE: case ID_NT:
                case ID_LA: case ID_CA: case ID_WO:
 +              case ID_LS:
+               case ID_SPK:
                case ID_SCE:
                {
                        return 1;
@@@ -2237,9 -2317,9 +2324,12 @@@ void BKE_animsys_evaluate_all_animatio
        /* particles */
        EVAL_ANIM_IDS(main->particle.first, ADT_RECALC_ANIM);
        
+       /* lamps */
+       EVAL_ANIM_IDS(main->speaker.first, ADT_RECALC_ANIM);
 +      /* linestyles */
 +      EVAL_ANIM_IDS(main->linestyle.first, ADT_RECALC_ANIM);
 +      
        /* objects */
                /* ADT_RECALC_ANIM doesn't need to be supplied here, since object AnimData gets 
                 * this tagged by Depsgraph on framechange. This optimisation means that objects
index d8a81a8d71ce5899533339de22a8e818bb353c48,677a292266688851f27a134289bb7c2aedb92bd6..841e60e6846d8d8064ee7457b62c44ff3d028672
  #include "BKE_particle.h"
  #include "BKE_gpencil.h"
  #include "BKE_fcurve.h"
+ #include "BKE_speaker.h"
 +#include "BKE_linestyle.h"
  
+ #include "RNA_access.h"
  #ifdef WITH_PYTHON
  #include "BPY_extern.h"
  #endif
index a9f586d50dc7733cb40141b98eb0a9cefbcd40b1,bdc654ff25a1fb19a9bb8a1eaea7061a6c0eb764..0d86f7047619a47dc1d0e67cb2ae14e43fbbd8a4
@@@ -2171,82 -1984,6 +1985,83 @@@ static bAnimChannelType ACF_DSNTREE
        acf_dsntree_setting_ptr                                 /* pointer for setting */
  };
  
 +/* LineStyle Expander  ------------------------------------------- */
 +
 +// TODO: just get this from RNA?
 +static int acf_dslinestyle_icon(bAnimListElem *ale)
 +{
 +      return ICON_BRUSH_DATA; /* FIXME */
 +}
 +
 +/* get the appropriate flag(s) for the setting when it is valid  */
 +static int acf_dslinestyle_setting_flag(bAnimContext *ac, int setting, short *neg)
 +{
 +      /* clear extra return data first */
 +      *neg= 0;
 +      
 +      switch (setting) {
 +              case ACHANNEL_SETTING_EXPAND: /* expanded */
 +                      return LS_DS_EXPAND;
 +                      
 +              case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
 +                      return ADT_NLA_EVAL_OFF;
 +                      
 +              case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
 +                      *neg= 1;
 +                      return ADT_CURVES_NOT_VISIBLE;
 +                      
 +              case ACHANNEL_SETTING_SELECT: /* selected */
 +                      return ADT_UI_SELECTED;
 +                      
 +              default: /* unsupported */
 +                      return 0;
 +      }
 +}
 +
 +/* get pointer to the setting */
 +static void *acf_dslinestyle_setting_ptr(bAnimListElem *ale, int setting, short *type)
 +{
 +      FreestyleLineStyle *linestyle= (FreestyleLineStyle *)ale->data;
 +      
 +      /* clear extra return data first */
 +      *type= 0;
 +      
 +      switch (setting) {
 +              case ACHANNEL_SETTING_EXPAND: /* expanded */
 +                      GET_ACF_FLAG_PTR(linestyle->flag);
 +                      
 +              case ACHANNEL_SETTING_SELECT: /* selected */
 +              case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
 +              case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
 +                      if (linestyle->adt)
 +                              GET_ACF_FLAG_PTR(linestyle->adt->flag)
 +                      else
 +                              return NULL;
 +                      
 +              default: /* unsupported */
 +                      return NULL;
 +      }
 +}
 +
 +/* node tree expander type define */
 +static bAnimChannelType ACF_DSLINESTYLE= 
 +{
 +      "Line Style Expander",                  /* type name */
 +      
 +      acf_generic_dataexpand_color,   /* backdrop color */
 +      acf_generic_dataexpand_backdrop,/* backdrop */
 +      acf_generic_indention_1,                /* indent level */
 +      acf_generic_basic_offset,               /* offset */
 +      
 +      acf_generic_idblock_name,               /* name */
++      acf_generic_idblock_nameprop,   /* name prop */
 +      acf_dslinestyle_icon,                   /* icon */
 +      
 +      acf_generic_dataexpand_setting_valid,   /* has setting */
 +      acf_dslinestyle_setting_flag,                   /* flag for setting */
 +      acf_dslinestyle_setting_ptr                             /* pointer for setting */
 +};
 +
  /* Mesh Expander  ------------------------------------------- */
  
  // TODO: just get this from RNA?
@@@ -2684,7 -2529,7 +2607,8 @@@ static void ANIM_init_channel_typeinfo_
                animchannelTypeInfo[type++]= &ACF_DSMESH;               /* Mesh Channel */
                animchannelTypeInfo[type++]= &ACF_DSTEX;                /* Texture Channel */
                animchannelTypeInfo[type++]= &ACF_DSLAT;                /* Lattice Channel */
 +              animchannelTypeInfo[type++]= &ACF_DSLINESTYLE;  /* LineStyle Channel */
+               animchannelTypeInfo[type++]= &ACF_DSSPK;                /* Speaker Channel */
                
                animchannelTypeInfo[type++]= &ACF_SHAPEKEY;             /* ShapeKey */
                
index b24b44f3526f8d6eb7e7c6d38bb9574ffdec2a9c,d58d51c8e08b65bcf7874f1f885acc4d4b21fb39..faeeee21333958e6a71e208a9b49fc2dd8314ee5
@@@ -123,6 -122,7 +122,8 @@@ void ANIM_set_active_channel (bAnimCont
                        case ANIMTYPE_DSMESH:
                        case ANIMTYPE_DSTEX:
                        case ANIMTYPE_DSLAT:
++                      case ANIMTYPE_DSLINESTYLE:
+                       case ANIMTYPE_DSSPK:
                        {
                                /* need to verify that this data is valid for now */
                                if (ale->adt) {
                        case ANIMTYPE_DSARM:
                        case ANIMTYPE_DSMESH:
                        case ANIMTYPE_DSLAT:
++                      case ANIMTYPE_DSLINESTYLE:
+                       case ANIMTYPE_DSSPK:
                        {
                                /* need to verify that this data is valid for now */
                                if (ale && ale->adt) {
@@@ -245,7 -247,7 +249,8 @@@ void ANIM_deselect_anim_channels (bAnim
                                case ANIMTYPE_DSNTREE:
                                case ANIMTYPE_DSTEX:
                                case ANIMTYPE_DSLAT:
 +                              case ANIMTYPE_DSLINESTYLE:
+                               case ANIMTYPE_DSSPK:
                                {
                                        if ((ale->adt) && (ale->adt->flag & ADT_UI_SELECTED))
                                                sel= ACHANNEL_SETFLAG_CLEAR;
                        case ANIMTYPE_DSNTREE:
                        case ANIMTYPE_DSTEX:
                        case ANIMTYPE_DSLAT:
 +                      case ANIMTYPE_DSLINESTYLE:
+                       case ANIMTYPE_DSSPK:
                        {
                                /* need to verify that this data is valid for now */
                                if (ale->adt) {
@@@ -2004,7 -2177,7 +2181,8 @@@ static int mouse_anim_channels (bAnimCo
                case ANIMTYPE_DSNTREE:
                case ANIMTYPE_DSTEX:
                case ANIMTYPE_DSLAT:
 +              case ANIMTYPE_DSLINESTYLE:
+               case ANIMTYPE_DSSPK:
                {
                        /* sanity checking... */
                        if (ale->adt) {
index 340fa894c3fd32f9ce4bc27da6bcbdcb24285632,8010a41ccb334c87e1bd58cf9ef0312a7258f514..3cfe3f6094cd876ae158b74da02b18828c0988a8
@@@ -1243,70 -1249,114 +1263,162 @@@ static size_t animdata_filter_shapekey 
        return items;
  }
  
+ static size_t animdata_filter_gpencil_data (ListBase *anim_data, bGPdata *gpd, int filter_mode)
+ {
+       bGPDlayer *gpl;
+       size_t items = 0;
+       
+       /* loop over layers as the conditions are acceptable */
+       for (gpl= gpd->layers.first; gpl; gpl= gpl->next) {
+               /* only if selected */
+               if ( ANIMCHANNEL_SELOK(SEL_GPL(gpl)) ) {
+                       /* only if editable */
+                       if (!(filter_mode & ANIMFILTER_FOREDIT) || EDITABLE_GPL(gpl)) {
+                               /* active... */
+                               if (!(filter_mode & ANIMFILTER_ACTIVE) || (gpl->flag & GP_LAYER_ACTIVE)) {
+                                       /* add to list */
+                                       ANIMCHANNEL_NEW_CHANNEL(gpl, ANIMTYPE_GPLAYER, gpd);
+                               }
+                       }
+               }
+       }
+       
+       return items;
+ }
  /* Grab all Grase Pencil datablocks in file */
  // TODO: should this be amalgamated with the dopesheet filtering code?
- static int animdata_filter_gpencil (ListBase *anim_data, void *UNUSED(data), int filter_mode)
+ static size_t animdata_filter_gpencil (ListBase *anim_data, void *UNUSED(data), int filter_mode)
  {
-       bAnimListElem *ale;
        bGPdata *gpd;
-       bGPDlayer *gpl;
-       int items = 0;
+       size_t items = 0;
        
-       /* check if filtering types are appropriate */
-       if (!(filter_mode & (ANIMFILTER_ACTGROUPED|ANIMFILTER_CURVESONLY)))
-       {
-               /* for now, grab grease pencil datablocks directly from main*/
-               for (gpd = G.main->gpencil.first; gpd; gpd = gpd->id.next) {
-                       /* only show if gpd is used by something... */
-                       if (ID_REAL_USERS(gpd) < 1)
-                               continue;
+       /* for now, grab grease pencil datablocks directly from main */
+       // XXX: this is not good...
+       for (gpd = G.main->gpencil.first; gpd; gpd = gpd->id.next) {
+               ListBase tmp_data = {NULL, NULL};
+               size_t tmp_items = 0;
+               
+               /* only show if gpd is used by something... */
+               if (ID_REAL_USERS(gpd) < 1)
+                       continue;
                        
-                       /* add gpd as channel too (if for drawing, and it has layers) */
-                       if ((filter_mode & ANIMFILTER_CHANNELS) && (gpd->layers.first)) {
-                               /* add to list */
-                               ale= make_new_animlistelem(gpd, ANIMTYPE_GPDATABLOCK, NULL, ANIMTYPE_NONE, NULL);
-                               if (ale) {
-                                       BLI_addtail(anim_data, ale);
-                                       items++;
-                               }
+               /* add gpencil animation channels */
+               BEGIN_ANIMFILTER_SUBCHANNELS(EXPANDED_GPD(gpd))
+               {
+                       tmp_items += animdata_filter_gpencil_data(&tmp_data, gpd, filter_mode);
+               }
+               END_ANIMFILTER_SUBCHANNELS;
+               
+               /* did we find anything? */
+               if (tmp_items) {
+                       /* include data-expand widget first */
+                       if (filter_mode & ANIMFILTER_LIST_CHANNELS) {
+                               /* add gpd as channel too (if for drawing, and it has layers) */
+                               ANIMCHANNEL_NEW_CHANNEL(gpd, ANIMTYPE_GPDATABLOCK, NULL);
                        }
                        
-                       /* only add layers if they will be visible (if drawing channels) */
-                       if ( !(filter_mode & ANIMFILTER_VISIBLE) || (EXPANDED_GPD(gpd)) ) {
-                               /* loop over layers as the conditions are acceptable */
-                               for (gpl= gpd->layers.first; gpl; gpl= gpl->next) {
-                                       /* only if selected */
-                                       if ( ANIMCHANNEL_SELOK(SEL_GPL(gpl)) ) {
-                                               /* only if editable */
-                                               if (!(filter_mode & ANIMFILTER_FOREDIT) || EDITABLE_GPL(gpl)) {
-                                                       /* add to list */
-                                                       ale= make_new_animlistelem(gpl, ANIMTYPE_GPLAYER, gpd, ANIMTYPE_GPDATABLOCK, (ID*)gpd);
-                                                       if (ale) {
-                                                               BLI_addtail(anim_data, ale);
-                                                               items++;
-                                                       }
-                                               }
+                       /* now add the list of collected channels */
+                       BLI_movelisttolist(anim_data, &tmp_data);
+                       BLI_assert((tmp_data.first == tmp_data.last) && (tmp_data.first == NULL));
+                       items += tmp_items;
+               }
+       }
+       
+       /* return the number of items added to the list */
+       return items;
+ }
+ /* NOTE: owner_id is scene, material, or texture block, which is the direct owner of the node tree in question */
+ // TODO: how to handle group nodes is still unclear...
+ static size_t animdata_filter_ds_nodetree (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, ID *owner_id, bNodeTree *ntree, int filter_mode)
+ {
+       ListBase tmp_data = {NULL, NULL};
+       size_t tmp_items = 0;
+       size_t items = 0;
+       
+       /* add nodetree animation channels */
+       BEGIN_ANIMFILTER_SUBCHANNELS(FILTER_NTREE_DATA(ntree))
+       {
+               /* animation data filtering */
+               tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)ntree, filter_mode);
+       }
+       END_ANIMFILTER_SUBCHANNELS;
+       
+       /* did we find anything? */
+       if (tmp_items) {
+               /* include data-expand widget first */
+               if (filter_mode & ANIMFILTER_LIST_CHANNELS) {
+                       /* check if filtering by active status */
+                       if ANIMCHANNEL_ACTIVEOK(ntree) {
+                               ANIMCHANNEL_NEW_CHANNEL(ntree, ANIMTYPE_DSNTREE, owner_id);
+                       }
+               }
+               
+               /* now add the list of collected channels */
+               BLI_movelisttolist(anim_data, &tmp_data);
+               BLI_assert((tmp_data.first == tmp_data.last) && (tmp_data.first == NULL));
+               items += tmp_items;
+       }
+       
+       /* return the number of items added to the list */
+       return items;
+ }
++static size_t animdata_filter_ds_linestyle (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Scene *sce, int filter_mode)
++{
++      SceneRenderLayer *srl;
++      size_t items = 0;
++
++      for (srl= sce->r.layers.first; srl; srl= srl->next) {
++              FreestyleLineSet *lineset;
++
++              /* skip render layers without Freestyle enabled */
++              if (!(srl->layflag & SCE_LAY_FRS))
++                      continue;
++
++              /* loop over linesets defined in the render layer */
++              for (lineset= srl->freestyleConfig.linesets.first; lineset; lineset= lineset->next) {
++                      FreestyleLineStyle *linestyle = lineset->linestyle;
++                      ListBase tmp_data = {NULL, NULL};
++                      size_t tmp_items = 0;
++
++                      /* add scene-level animation channels */
++                      BEGIN_ANIMFILTER_SUBCHANNELS(FILTER_LS_SCED(linestyle))
++                      {
++                              /* animation data filtering */
++                              tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)linestyle, filter_mode);
++                      }
++                      END_ANIMFILTER_SUBCHANNELS;
++
++                      /* did we find anything? */
++                      if (tmp_items) {
++                              /* include anim-expand widget first */
++                              if (filter_mode & ANIMFILTER_LIST_CHANNELS) {
++                                      /* check if filtering by active status */
++                                      if ANIMCHANNEL_ACTIVEOK(linestyle) {
++                                              ANIMCHANNEL_NEW_CHANNEL(linestyle, ANIMTYPE_DSLINESTYLE, sce);
 +                                      }
 +                              }
++                              
++                              /* now add the list of collected channels */
++                              BLI_movelisttolist(anim_data, &tmp_data);
++                              BLI_assert((tmp_data.first == tmp_data.last) && (tmp_data.first == NULL));
++                              items += tmp_items;
 +                      }
 +              }
 +      }
 +      
 +      /* return the number of items added to the list */
 +      return items;
 +}
 +
  /* NOTE: owner_id is either material, lamp, or world block, which is the direct owner of the texture stack in question */
- static int animdata_filter_dopesheet_texs (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, ID *owner_id, int filter_mode)
+ static size_t animdata_filter_ds_textures (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, ID *owner_id, int filter_mode)
  {
-       ListBase texs = {NULL, NULL};
-       LinkData *ld;
        MTex **mtex = NULL;
-       short expanded=0;
-       int ownertype = ANIMTYPE_NONE;
-       
-       bAnimListElem *ale=NULL;
-       int items=0, a=0;
+       size_t items=0;
+       int a=0;
        
        /* get datatype specific data first */
        if (owner_id == NULL)
@@@ -1693,505 -1670,301 +1732,306 @@@ static size_t animdata_filter_ds_obdat
        return items;
  }
  
- static int animdata_filter_dopesheet_ob (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Base *base, int filter_mode)
+ /* shapekey-level animation */
+ static size_t animdata_filter_ds_keyanim (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Object *ob, Key *key, int filter_mode)
  {
-       bAnimListElem *ale=NULL;
-       AnimData *adt = NULL;
-       Object *ob= base->object;
-       Key *key= ob_get_key(ob);
-       short obdata_ok = 0;
-       int items = 0;
-       
-       /* add this object as a channel first */
-       if ((filter_mode & (ANIMFILTER_CURVESONLY|ANIMFILTER_NLATRACKS)) == 0) {
-               /* check if filtering by selection */
-               if ANIMCHANNEL_SELOK((base->flag & SELECT)) {
-                       /* check if filtering by active status */
-                       if ANIMCHANNEL_ACTIVEOK(ob) {
-                               ale= make_new_animlistelem(base, ANIMTYPE_OBJECT, NULL, ANIMTYPE_NONE, (ID *)ob);
-                               if (ale) {
-                                       BLI_addtail(anim_data, ale);
-                                       items++;
-                               }
-                       }
-               }
+       ListBase tmp_data = {NULL, NULL};
+       size_t tmp_items = 0;
+       size_t items = 0;
+       
+       /* add shapekey-level animation channels */
+       BEGIN_ANIMFILTER_SUBCHANNELS(FILTER_SKE_OBJD(key))
+       {
+               /* animation data filtering */
+               tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)key, filter_mode);
        }
+       END_ANIMFILTER_SUBCHANNELS;
        
-       /* if collapsed, don't go any further (unless adding keyframes only) */
-       if ( ((filter_mode & ANIMFILTER_VISIBLE) && EXPANDED_OBJC(ob) == 0) &&
-                !(filter_mode & (ANIMFILTER_CURVESONLY|ANIMFILTER_NLATRACKS)) )
-               return items;
-       
-       /* Action, Drivers, or NLA */
-       if (ob->adt && !(ads->filterflag & ADS_FILTER_NOOBJ)) {
-               adt= ob->adt;
-               ANIMDATA_FILTER_CASES(ob,
-                       { /* AnimData blocks - do nothing... */ },
-                       { /* nla */
-                               /* add NLA tracks */
-                               items += animdata_filter_nla(ac, anim_data, ads, adt, filter_mode, ob, ANIMTYPE_OBJECT, (ID *)ob);
-                       },
-                       { /* drivers */
-                               /* include drivers-expand widget? */
-                               if ((filter_mode & ANIMFILTER_CHANNELS) && !(filter_mode & ANIMFILTER_CURVESONLY)) {
-                                       ale= make_new_animlistelem(adt->action, ANIMTYPE_FILLDRIVERS, base, ANIMTYPE_OBJECT, (ID *)ob);
-                                       if (ale) {
-                                               BLI_addtail(anim_data, ale);
-                                               items++;
-                                       }
-                               }
-                               
-                               /* add F-Curve channels (drivers are F-Curves) */
-                               if (!(filter_mode & ANIMFILTER_VISIBLE) || EXPANDED_DRVD(adt) || !(filter_mode & ANIMFILTER_CHANNELS)) {
-                                       // need to make the ownertype normal object here... (maybe type should be a separate one for clarity?)
-                                       items += animdata_filter_fcurves(anim_data, ads, adt->drivers.first, NULL, ob, ANIMTYPE_OBJECT, filter_mode, (ID *)ob);
-                               }
-                       },
-                       { /* action (keyframes) */
-                               /* include action-expand widget? */
-                               if ((filter_mode & ANIMFILTER_CHANNELS) && !(filter_mode & ANIMFILTER_CURVESONLY)) {
-                                       ale= make_new_animlistelem(adt->action, ANIMTYPE_FILLACTD, base, ANIMTYPE_OBJECT, (ID *)ob);
-                                       if (ale) {
-                                               BLI_addtail(anim_data, ale);
-                                               items++;
-                                       }
-                               }
-                               
-                               /* add F-Curve channels? */
-                               if (!(filter_mode & ANIMFILTER_VISIBLE) || EXPANDED_ACTC(adt->action) || !(filter_mode & ANIMFILTER_CHANNELS)) {
-                                       // need to make the ownertype normal object here... (maybe type should be a separate one for clarity?)
-                                       items += animdata_filter_action(ac, anim_data, ads, adt->action, filter_mode, ob, ANIMTYPE_OBJECT, (ID *)ob); 
-                               }
+       /* did we find anything? */
+       if (tmp_items) {
+               /* include key-expand widget first */
+               if (filter_mode & ANIMFILTER_LIST_CHANNELS) {
+                       if ANIMCHANNEL_ACTIVEOK(key) {
+                               ANIMCHANNEL_NEW_CHANNEL(key, ANIMTYPE_DSSKEY, ob);
                        }
-               );
+               }
+               
+               /* now add the list of collected channels */
+               BLI_movelisttolist(anim_data, &tmp_data);
+               BLI_assert((tmp_data.first == tmp_data.last) && (tmp_data.first == NULL));
+               items += tmp_items;
        }
        
+       /* return the number of items added to the list */
+       return items;
+ }
+ /* object-level animation */
+ static size_t animdata_filter_ds_obanim (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Object *ob, int filter_mode)
+ {
+       ListBase tmp_data = {NULL, NULL};
+       size_t tmp_items = 0;
+       size_t items = 0;
+       
+       AnimData *adt = ob->adt;
+       short type=0, expanded=1;
+       void *cdata = NULL;
+       
+       /* determine the type of expander channels to use */
+       // this is the best way to do this for now...
+       ANIMDATA_FILTER_CASES(ob,
+               {/* AnimData - no channel, but consider data */},
+               {/* NLA - no channel, but consider data */},
+               {/* Drivers */
+                       type = ANIMTYPE_FILLDRIVERS;
+                       cdata = adt;
+                       expanded = EXPANDED_DRVD(adt);
+               },
+               {/* Keyframes */
+                       type = ANIMTYPE_FILLACTD;
+                       cdata = adt->action;
+                       expanded = EXPANDED_ACTC(adt->action);
+               });
+               
+       /* add object-level animation channels */
+       BEGIN_ANIMFILTER_SUBCHANNELS(expanded)
+       {
+               /* animation data filtering */
+               tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)ob, filter_mode);
+       }
+       END_ANIMFILTER_SUBCHANNELS;
        
-       /* ShapeKeys? */
-       if ((key) && !(ads->filterflag & ADS_FILTER_NOSHAPEKEYS)) {
-               adt= key->adt;
-               ANIMDATA_FILTER_CASES(key,
-                       { /* AnimData blocks - do nothing... */ },
-                       { /* nla */
-                               /* include shapekey-expand widget? */
-                               if ((filter_mode & ANIMFILTER_CHANNELS) && !(filter_mode & ANIMFILTER_CURVESONLY)) {
-                                       /* check if filtering by active status */
-                                       if ANIMCHANNEL_ACTIVEOK(key) {
-                                               ale= make_new_animlistelem(key, ANIMTYPE_DSSKEY, base, ANIMTYPE_OBJECT, (ID *)ob);
-                                               if (ale) {
-                                                       BLI_addtail(anim_data, ale);
-                                                       items++;
-                                               }
-                                       }
-                               }
-                               
-                               /* add NLA tracks - only if expanded or so */
-                               if (!(filter_mode & ANIMFILTER_VISIBLE) || FILTER_SKE_OBJD(key) || (filter_mode & ANIMFILTER_CURVESONLY))
-                                       items += animdata_filter_nla(ac, anim_data, ads, adt, filter_mode, ob, ANIMTYPE_OBJECT, (ID *)key);
-                       },
-                       { /* drivers */
-                               /* include shapekey-expand widget? */
-                               if ((filter_mode & ANIMFILTER_CHANNELS) && !(filter_mode & ANIMFILTER_CURVESONLY)) {
-                                       ale= make_new_animlistelem(key, ANIMTYPE_DSSKEY, base, ANIMTYPE_OBJECT, (ID *)ob);
-                                       if (ale) {
-                                               BLI_addtail(anim_data, ale);
-                                               items++;
-                                       }
-                               }
-                               
-                               /* add channels */
-                               if (!(filter_mode & ANIMFILTER_VISIBLE) || FILTER_SKE_OBJD(key) || (filter_mode & ANIMFILTER_CURVESONLY)) {
-                                       items += animdata_filter_fcurves(anim_data, ads, adt->drivers.first, NULL, key, ANIMTYPE_DSSKEY, filter_mode, (ID *)key);
-                               }
-                       },
-                       { /* action (keyframes) */
-                               /* include shapekey-expand widget? */
-                               if ((filter_mode & ANIMFILTER_CHANNELS) && !(filter_mode & ANIMFILTER_CURVESONLY)) {
-                                       /* check if filtering by active status */
-                                       if ANIMCHANNEL_ACTIVEOK(key) {
-                                               ale= make_new_animlistelem(key, ANIMTYPE_DSSKEY, base, ANIMTYPE_OBJECT, (ID *)ob);
-                                               if (ale) {
-                                                       BLI_addtail(anim_data, ale);
-                                                       items++;
-                                               }
-                                       }
-                               }
-                               
-                               /* add channels */
-                               if (!(filter_mode & ANIMFILTER_VISIBLE) || FILTER_SKE_OBJD(key) || (filter_mode & ANIMFILTER_CURVESONLY)) {
-                                       items += animdata_filter_action(ac, anim_data, ads, adt->action, filter_mode, key, ANIMTYPE_DSSKEY, (ID *)key); 
-                               }
+       /* did we find anything? */
+       if (tmp_items) {
+               /* include anim-expand widget first */
+               if (filter_mode & ANIMFILTER_LIST_CHANNELS) {
+                       if (type != ANIMTYPE_NONE) {
+                               /* NOTE: active-status (and the associated checks) don't apply here... */
+                               ANIMCHANNEL_NEW_CHANNEL(cdata, type, ob);
                        }
-               );
+               }
+               
+               /* now add the list of collected channels */
+               BLI_movelisttolist(anim_data, &tmp_data);
+               BLI_assert((tmp_data.first == tmp_data.last) && (tmp_data.first == NULL));
+               items += tmp_items;
        }
+       
+       /* return the number of items added to the list */
+       return items;
+ }
  
-       /* Materials? */
-       if ((ob->totcol) && !(ads->filterflag & ADS_FILTER_NOMAT))
-               items += animdata_filter_dopesheet_mats(ac, anim_data, ads, base, filter_mode);
+ /* get animation channels from object2 */
+ static size_t animdata_filter_dopesheet_ob (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Base *base, int filter_mode)
+ {
+       ListBase tmp_data = {NULL, NULL};
+       Object *ob= base->object;
+       size_t tmp_items = 0;
+       size_t items = 0;
        
-       /* Object Data */
-       switch (ob->type) {
-               case OB_CAMERA: /* ------- Camera ------------ */
-               {
-                       Camera *ca= (Camera *)ob->data;
-                       
-                       if ((ads->filterflag & ADS_FILTER_NOCAM) == 0) {
-                               ANIMDATA_FILTER_CASES(ca,
-                                       { /* AnimData blocks - do nothing... */ },
-                                       obdata_ok= 1;,
-                                       obdata_ok= 1;,
-                                       obdata_ok= 1;)
-                       }
-               }
-                       break;
-               case OB_LAMP: /* ---------- Lamp ----------- */
-               {
-                       Lamp *la= (Lamp *)ob->data;
-                       
-                       if ((ads->filterflag & ADS_FILTER_NOLAM) == 0) {
-                               ANIMDATA_FILTER_CASES(la,
-                                       { /* AnimData blocks - do nothing... */ },
-                                       obdata_ok= 1;,
-                                       obdata_ok= 1;,
-                                       obdata_ok= 1;)
-                       }
+       /* filter data contained under object first */
+       BEGIN_ANIMFILTER_SUBCHANNELS(EXPANDED_OBJC(ob))
+       {
+               Key *key= ob_get_key(ob);
+               
+               /* object-level animation */
+               if ((ob->adt) && !(ads->filterflag & ADS_FILTER_NOOBJ)) {
+                       tmp_items += animdata_filter_ds_obanim(ac, &tmp_data, ads, ob, filter_mode);
                }
-                       break;
-               case OB_CURVE: /* ------- Curve ---------- */
-               case OB_SURF: /* ------- Nurbs Surface ---------- */
-               case OB_FONT: /* ------- Text Curve ---------- */
-               {
-                       Curve *cu= (Curve *)ob->data;
-                       
-                       if ((ads->filterflag & ADS_FILTER_NOCUR) == 0) {
-                               ANIMDATA_FILTER_CASES(cu,
-                                       { /* AnimData blocks - do nothing... */ },
-                                       obdata_ok= 1;,
-                                       obdata_ok= 1;,
-                                       obdata_ok= 1;)
-                       }
+               
+               /* shape-key */
+               if ((key && key->adt) && !(ads->filterflag & ADS_FILTER_NOSHAPEKEYS)) {
+                       tmp_items += animdata_filter_ds_keyanim(ac, &tmp_data, ads, ob, key, filter_mode);
                }
-                       break;
-               case OB_MBALL: /* ------- MetaBall ---------- */
-               {
-                       MetaBall *mb= (MetaBall *)ob->data;
-                       
-                       if ((ads->filterflag & ADS_FILTER_NOMBA) == 0) {
-                               ANIMDATA_FILTER_CASES(mb,
-                                       { /* AnimData blocks - do nothing... */ },
-                                       obdata_ok= 1;,
-                                       obdata_ok= 1;,
-                                       obdata_ok= 1;)
-                       }
+               
+               /* materials */
+               if ((ob->totcol) && !(ads->filterflag & ADS_FILTER_NOMAT)) {
+                       tmp_items += animdata_filter_ds_materials(ac, &tmp_data, ads, ob, filter_mode);
                }
-                       break;
-               case OB_ARMATURE: /* ------- Armature ---------- */
-               {
-                       bArmature *arm= (bArmature *)ob->data;
-                       
-                       if ((ads->filterflag & ADS_FILTER_NOARM) == 0) {
-                               ANIMDATA_FILTER_CASES(arm,
-                                       { /* AnimData blocks - do nothing... */ },
-                                       obdata_ok= 1;,
-                                       obdata_ok= 1;,
-                                       obdata_ok= 1;)
-                       }
+               
+               /* object data */
+               if (ob->data) {
+                       tmp_items += animdata_filter_ds_obdata(ac, &tmp_data, ads, ob, filter_mode);
                }
-                       break;
-               case OB_MESH: /* ------- Mesh ---------- */
-               {
-                       Mesh *me= (Mesh *)ob->data;
-                       
-                       if ((ads->filterflag & ADS_FILTER_NOMESH) == 0) {
-                               ANIMDATA_FILTER_CASES(me,
-                                       { /* AnimData blocks - do nothing... */ },
-                                       obdata_ok= 1;,
-                                       obdata_ok= 1;,
-                                       obdata_ok= 1;)
-                       }
+               
+               /* particles */
+               if ((ob->particlesystem.first) && !(ads->filterflag & ADS_FILTER_NOPART)) {
+                       tmp_items += animdata_filter_ds_particles(ac, &tmp_data, ads, ob, filter_mode);
                }
-                       break;
-               case OB_LATTICE: /* ------- Lattice ---------- */
-               {
-                       Lattice *lt= (Lattice *)ob->data;
-                       
-                       if ((ads->filterflag & ADS_FILTER_NOLAT) == 0) {
-                               ANIMDATA_FILTER_CASES(lt,
-                                       { /* AnimData blocks - do nothing... */ },
-                                       obdata_ok= 1;,
-                                       obdata_ok= 1;,
-                                       obdata_ok= 1;)
+       }
+       END_ANIMFILTER_SUBCHANNELS;
+       
+       
+       /* if we collected some channels, add these to the new list... */
+       if (tmp_items) {
+               /* firstly add object expander if required */
+               if (filter_mode & ANIMFILTER_LIST_CHANNELS) {
+                       /* check if filtering by selection */
+                       // XXX: double-check on this - most of the time, a lot of tools need to filter out these channels!
+                       if ANIMCHANNEL_SELOK((base->flag & SELECT)) {
+                               /* check if filtering by active status */
+                               if (ANIMCHANNEL_ACTIVEOK(ob)) {
+                                       ANIMCHANNEL_NEW_CHANNEL(base, ANIMTYPE_OBJECT, ob);
+                               }
                        }
                }
-                       break;
+               
+               /* now add the list of collected channels */
+               BLI_movelisttolist(anim_data, &tmp_data);
+               BLI_assert((tmp_data.first == tmp_data.last) && (tmp_data.first == NULL));
+               items += tmp_items;
        }
-       if (obdata_ok) 
-               items += animdata_filter_dopesheet_obdata(ac, anim_data, ads, base, filter_mode);
-       /* particles */
-       if (ob->particlesystem.first && !(ads->filterflag & ADS_FILTER_NOPART))
-               items += animdata_filter_dopesheet_particles(ac, anim_data, ads, base, filter_mode);
        
-       /* return the number of items added to the list */
+       /* return the number of items added */
        return items;
- }     
+ }
  
- static int animdata_filter_dopesheet_scene (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Scene *sce, int filter_mode)
+ static size_t animdata_filter_ds_world (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Scene *sce, World *wo, int filter_mode)
  {
-       World *wo= sce->world;
-       bNodeTree *ntree= sce->nodetree;
-       AnimData *adt= NULL;
-       bAnimListElem *ale;
-       int items = 0;
-       
-       /* add scene as a channel first (even if we aren't showing scenes we still need to show the scene's sub-data */
-       if ((filter_mode & (ANIMFILTER_CURVESONLY|ANIMFILTER_NLATRACKS)) == 0) {
-               /* check if filtering by selection */
-               if (ANIMCHANNEL_SELOK( (sce->flag & SCE_DS_SELECTED) )) {
-                       ale= make_new_animlistelem(sce, ANIMTYPE_SCENE, NULL, ANIMTYPE_NONE, NULL);
-                       if (ale) {
-                               BLI_addtail(anim_data, ale);
-                               items++;
+       ListBase tmp_data = {NULL, NULL};
+       size_t tmp_items = 0;
+       size_t items = 0;
+       
+       /* add world animation channels */
+       BEGIN_ANIMFILTER_SUBCHANNELS(FILTER_WOR_SCED(wo))
+       {
+               /* animation data filtering */
+               tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)wo, filter_mode);
+               
+               /* textures for world */
+               if (!(ads->filterflag & ADS_FILTER_NOTEX))
+                       items += animdata_filter_ds_textures(ac, &tmp_data, ads, (ID *)wo, filter_mode);
+       }
+       END_ANIMFILTER_SUBCHANNELS;
+       
+       /* did we find anything? */
+       if (tmp_items) {
+               /* include data-expand widget first */
+               if (filter_mode & ANIMFILTER_LIST_CHANNELS) {
+                       /* check if filtering by active status */
+                       if ANIMCHANNEL_ACTIVEOK(wo) {
+                               ANIMCHANNEL_NEW_CHANNEL(wo, ANIMTYPE_DSWOR, sce);
                        }
                }
+               
+               /* now add the list of collected channels */
+               BLI_movelisttolist(anim_data, &tmp_data);
+               BLI_assert((tmp_data.first == tmp_data.last) && (tmp_data.first == NULL));
+               items += tmp_items;
        }
        
-       /* if collapsed, don't go any further (unless adding keyframes only) */
-       if ( (EXPANDED_SCEC(sce) == 0) && !(filter_mode & (ANIMFILTER_CURVESONLY|ANIMFILTER_NLATRACKS)) )
-               return items;
+       /* return the number of items added to the list */
+       return items;
+ }
+ static size_t animdata_filter_ds_scene (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Scene *sce, int filter_mode)
+ {
+       ListBase tmp_data = {NULL, NULL};
+       size_t tmp_items = 0;
+       size_t items = 0;
+       
+       AnimData *adt = sce->adt;
+       short type=0, expanded=1;
+       void *cdata = NULL;
+       
+       /* determine the type of expander channels to use */
+       // this is the best way to do this for now...
+       ANIMDATA_FILTER_CASES(sce,
+               {/* AnimData - no channel, but consider data */},
+               {/* NLA - no channel, but consider data */},
+               {/* Drivers */
+                       type = ANIMTYPE_FILLDRIVERS;
+                       cdata = adt;
+                       expanded = EXPANDED_DRVD(adt);
+               },
+               {/* Keyframes */
+                       type = ANIMTYPE_FILLACTD;
+                       cdata = adt->action;
+                       expanded = EXPANDED_ACTC(adt->action);
+               });
                
-       /* Action, Drivers, or NLA for Scene */
-       if ((ads->filterflag & ADS_FILTER_NOSCE) == 0) {
-               adt= sce->adt;
-               ANIMDATA_FILTER_CASES(sce,
-                       { /* AnimData blocks - do nothing... */ },
-                       { /* nla */
-                               /* add NLA tracks */
-                               items += animdata_filter_nla(ac, anim_data, ads, adt, filter_mode, sce, ANIMTYPE_SCENE, (ID *)sce);
-                       },
-                       { /* drivers */
-                               /* include drivers-expand widget? */
-                               if ((filter_mode & ANIMFILTER_CHANNELS) && !(filter_mode & ANIMFILTER_CURVESONLY)) {
-                                       ale= make_new_animlistelem(adt->action, ANIMTYPE_FILLDRIVERS, sce, ANIMTYPE_SCENE, (ID *)sce);
-                                       if (ale) {
-                                               BLI_addtail(anim_data, ale);
-                                               items++;
-                                       }
-                               }
-                               
-                               /* add F-Curve channels (drivers are F-Curves) */
-                               if (EXPANDED_DRVD(adt) || !(filter_mode & ANIMFILTER_CHANNELS)) {
-                                       items += animdata_filter_fcurves(anim_data, ads, adt->drivers.first, NULL, sce, ANIMTYPE_SCENE, filter_mode, (ID *)sce);
-                               }
-                       },
-                       { /* action */
-                               /* include action-expand widget? */
-                               if ((filter_mode & ANIMFILTER_CHANNELS) && !(filter_mode & ANIMFILTER_CURVESONLY)) {
-                                       ale= make_new_animlistelem(adt->action, ANIMTYPE_FILLACTD, sce, ANIMTYPE_SCENE, (ID *)sce);
-                                       if (ale) {
-                                               BLI_addtail(anim_data, ale);
-                                               items++;
-                                       }
-                               }
-                               
-                               /* add F-Curve channels? */
-                               if (EXPANDED_ACTC(adt->action) || !(filter_mode & ANIMFILTER_CHANNELS)) {
-                                       items += animdata_filter_action(ac, anim_data, ads, adt->action, filter_mode, sce, ANIMTYPE_SCENE, (ID *)sce); 
-                               }
-                       }
-               )
+       /* add scene-level animation channels */
+       BEGIN_ANIMFILTER_SUBCHANNELS(expanded)
+       {
+               /* animation data filtering */
+               tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)sce, filter_mode);
        }
+       END_ANIMFILTER_SUBCHANNELS;
        
-       /* world */
-       if ((wo && wo->adt) && !(ads->filterflag & ADS_FILTER_NOWOR)) {
-               /* Action, Drivers, or NLA for World */
-               adt= wo->adt;
-               ANIMDATA_FILTER_CASES(wo,
-                       { /* AnimData blocks - do nothing... */ },
-                       { /* nla */
-                               /* add NLA tracks */
-                               items += animdata_filter_nla(ac, anim_data, ads, adt, filter_mode, wo, ANIMTYPE_DSWOR, (ID *)wo);
-                       },
-                       { /* drivers */
-                               /* include world-expand widget? */
-                               if ((filter_mode & ANIMFILTER_CHANNELS) && !(filter_mode & ANIMFILTER_CURVESONLY)) {
-                                       ale= make_new_animlistelem(wo, ANIMTYPE_DSWOR, sce, ANIMTYPE_SCENE, (ID *)wo);
-                                       if (ale) {
-                                               BLI_addtail(anim_data, ale);
-                                               items++;
-                                       }
-                               }
-                               
-                               /* add F-Curve channels (drivers are F-Curves) */
-                               if (FILTER_WOR_SCED(wo)/*EXPANDED_DRVD(adt)*/ || !(filter_mode & ANIMFILTER_CHANNELS)) {
-                                       // XXX owner info is messed up now...
-                                       items += animdata_filter_fcurves(anim_data, ads, adt->drivers.first, NULL, wo, ANIMTYPE_DSWOR, filter_mode, (ID *)wo);
-                               }
-                       },
-                       { /* action */
-                               /* include world-expand widget? */
-                               if ((filter_mode & ANIMFILTER_CHANNELS) && !(filter_mode & ANIMFILTER_CURVESONLY)) {
-                                       ale= make_new_animlistelem(wo, ANIMTYPE_DSWOR, sce, ANIMTYPE_SCENE, (ID *)sce);
-                                       if (ale) {
-                                               BLI_addtail(anim_data, ale);
-                                               items++;
-                                       }
-                               }
-                               
-                               /* add channels */
-                               if (FILTER_WOR_SCED(wo) || (filter_mode & ANIMFILTER_CURVESONLY)) {
-                                       items += animdata_filter_action(ac, anim_data, ads, adt->action, filter_mode, wo, ANIMTYPE_DSWOR, (ID *)wo); 
-                               }
+       /* did we find anything? */
+       if (tmp_items) {
+               /* include anim-expand widget first */
+               if (filter_mode & ANIMFILTER_LIST_CHANNELS) {
+                       if (type != ANIMTYPE_NONE) {
+                               /* NOTE: active-status (and the associated checks) don't apply here... */
+                               ANIMCHANNEL_NEW_CHANNEL(cdata, type, sce);
                        }
-               )
-               
-               /* if expanded, check world textures too */
-               if (FILTER_WOR_SCED(wo) || (filter_mode & ANIMFILTER_CURVESONLY)) {
-                       /* textures for world */
-                       if (!(ads->filterflag & ADS_FILTER_NOTEX))
-                               items += animdata_filter_dopesheet_texs(ac, anim_data, ads, (ID *)wo, filter_mode);
                }
+               
+               /* now add the list of collected channels */
+               BLI_movelisttolist(anim_data, &tmp_data);
+               BLI_assert((tmp_data.first == tmp_data.last) && (tmp_data.first == NULL));
+               items += tmp_items;
        }
-       /* nodetree */
-       if ((ntree && ntree->adt) && !(ads->filterflag & ADS_FILTER_NONTREE)) {
-               /* Action, Drivers, or NLA for Nodetree */
-               adt= ntree->adt;
-               ANIMDATA_FILTER_CASES(ntree,
-                       { /* AnimData blocks - do nothing... */ },
-                       { /* nla */
-                               /* add NLA tracks */
-                               items += animdata_filter_nla(ac, anim_data, ads, adt, filter_mode, ntree, ANIMTYPE_DSNTREE, (ID *)ntree);
-                       },
-                       { /* drivers */
-                               /* include nodetree-expand widget? */
-                               if ((filter_mode & ANIMFILTER_CHANNELS) && !(filter_mode & ANIMFILTER_CURVESONLY)) {
-                                       ale= make_new_animlistelem(ntree, ANIMTYPE_DSNTREE, sce, ANIMTYPE_SCENE, (ID *)ntree);
-                                       if (ale) {
-                                               BLI_addtail(anim_data, ale);
-                                               items++;
-                                       }
-                               }
-                               
-                               /* add F-Curve channels (drivers are F-Curves) */
-                               if (FILTER_NTREE_SCED(ntree)/*EXPANDED_DRVD(adt)*/ || !(filter_mode & ANIMFILTER_CHANNELS)) {
-                                       // XXX owner info is messed up now...
-                                       items += animdata_filter_fcurves(anim_data, ads, adt->drivers.first, NULL, ntree, ANIMTYPE_DSNTREE, filter_mode, (ID *)ntree);
-                               }
-                       },
-                       { /* action */
-                               /* include nodetree-expand widget? */
-                               if ((filter_mode & ANIMFILTER_CHANNELS) && !(filter_mode & ANIMFILTER_CURVESONLY)) {
-                                       ale= make_new_animlistelem(ntree, ANIMTYPE_DSNTREE, sce, ANIMTYPE_SCENE, (ID *)sce);
-                                       if (ale) {
-                                               BLI_addtail(anim_data, ale);
-                                               items++;
-                                       }
-                               }
-                               
-                               /* add channels */
-                               if (FILTER_NTREE_SCED(ntree) || (filter_mode & ANIMFILTER_CURVESONLY)) {
-                                       items += animdata_filter_action(ac, anim_data, ads, adt->action, filter_mode, ntree, ANIMTYPE_DSNTREE, (ID *)ntree); 
-                               }
-                       }
-               )
-       }
-       /* line styles */
-       if (!(ads->filterflag & ADS_FILTER_NOLINESTYLE)) {
-               ListBase linestyles = {NULL, NULL};
-               LinkData *link;
-               SceneRenderLayer *srl;
-               FreestyleLineSet *lineset;
-               FreestyleLineStyle *linestyle;
-               for (srl = (SceneRenderLayer *)sce->r.layers.first; srl; srl = srl->next) {
-                       if (!(srl->layflag & SCE_LAY_FRS))
-                               continue;
-                       for (lineset = (FreestyleLineSet *)srl->freestyleConfig.linesets.first; lineset; lineset = lineset->next) {
-                               short ok = 0;
-                               linestyle = lineset->linestyle;
-                               if (!linestyle->adt)
-                                       continue;
-                               ANIMDATA_FILTER_CASES(linestyle, 
-                                       { /* AnimData blocks - do nothing... */ },
-                                       ok=1;, 
-                                       ok=1;, 
-                                       ok=1;)
-                               if (ok == 0) continue;
-                               /* check if the same linestyle is already in the list */
-                               for (link = (LinkData *)linestyles.first; link; link = link->next) {
-                                       if (link->data == linestyle) {
-                                               ok = 0;
-                                               break;
-                                       }
-                               }
-                               if (ok == 0) continue;
+       
+       /* return the number of items added to the list */
+       return items;
+ }
  
-                               /* add this linestyle to the list */
-                               link= MEM_callocN(sizeof(LinkData), "DopeSheet LineStyle cache");
-                               link->data= linestyle;
-                               BLI_addtail(&linestyles, link);
-                       }
+ static size_t animdata_filter_dopesheet_scene (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Scene *sce, int filter_mode)
+ {
+       ListBase tmp_data = {NULL, NULL};
+       size_t tmp_items = 0;
+       size_t items = 0;
+       
+       /* filter data contained under object first */
+       BEGIN_ANIMFILTER_SUBCHANNELS(EXPANDED_SCEC(sce))
+       {
+               bNodeTree *ntree= sce->nodetree;
+               World *wo= sce->world;
+               
+               /* Action, Drivers, or NLA for Scene */
+               if ((ads->filterflag & ADS_FILTER_NOSCE) == 0) {
+                       tmp_items += animdata_filter_ds_scene(ac, &tmp_data, ads, sce, filter_mode);
+               }
+               
+               /* world */
+               if ((wo && wo->adt) && !(ads->filterflag & ADS_FILTER_NOWOR)) {
+                       tmp_items += animdata_filter_ds_world(ac, &tmp_data, ads, sce, wo, filter_mode);
+               }
+               
+               /* nodetree */
+               if ((ntree && ntree->adt) && !(ads->filterflag & ADS_FILTER_NONTREE)) {
+                       tmp_items += animdata_filter_ds_nodetree(ac, &tmp_data, ads, (ID *)sce, ntree, filter_mode);
                }
-               if (linestyles.first) {
-                       for (link = (LinkData *)linestyles.first; link; link = link->next) {
-                               linestyle = (FreestyleLineStyle *)link->data;
-                               /* Action, Drivers, or NLA for line styles */
-                               adt= linestyle->adt;
-                               ANIMDATA_FILTER_CASES(linestyle,
-                                       { /* AnimData blocks - do nothing... */ },
-                                       { /* nla */
-                                               /* add NLA tracks */
-                                               items += animdata_filter_nla(ac, anim_data, ads, adt, filter_mode, linestyle, ANIMTYPE_DSLINESTYLE, (ID *)linestyle);
-                                       },
-                                       { /* drivers */
-                                               /* include linestyle-expand widget? */
-                                               if ((filter_mode & ANIMFILTER_CHANNELS) && !(filter_mode & ANIMFILTER_CURVESONLY)) {
-                                                       ale= make_new_animlistelem(linestyle, ANIMTYPE_DSLINESTYLE, sce, ANIMTYPE_SCENE, (ID *)linestyle);
-                                                       if (ale) {
-                                                               BLI_addtail(anim_data, ale);
-                                                               items++;
-                                                       }
-                                               }
-                                               
-                                               /* add F-Curve channels (drivers are F-Curves) */
-                                               if (FILTER_LS_SCED(linestyle)/*EXPANDED_DRVD(adt)*/ || !(filter_mode & ANIMFILTER_CHANNELS)) {
-                                                       // XXX owner info is messed up now...
-                                                       items += animdata_filter_fcurves(anim_data, ads, adt->drivers.first, NULL, linestyle, ANIMTYPE_DSLINESTYLE, filter_mode, (ID *)linestyle);
-                                               }
-                                       },
-                                       { /* action */
-                                               /* include nodetree-expand widget? */
-                                               if ((filter_mode & ANIMFILTER_CHANNELS) && !(filter_mode & ANIMFILTER_CURVESONLY)) {
-                                                       ale= make_new_animlistelem(linestyle, ANIMTYPE_DSLINESTYLE, sce, ANIMTYPE_SCENE, (ID *)sce);
-                                                       if (ale) {
-                                                               BLI_addtail(anim_data, ale);
-                                                               items++;
-                                                       }
-                                               }
-                                               
-                                               /* add channels */
-                                               if (FILTER_LS_SCED(linestyle) || (filter_mode & ANIMFILTER_CURVESONLY)) {
-                                                       items += animdata_filter_action(ac, anim_data, ads, adt->action, filter_mode, linestyle, ANIMTYPE_DSLINESTYLE, (ID *)linestyle); 
-                                               }
-                                       }
-                               )
 +
++              /* line styles */
++              if ((ads->filterflag & ADS_FILTER_NOLINESTYLE) == 0) {
++                      tmp_items += animdata_filter_ds_linestyle(ac, &tmp_data, ads, sce, filter_mode);
++              }
+               
+               // TODO: one day, when sequencer becomes its own datatype, perhaps it should be included here
+       }
+       END_ANIMFILTER_SUBCHANNELS;
+       
+       /* if we collected some channels, add these to the new list... */
+       if (tmp_items) {
+               /* firstly add object expander if required */
+               if (filter_mode & ANIMFILTER_LIST_CHANNELS) {
+                       /* check if filtering by selection */
+                       if ANIMCHANNEL_SELOK((sce->flag & SCE_DS_SELECTED)) {
+                               /* NOTE: active-status doesn't matter for this! */
+                               ANIMCHANNEL_NEW_CHANNEL(sce, ANIMTYPE_SCENE, sce);
                        }
-                       /* free cache */
-                       BLI_freelistN(&linestyles);
                }
+               
+               /* now add the list of collected channels */
+               BLI_movelisttolist(anim_data, &tmp_data);
+               BLI_assert((tmp_data.first == tmp_data.last) && (tmp_data.first == NULL));
+               items += tmp_items;
        }
-       // TODO: scene compositing nodes (these aren't standard node-trees)
        
-       /* return the number of items added to the list */
+       /* return the number of items added */
        return items;
  }
  
index 620d1dc51ed234192589df62d3d007f7de136167,b730913a368d70a5a7819c0d02699858284468ca..bd95177637afa3f9aa60c7a76fb2129a0ba6caac
@@@ -158,7 -154,7 +154,8 @@@ typedef enum eAnim_ChannelType 
        ANIMTYPE_DSMESH,
        ANIMTYPE_DSTEX,
        ANIMTYPE_DSLAT,
 +      ANIMTYPE_DSLINESTYLE,
+       ANIMTYPE_DSSPK,
        
        ANIMTYPE_SHAPEKEY,
        
@@@ -219,8 -231,6 +232,7 @@@ typedef enum eAnimFilter_Flags 
  #define EXPANDED_SCEC(sce) ((sce->flag & SCE_DS_COLLAPSED)==0)
        /* 'Sub-Scene' channels (flags stored in Data block) */
  #define FILTER_WOR_SCED(wo) ((wo->flag & WO_DS_EXPAND))
- #define FILTER_NTREE_SCED(ntree) ((ntree->flag & NTREE_DS_EXPAND))
 +#define FILTER_LS_SCED(linestyle) ((linestyle->flag & LS_DS_EXPAND))
        /* 'Object' channels */
  #define SEL_OBJC(base) ((base->flag & SELECT))
  #define EXPANDED_OBJC(ob) ((ob->nlaflag & OB_ADS_COLLAPSED)==0)
index 17cd7ae41bd6f2f5bc489e23bab40d6206d45391,4392e49e5d7c0367a8a823602c5e57921c2b53e2..87c8a6d39a60108f1c0317814464f7ade9e13814
@@@ -145,7 -144,7 +144,8 @@@ static int nla_panel_context(const bCon
                        case ANIMTYPE_DSPART:
                        case ANIMTYPE_DSMBALL:
                        case ANIMTYPE_DSARM:
 +                      case ANIMTYPE_DSLINESTYLE:
+                       case ANIMTYPE_DSSPK:
                        {
                                /* for these channels, we only do AnimData */
                                if (ale->id && ale->adt) {
index f2c030ab32707c71eb05c4310a827227487c80f6,8775d256b800cadd3654758921b511893cffdf7d..80691aceb6a700980ea3856cd064757a2ef1d67d
@@@ -179,7 -178,7 +178,8 @@@ static int mouse_nla_channels (bAnimCon
                case ANIMTYPE_DSMESH:
                case ANIMTYPE_DSTEX:
                case ANIMTYPE_DSLAT:
 +              case ANIMTYPE_DSLINESTYLE:
+               case ANIMTYPE_DSSPK:
                {
                        /* sanity checking... */
                        if (ale->adt) {
Simple merge
index 6562d602b8d9b3162cb9b2dc85a487a8043c695b,a820e59779f6cb51461628b253b5fbc36a4287b9..03a20400cfdfdba5541e0e2a4a2b06c48d0fc87d
@@@ -552,7 -553,7 +553,8 @@@ typedef enum eDopeSheet_FilterFlag 
        ADS_FILTER_NOARM                        = (1<<18),
        ADS_FILTER_NONTREE                      = (1<<19),
        ADS_FILTER_NOTEX                        = (1<<20),
-       ADS_FILTER_NOLINESTYLE          = (1<<21),
+       ADS_FILTER_NOSPK                        = (1<<21),
++      ADS_FILTER_NOLINESTYLE          = (1<<22),
        
                /* NLA-specific filters */
        ADS_FILTER_NLA_NOACT            = (1<<25),      /* if the AnimData block has no NLA data, don't include to just show Action-line */
index bc86d6d212c2a27f2168a396bb6b47960bfa5d7d,694b403c7c5ced8eeee02fc799c3684796799e0c..fb7b16e8857d3c6438cb468632a0ff496cd79e3e
@@@ -132,8 -132,7 +132,9 @@@ const char *includefiles[] = 
        "DNA_anim_types.h",
        "DNA_boid_types.h",
        "DNA_smoke_types.h",
+       "DNA_speaker_types.h",
 +      "DNA_freestyle_types.h",
 +      "DNA_linestyle_types.h",
  
        // empty string to indicate end of includefiles
        ""
@@@ -1198,6 -1197,5 +1199,7 @@@ int main(int argc, char ** argv
  #include "DNA_anim_types.h"
  #include "DNA_boid_types.h"
  #include "DNA_smoke_types.h"
+ #include "DNA_speaker_types.h"
 +#include "DNA_freestyle_types.h"
 +#include "DNA_linestyle_types.h"
  /* end of list */
Simple merge
index 45cf21c5036c992c5e18c777b18baa0046058e2b,d69cb2063abf418dcf9a3229b33a8b41fb1c4113..262a115f555593d725456686a208fc67c81163d4
@@@ -64,7 -64,7 +64,8 @@@
  #include "BKE_particle.h"
  #include "BKE_font.h"
  #include "BKE_node.h"
+ #include "BKE_speaker.h"
 +#include "BKE_linestyle.h"
  
  #include "DNA_armature_types.h"
  #include "DNA_camera_types.h"
index 237277867ad0e1bf603076775378e7ee6880e636,a04fdfa0f7445e31694186ec21875a624045ebae..e513ac3e27b7881fabf313618a1de242ebcba2ed
@@@ -51,10 -51,9 +51,11 @@@ struct Curve
  struct EditBone;
  struct EditFace;
  struct EditMesh;
+ struct EnvMap;
  struct ID;
  struct FCurve;
 +struct FreestyleConfig;
 +struct FreestyleLineSet;
  struct ImBuf;
  struct Image;
  struct ImageUser;