Added support for line styles in the Graph Editor, DopeSheet
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>
Tue, 21 Sep 2010 22:23:10 +0000 (22:23 +0000)
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>
Tue, 21 Sep 2010 22:23:10 +0000 (22:23 +0000)
and NLA Editor.

12 files changed:
release/scripts/ui/space_dopesheet.py
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/DNA_linestyle_types.h
source/blender/makesrna/intern/rna_action.c

index 19f642684814d15f948b904ac1714e81689d934b..e1b92ab4d323bc18b93739848973d5424def04dc 100644 (file)
@@ -60,6 +60,8 @@ def dopesheet_filter(layout, context):
         row.prop(dopesheet, "show_armatures", text="")
     if bpy.data.particles:
         row.prop(dopesheet, "show_particles", text="")
+    if bpy.data.linestyles:
+        row.prop(dopesheet, "show_linestyles", text="")
 
     if bpy.data.groups:
         row = layout.row(align=True)
index 3fb8e441d6f049630571e8b7291463348debbbc0..dbd13e9188f16e31d8ef2a3e3dff2af266af760a 100644 (file)
@@ -42,6 +42,7 @@
 #include "DNA_space_types.h"
 #include "DNA_key_types.h"
 #include "DNA_lamp_types.h"
+#include "DNA_linestyle_types.h"
 #include "DNA_mesh_types.h"
 #include "DNA_material_types.h"
 #include "DNA_meta_types.h"
@@ -2157,6 +2158,82 @@ 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_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?
@@ -2489,6 +2566,7 @@ void ANIM_init_channel_typeinfo_data (void)
                animchannelTypeInfo[type++]= &ACF_DSARM;                /* Armature Channel */
                animchannelTypeInfo[type++]= &ACF_DSMESH;               /* Mesh Channel */
                animchannelTypeInfo[type++]= &ACF_DSTEX;                /* Texture Channel */
+               animchannelTypeInfo[type++]= &ACF_DSLINESTYLE;  /* LineStyle Channel */
                
                animchannelTypeInfo[type++]= &ACF_SHAPEKEY;             /* ShapeKey */
                
index e229de4200649e1f13314d408ab8371d4e8301e3..496d41ae4dc8b631fdec860f5e677a0cfa89661b 100644 (file)
@@ -229,6 +229,7 @@ void ANIM_deselect_anim_channels (bAnimContext *ac, void *data, short datatype,
                                case ANIMTYPE_DSMESH:
                                case ANIMTYPE_DSNTREE:
                                case ANIMTYPE_DSTEX:
+                               case ANIMTYPE_DSLINESTYLE:
                                {
                                        if ((ale->adt) && (ale->adt->flag & ADT_UI_SELECTED))
                                                sel= ACHANNEL_SETFLAG_CLEAR;
@@ -312,6 +313,7 @@ void ANIM_deselect_anim_channels (bAnimContext *ac, void *data, short datatype,
                        case ANIMTYPE_DSMESH:
                        case ANIMTYPE_DSNTREE:
                        case ANIMTYPE_DSTEX:
+                       case ANIMTYPE_DSLINESTYLE:
                        {
                                /* need to verify that this data is valid for now */
                                if (ale->adt) {
@@ -1733,6 +1735,7 @@ static int mouse_anim_channels (bAnimContext *ac, float x, int channel_index, sh
                case ANIMTYPE_DSMESH:
                case ANIMTYPE_DSNTREE:
                case ANIMTYPE_DSTEX:
+               case ANIMTYPE_DSLINESTYLE:
                {
                        /* sanity checking... */
                        if (ale->adt) {
index 0ff75c1cdedd1644f8756e9ba2d90d85e8f1af5a..2a16e27df2953949d6c71c3b34474e40979be121 100644 (file)
@@ -52,6 +52,7 @@
 #include "DNA_camera_types.h"
 #include "DNA_lamp_types.h"
 #include "DNA_lattice_types.h"
+#include "DNA_linestyle_types.h"
 #include "DNA_key_types.h"
 #include "DNA_material_types.h"
 #include "DNA_mesh_types.h"
@@ -678,6 +679,19 @@ bAnimListElem *make_new_animlistelem (void *data, short datatype, void *owner, s
                                ale->key_data= (adt) ? adt->action : NULL;
                                ale->datatype= ALE_ACT;
                                
+                               ale->adt= BKE_animdata_from_id(data);
+                       }
+                               break;
+                       case ANIMTYPE_DSLINESTYLE:
+                       {
+                               FreestyleLineStyle *linestyle= (FreestyleLineStyle *)data;
+                               AnimData *adt= linestyle->adt;
+                               
+                               ale->flag= FILTER_LS_SCED(linestyle); 
+                               
+                               ale->key_data= (adt) ? adt->action : NULL;
+                               ale->datatype= ALE_ACT;
+                               
                                ale->adt= BKE_animdata_from_id(data);
                        }
                                break;
@@ -2010,7 +2024,99 @@ static int animdata_filter_dopesheet_scene (bAnimContext *ac, ListBase *anim_dat
                )
        }
 
-       
+       /* 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;
+
+                               /* add this linestyle to the list */
+                               link= MEM_callocN(sizeof(LinkData), "DopeSheet LineStyle cache");
+                               link->data= linestyle;
+                               BLI_addtail(&linestyles, link);
+                       }
+               }
+
+               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); 
+                                               }
+                                       }
+                               )
+                       }
+
+                       /* free cache */
+                       BLI_freelistN(&linestyles);
+               }
+       }
+
        // TODO: scene compositing nodes (these aren't standard node-trees)
        
        /* return the number of items added to the list */
