Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-06-08 18:31:38 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-06-08 18:31:38 +0400
commitb33c5168f4070e30f5ef66dcca76d1ad3c4aaa38 (patch)
tree9303fd49af427824aa3867813a45ec5e46cea781 /source/blender/editors/animation
parent68c365e2f040cb61266d6ef1309fb22d064ab0d0 (diff)
mask animation keys now editable in the dope sheet (duplicate, transform, delete, select- etc).
Diffstat (limited to 'source/blender/editors/animation')
-rw-r--r--source/blender/editors/animation/anim_channels_defines.c170
-rw-r--r--source/blender/editors/animation/anim_channels_edit.c59
-rw-r--r--source/blender/editors/animation/anim_filter.c118
-rw-r--r--source/blender/editors/animation/keyframes_draw.c19
4 files changed, 361 insertions, 5 deletions
diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c
index 7f7d269a7c3..f6b301c4594 100644
--- a/source/blender/editors/animation/anim_channels_defines.c
+++ b/source/blender/editors/animation/anim_channels_defines.c
@@ -54,6 +54,7 @@
#include "DNA_world_types.h"
#include "DNA_gpencil_types.h"
#include "DNA_speaker_types.h"
+#include "DNA_mask_types.h"
#include "RNA_access.h"
@@ -2516,6 +2517,172 @@ static bAnimChannelType ACF_GPL =
acf_gpl_setting_ptr /* pointer for setting */
};
+
+/* Mask Datablock ------------------------------------------- */
+
+/* get backdrop color for mask datablock widget */
+static void acf_mask_color(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale), float r_color[3])
+{
+ /* these are ID-blocks, but not exactly standalone... */
+ UI_GetThemeColorShade3fv(TH_DOPESHEET_CHANNELSUBOB, 20, r_color);
+}
+
+// TODO: just get this from RNA?
+static int acf_mask_icon(bAnimListElem *UNUSED(ale))
+{
+ return ICON_GREASEPENCIL; // MASK_TODO - need real icon
+}
+
+/* check if some setting exists for this channel */
+static short acf_mask_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale), int setting)
+{
+ switch (setting) {
+ /* only select and expand supported */
+ case ACHANNEL_SETTING_SELECT:
+ case ACHANNEL_SETTING_EXPAND:
+ return 1;
+
+ default:
+ return 0;
+ }
+}
+
+/* get the appropriate flag(s) for the setting when it is valid */
+static int acf_mask_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg)
+{
+ /* clear extra return data first */
+ *neg = 0;
+
+ switch (setting) {
+ case ACHANNEL_SETTING_SELECT: /* selected */
+ return AGRP_SELECTED;
+
+ case ACHANNEL_SETTING_EXPAND: /* expanded */
+ return MASK_ANIMF_EXPAND;
+ }
+
+ /* this shouldn't happen */
+ return 0;
+}
+
+/* get pointer to the setting */
+static void *acf_mask_setting_ptr(bAnimListElem *ale, int UNUSED(setting), short *type)
+{
+ Mask *mask = (Mask *)ale->data;
+
+ /* all flags are just in mask->flag for now... */
+ return GET_ACF_FLAG_PTR(mask->flag, type);
+}
+
+/* mask datablock type define */
+static bAnimChannelType ACF_MASKDATA =
+{
+ "Mask Datablock", /* type name */
+
+ acf_mask_color, /* backdrop color */
+ acf_group_backdrop, /* backdrop */
+ acf_generic_indention_0, /* indent level */
+ acf_generic_group_offset, /* offset */
+
+ acf_generic_idblock_name, /* name */
+ acf_generic_idfill_nameprop, /* name prop */
+ acf_mask_icon, /* icon */
+
+ acf_mask_setting_valid, /* has setting */
+ acf_mask_setting_flag, /* flag for setting */
+ acf_mask_setting_ptr /* pointer for setting */
+};
+
+/* Mask Layer ------------------------------------------- */
+
+/* name for grease pencil layer entries */
+static void acf_masklay_name(bAnimListElem *ale, char *name)
+{
+ MaskLayer *masklay = (MaskLayer *)ale->data;
+
+ if (masklay && name)
+ BLI_strncpy(name, masklay->name, ANIM_CHAN_NAME_SIZE);
+}
+
+/* name property for grease pencil layer entries */
+static short acf_masklay_name_prop(bAnimListElem *ale, PointerRNA *ptr, PropertyRNA **prop)
+{
+ if (ale->data) {
+ RNA_pointer_create(ale->id, &RNA_MaskLayer, ale->data, ptr);
+ *prop = RNA_struct_name_property(ptr->type);
+
+ return (*prop != NULL);
+ }
+
+ return 0;
+}
+
+/* check if some setting exists for this channel */
+static short acf_masklay_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale), int setting)
+{
+ switch (setting) {
+ /* unsupported */
+ case ACHANNEL_SETTING_EXPAND: /* mask layers are more like F-Curves than groups */
+ case ACHANNEL_SETTING_VISIBLE: /* graph editor only */
+ return 0;
+
+ /* always available */
+ default:
+ return 1;
+ }
+}
+
+/* get the appropriate flag(s) for the setting when it is valid */
+static int acf_masklay_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg)
+{
+ /* clear extra return data first */
+ *neg = 0;
+
+ switch (setting) {
+ case ACHANNEL_SETTING_SELECT: /* selected */
+ return MASK_LAYERFLAG_SELECT;
+
+// case ACHANNEL_SETTING_MUTE: /* muted */
+// return GP_LAYER_HIDE;
+
+ case ACHANNEL_SETTING_PROTECT: /* protected */
+ // *neg = 1; - if we change this to edtiability
+ return MASK_LAYERFLAG_LOCKED;
+
+ default: /* unsupported */
+ return 0;
+ }
+}
+
+/* get pointer to the setting */
+static void *acf_masklay_setting_ptr(bAnimListElem *ale, int UNUSED(setting), short *type)
+{
+ MaskLayer *masklay = (MaskLayer *)ale->data;
+
+ /* all flags are just in agrp->flag for now... */
+ return GET_ACF_FLAG_PTR(masklay->flag, type);
+}
+
+/* grease pencil layer type define */
+static bAnimChannelType ACF_MASKLAYER =
+{
+ "Mask Layer", /* type name */
+
+ acf_generic_channel_color, /* backdrop color */
+ acf_generic_channel_backdrop, /* backdrop */
+ acf_generic_indention_flexible, /* indent level */
+ acf_generic_group_offset, /* offset */
+
+ acf_masklay_name, /* name */
+ acf_masklay_name_prop, /* name prop */
+ NULL, /* icon */
+
+ acf_masklay_setting_valid, /* has setting */
+ acf_masklay_setting_flag, /* flag for setting */
+ acf_masklay_setting_ptr /* pointer for setting */
+};
+
+
/* *********************************************** */
/* Type Registration and General Access */
@@ -2566,6 +2733,9 @@ static void ANIM_init_channel_typeinfo_data(void)
animchannelTypeInfo[type++] = &ACF_GPD; /* Grease Pencil Datablock */
animchannelTypeInfo[type++] = &ACF_GPL; /* Grease Pencil Layer */
+ animchannelTypeInfo[type++] = &ACF_MASKDATA; /* Mask Datablock */
+ animchannelTypeInfo[type++] = &ACF_MASKLAYER; /* Mask Layer */
+
// TODO: these types still need to be implemented!!!
// probably need a few extra flags for these special cases...
animchannelTypeInfo[type++] = NULL; /* NLA Track */
diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c
index dc0886a473e..5c57407d14e 100644
--- a/source/blender/editors/animation/anim_channels_edit.c
+++ b/source/blender/editors/animation/anim_channels_edit.c
@@ -43,6 +43,7 @@
#include "DNA_scene_types.h"
#include "DNA_key_types.h"
#include "DNA_gpencil_types.h"
+#include "DNA_mask_types.h"
#include "RNA_access.h"
#include "RNA_define.h"
@@ -51,6 +52,7 @@
#include "BKE_fcurve.h"
#include "BKE_gpencil.h"
#include "BKE_context.h"
+#include "BKE_mask.h"
#include "BKE_global.h"
#include "UI_view2d.h"
@@ -258,6 +260,10 @@ void ANIM_deselect_anim_channels(bAnimContext *ac, void *data, short datatype, s
if (ale->flag & GP_LAYER_SELECT)
sel = ACHANNEL_SETFLAG_CLEAR;
break;
+ case ANIMTYPE_MASKLAYER:
+ if (ale->flag & MASK_LAYERFLAG_SELECT)
+ sel = ACHANNEL_SETFLAG_CLEAR;
+ break;
}
}
}
@@ -354,6 +360,14 @@ void ANIM_deselect_anim_channels(bAnimContext *ac, void *data, short datatype, s
ACHANNEL_SET_FLAG(gpl, sel, GP_LAYER_SELECT);
}
break;
+
+ case ANIMTYPE_MASKLAYER:
+ {
+ MaskLayer *masklay = (MaskLayer *)ale->data;
+
+ ACHANNEL_SET_FLAG(masklay, sel, MASK_LAYERFLAG_SELECT);
+ }
+ break;
}
}
@@ -1055,6 +1069,10 @@ static int animchannels_rearrange_exec(bContext *C, wmOperator *op)
/* Grease Pencil channels */
printf("Grease Pencil not supported for moving yet\n");
}
+ else if (ac.datatype == ANIMCONT_MASK) {
+ /* Grease Pencil channels */
+ printf("Mask does not supported for moving yet\n");
+ }
else if (ac.datatype == ANIMCONT_ACTION) {
/* Directly rearrange action's channels */
rearrange_action_channels(&ac, ac.data, mode);
@@ -1205,6 +1223,17 @@ static int animchannels_delete_exec(bContext *C, wmOperator *UNUSED(op))
BLI_freelinkN(&gpd->layers, gpl);
}
break;
+
+ case ANIMTYPE_MASKLAYER:
+ {
+ /* Grease Pencil layer */
+ Mask *mask = (Mask *)ale->id;
+ MaskLayer *masklay = (MaskLayer *)ale->data;
+
+ /* try to delete the layer's data and the layer itself */
+ BKE_mask_layer_remove(mask, masklay);
+ }
+ break;
}
}
@@ -2287,6 +2316,36 @@ static int mouse_anim_channels(bAnimContext *ac, float UNUSED(x), int channel_in
notifierFlags |= (ND_ANIMCHAN | NA_EDITED);
}
break;
+ case ANIMTYPE_MASKDATABLOCK:
+ {
+ Mask *mask = (Mask *)ale->data;
+
+ /* toggle expand
+ * - although the triangle widget already allows this, the whole channel can also be used for this purpose
+ */
+ mask->flag ^= MASK_ANIMF_EXPAND;
+
+ notifierFlags |= (ND_ANIMCHAN | NA_EDITED);
+ }
+ break;
+ case ANIMTYPE_MASKLAYER:
+ {
+ MaskLayer *masklay = (MaskLayer *)ale->data;
+
+ /* select/deselect */
+ if (selectmode == SELECT_INVERT) {
+ /* invert selection status of this layer only */
+ masklay->flag ^= MASK_LAYERFLAG_SELECT;
+ }
+ else {
+ /* select layer by itself */
+ ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR);
+ masklay->flag |= MASK_LAYERFLAG_SELECT;
+ }
+
+ notifierFlags |= (ND_ANIMCHAN | NA_EDITED);
+ }
+ break;
default:
if (G.debug & G_DEBUG)
printf("Error: Invalid channel type in mouse_anim_channels()\n");
diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c
index 160e6957513..752e458ef78 100644
--- a/source/blender/editors/animation/anim_filter.c
+++ b/source/blender/editors/animation/anim_filter.c
@@ -56,6 +56,7 @@
#include "DNA_lamp_types.h"
#include "DNA_lattice_types.h"
#include "DNA_key_types.h"
+#include "DNA_mask_types.h"
#include "DNA_material_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meta_types.h"
@@ -86,6 +87,7 @@
#include "BKE_main.h"
#include "BKE_material.h"
#include "BKE_node.h"
+#include "BKE_mask.h"
#include "BKE_sequencer.h"
#include "BKE_utildefines.h"
@@ -173,6 +175,22 @@ static short actedit_get_context(bAnimContext *ac, SpaceAction *saction)
ac->mode = saction->mode;
return 1;
+ case SACTCONT_MASK: /* Grease Pencil */ // XXX review how this mode is handled...
+ /* update scene-pointer (no need to check for pinning yet, as not implemented) */
+{
+ // TODO, other methods to get the mask
+ // Sequence *seq = BKE_sequencer_active_get(ac->scene);
+ //MovieClip *clip = ac->scene->clip;
+// struct Mask *mask = seq ? seq->mask : NULL;
+
+ saction->ads.source = (ID *)ac->scene;;
+
+ ac->datatype = ANIMCONT_MASK;
+ ac->data = &saction->ads;
+
+ ac->mode = saction->mode;
+ return 1;
+}
case SACTCONT_DOPESHEET: /* DopeSheet */
/* update scene-pointer (no need to check for pinning yet, as not implemented) */
saction->ads.source = (ID *)ac->scene;
@@ -807,7 +825,18 @@ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owne
ale->datatype = ALE_GPFRAME;
}
break;
-
+
+ case ANIMTYPE_MASKLAYER:
+ {
+ MaskLayer *masklay = (MaskLayer *)data;
+
+ ale->flag = masklay->flag;
+
+ ale->key_data = NULL;
+ ale->datatype = ALE_MASKLAY;
+ }
+ break;
+
case ANIMTYPE_NLATRACK:
{
NlaTrack *nlt = (NlaTrack *)data;
@@ -1353,6 +1382,83 @@ static size_t animdata_filter_gpencil(ListBase *anim_data, void *UNUSED(data), i
return items;
}
+static size_t animdata_filter_mask_data(ListBase *anim_data, Mask *mask, const int filter_mode)
+{
+ MaskLayer *masklay_act = BKE_mask_layer_active(mask);
+ MaskLayer *masklay;
+ size_t items = 0;
+
+ /* loop over layers as the conditions are acceptable */
+ for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
+ /* only if selected */
+ if (ANIMCHANNEL_SELOK(SEL_MASKLAY(masklay)) ) {
+ /* only if editable */
+// if (!(filter_mode & ANIMFILTER_FOREDIT) || EDITABLE_GPL(gpl)) {
+ /* active... */
+ if (!(filter_mode & ANIMFILTER_ACTIVE) || (masklay_act == masklay)) {
+ /* add to list */
+ ANIMCHANNEL_NEW_CHANNEL(masklay, ANIMTYPE_MASKLAYER, mask);
+
+
+// if (filter_mode & ANIMFILTER_TMP_PEEK)
+// return 1;
+// else {
+// bAnimListElem *ale = make_new_animlistelem(masklay, channel_type, (ID *)owner_id);
+// if (ale) {
+// BLI_addtail(anim_data, ale);
+// items ++;
+// }
+// }
+
+ }
+// }
+ }
+ }
+
+ return items;
+}
+
+static size_t animdata_filter_mask(ListBase *anim_data, void *UNUSED(data), int filter_mode)
+{
+ Mask *mask;
+ size_t items = 0;
+
+ /* for now, grab grease pencil datablocks directly from main */
+ // XXX: this is not good...
+ for (mask = G.main->mask.first; mask; mask = mask->id.next) {
+ ListBase tmp_data = {NULL, NULL};
+ size_t tmp_items = 0;
+
+ /* only show if gpd is used by something... */
+ if (ID_REAL_USERS(mask) < 1)
+ continue;
+
+ /* add gpencil animation channels */
+ BEGIN_ANIMFILTER_SUBCHANNELS(EXPANDED_MASK(mask))
+ {
+ tmp_items += animdata_filter_mask_data(&tmp_data, mask, 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(mask, ANIMTYPE_MASKDATABLOCK, NULL);
+ }
+
+ /* 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)
@@ -2280,7 +2386,7 @@ size_t ANIM_animdata_filter(bAnimContext *ac, ListBase *anim_data, int filter_mo
items += animfilter_action(ac, anim_data, ads, data, filter_mode, (ID *)obact);
}
break;
-
+
case ANIMCONT_SHAPEKEY: /* 'ShapeKey Editor' */
{
/* the check for the DopeSheet summary is included here since the summary works here too */
@@ -2294,7 +2400,13 @@ size_t ANIM_animdata_filter(bAnimContext *ac, ListBase *anim_data, int filter_mo
items = animdata_filter_gpencil(anim_data, data, filter_mode);
}
break;
-
+
+ case ANIMCONT_MASK:
+ {
+ items = animdata_filter_mask(anim_data, data, filter_mode);
+ }
+ break;
+
case ANIMCONT_DOPESHEET: /* 'DopeSheet Editor' */
{
/* the DopeSheet editor is the primary place where the DopeSheet summaries are useful */
diff --git a/source/blender/editors/animation/keyframes_draw.c b/source/blender/editors/animation/keyframes_draw.c
index cee8d15a807..e6fc4d5a168 100644
--- a/source/blender/editors/animation/keyframes_draw.c
+++ b/source/blender/editors/animation/keyframes_draw.c
@@ -209,7 +209,7 @@ static DLRBT_Node *nalloc_ak_masklayshape(void *data)
/* store settings based on state of BezTriple */
ak->cfra = masklay_shape->frame;
- ak->sel = (masklay_shape->flag & SELECT) ? SELECT : 0;
+ ak->sel = (masklay_shape->flag & MASK_SHAPE_SELECT) ? SELECT : 0;
/* set 'modified', since this is used to identify long keyframes */
ak->modified = 1;
@@ -224,7 +224,7 @@ static void nupdate_ak_masklayshape(void *node, void *data)
MaskLayerShape *masklay_shape = (MaskLayerShape *)data;
/* set selection status and 'touched' status */
- if (masklay_shape->flag & SELECT) ak->sel = SELECT;
+ if (masklay_shape->flag & MASK_SHAPE_SELECT) ak->sel = SELECT;
ak->modified += 1;
}
@@ -818,6 +818,21 @@ void draw_gpl_channel(View2D *v2d, bDopeSheet *ads, bGPDlayer *gpl, float ypos)
BLI_dlrbTree_free(&keys);
}
+void draw_masklay_channel(View2D *v2d, bDopeSheet *ads, MaskLayer *masklay, float ypos)
+{
+ DLRBT_Tree keys;
+
+ BLI_dlrbTree_init(&keys);
+
+ mask_to_keylist(ads, masklay, &keys);
+
+ BLI_dlrbTree_linkedlist_sync(&keys);
+
+ draw_keylist(v2d, &keys, NULL, ypos, (masklay->flag & MASK_LAYERFLAG_LOCKED));
+
+ BLI_dlrbTree_free(&keys);
+}
+
/* *************************** Keyframe List Conversions *************************** */
void summary_to_keylist(bAnimContext *ac, DLRBT_Tree *keys, DLRBT_Tree *blocks)