@@ -2044,7 +2150,7 @@ static int animdata_filter_dopesheet (bAnimContext *ac, ListBase *anim_data, bDo
        /* scene-linked animation */
        // TODO: sequencer, composite nodes - are we to include those here too?
        {
-               short sceOk= 0, worOk= 0, nodeOk=0;
+               short sceOk= 0, worOk= 0, nodeOk=0, lsOk = 0;
                
                /* check filtering-flags if ok */
                ANIMDATA_FILTER_CASES(sce, 
@@ -2084,17 +2190,41 @@ static int animdata_filter_dopesheet (bAnimContext *ac, ListBase *anim_data, bDo
                                nodeOk= !(ads->filterflag & ADS_FILTER_NONTREE);, 
                                nodeOk= !(ads->filterflag & ADS_FILTER_NONTREE);)
                }
+
+               /* line styles */
+               {
+                       SceneRenderLayer *srl;
+                       FreestyleLineSet *lineset;
+
+                       for (srl = (SceneRenderLayer *)sce->r.layers.first; srl; srl = srl->next) {
+                               if (srl->layflag & SCE_LAY_FRS) {
+                                       for (lineset = (FreestyleLineSet *)srl->freestyleConfig.linesets.first; lineset; lineset = lineset->next) {
+                                               ANIMDATA_FILTER_CASES(lineset->linestyle, 
+                                                       {
+                                                               /* for the special AnimData blocks only case, we only need to add
+                                                                * the block if it is valid... then other cases just get skipped (hence ok=0)
+                                                                */
+                                                               ANIMDATA_ADD_ANIMDATA(lineset->linestyle);
+                                                               lsOk=0;
+                                                       },
+                                                       lsOk= !(ads->filterflag & ADS_FILTER_NOLINESTYLE);, 
+                                                       lsOk= !(ads->filterflag & ADS_FILTER_NOLINESTYLE);, 
+                                                       lsOk= !(ads->filterflag & ADS_FILTER_NOLINESTYLE);)
+                                       }
+                               }
+                       }
+               }
                
                /* if only F-Curves with visible flags set can be shown, check that 
                 * datablocks haven't been set to invisible 
                 */
                if (filter_mode & ANIMFILTER_CURVEVISIBLE) {
                        if ((sce->adt) && (sce->adt->flag & ADT_CURVES_NOT_VISIBLE))
-                               sceOk= worOk= nodeOk= 0;
+                               sceOk= worOk= nodeOk= lsOk= 0;
                }
                
                /* check if not all bad (i.e. so there is something to show) */
-               if ( !(!sceOk && !worOk && !nodeOk) ) {
+               if ( !(!sceOk && !worOk && !nodeOk && !lsOk) ) {
                        /* add scene data to the list of filtered channels */
                        items += animdata_filter_dopesheet_scene(ac, anim_data, ads, sce, filter_mode);
                }
index 55bada5ba4ea5fa81e13d203d6fcc652a2f2bfa2..545b8462d4c65e4a0534b303292a05d42cb48d0f 100644 (file)
@@ -723,7 +723,7 @@ void scene_to_keylist(bDopeSheet *ads, Scene *sce, DLRBT_Tree *keys, DLRBT_Tree
                }
 
                /* linestyle animdata */
-               if (sce->r.mode & R_EDGE_FRS) {
+               if (sce->r.mode & R_EDGE_FRS && !(filterflag & ADS_FILTER_NOLINESTYLE)) {
                        SceneRenderLayer *srl;
                        FreestyleLineSet *lineset;
 
index 17d674784f8843a8cad612cc9b93c3e9259243d8..03bb8da529fa396e24882cf996ef91cd3e0f43ef 100644 (file)
@@ -39,6 +39,7 @@
 #include "DNA_camera_types.h"
 #include "DNA_key_types.h"
 #include "DNA_lamp_types.h"
+#include "DNA_linestyle_types.h"
 #include "DNA_mesh_types.h"
 #include "DNA_material_types.h"
 #include "DNA_object_types.h"
@@ -364,6 +365,24 @@ static short scene_keyframes_loop(KeyframeEditData *ked, Scene *sce, KeyframeEdi
                        return 1;
        }
        
+       /* Line styles */
+       {
+               SceneRenderLayer *srl;
+               FreestyleLineSet *lineset;
+               FreestyleLineStyle *linestyle;
+
+               for (srl = (SceneRenderLayer *)sce->r.layers.first; srl; srl = srl->next) {
+                       if (srl->layflag & SCE_LAY_FRS) {
+                               for (lineset = (FreestyleLineSet *)srl->freestyleConfig.linesets.first; lineset; lineset = lineset->next) {
+                                       linestyle = lineset->linestyle;
+                                       if (linestyle->adt) {
+                                               if (adt_keyframes_loop(ked, linestyle->adt, key_ok, key_cb, fcu_cb, filterflag))
+                                                       return 1;
+                                       }
+                               }
+                       }
+               }
+       }
        
        return 0;
 }
index 5fb7fa41752a7f52483fcc579f34315ef5341ca1..cf2b32653c8f51b0129419c6b02be89aee8546c5 100644 (file)
@@ -151,6 +151,7 @@ typedef enum eAnim_ChannelType {
        ANIMTYPE_DSARM,
        ANIMTYPE_DSMESH,
        ANIMTYPE_DSTEX,
+       ANIMTYPE_DSLINESTYLE,
        
        ANIMTYPE_SHAPEKEY,
        
@@ -212,6 +213,7 @@ typedef enum eAnimFilter_Flags {
        /* '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 a728cc900c2fe9e11ef9d7bfa7db4397e81eefee..2b3944051551a8b1956766ca682abd1bf3103a37 100644 (file)
@@ -138,6 +138,7 @@ static int nla_panel_context(const bContext *C, PointerRNA *adt_ptr, PointerRNA
                        case ANIMTYPE_DSPART:
                        case ANIMTYPE_DSMBALL:
                        case ANIMTYPE_DSARM:
+                       case ANIMTYPE_DSLINESTYLE:
                        {
                                /* for these channels, we only do AnimData */
                                if (ale->id && ale->adt) {
index b00cba676d0fb6165a4a3f6ceb0f7b54b897a311..d60551dac2eab2b82180a855300f21f50c6d3b5f 100644 (file)
@@ -173,6 +173,7 @@ static int mouse_nla_channels (bAnimContext *ac, float x, int channel_index, sho
                case ANIMTYPE_DSARM:
                case ANIMTYPE_DSMESH:
                case ANIMTYPE_DSTEX:
+               case ANIMTYPE_DSLINESTYLE:
                {
                        /* sanity checking... */
                        if (ale->adt) {
index f7bbf9235abeea5012e472d90b1135e945682b04..d9f0f20ad52498c2a5c8eebffefc0784fb839cda 100644 (file)
@@ -545,6 +545,7 @@ typedef enum eDopeSheet_FilterFlag {
        ADS_FILTER_NOARM                        = (1<<18),
        ADS_FILTER_NONTREE                      = (1<<19),
        ADS_FILTER_NOTEX                        = (1<<20),
+       ADS_FILTER_NOLINESTYLE          = (1<<21),
        
                /* 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 a19bbdf1bf92a95ce9f2a179f5fb35e9a62b61b7..a04cbb8c79db275f919ed51f424fc11a4ad90c39 100644 (file)
@@ -178,13 +178,18 @@ typedef struct LineStyleThicknessModifier_DistanceFromObject {
 #define LS_PANEL_DISTORT      5
 #define LS_PANEL_MISC         6
 
+/* FreestyleLineStyle::flag */
+#define LS_DS_EXPAND 1 /* for animation editors */
+
 typedef struct FreestyleLineStyle {
        ID id;
        struct AnimData *adt;
 
        float r, g, b, alpha;
        float thickness;
+       int flag;
        int panel; /* for UI */
+       int pad1;
 
        ListBase color_modifiers;
        ListBase alpha_modifiers;
index 42ddf340f1234fc20d4b1b91b19b99c446226823..d5f494ebbfbc626004be4da1fb8d3f064f5ca47a 100644 (file)
@@ -253,6 +253,12 @@ static void rna_def_dopesheet(BlenderRNA *brna)
        RNA_def_property_ui_icon(prop, ICON_LAMP_DATA, 0);
        RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL);
        
+       prop= RNA_def_property(srna, "show_linestyles", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOLINESTYLE);
+       RNA_def_property_ui_text(prop, "Display Line Style", "Include visualization of Line Style related Animation data");
+       RNA_def_property_ui_icon(prop, ICON_BRUSH_DATA, 0); /* FIXME */
+       RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL);
+       
        prop= RNA_def_property(srna, "show_textures", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOTEX);
        RNA_def_property_ui_text(prop, "Display Texture", "Include visualization of Texture related Animation data");