From c83d37ccc07c40813e44658857fc79886099b485 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 13 Jun 2012 08:35:50 +0000 Subject: [PATCH] mango request - highlight active mask layers. - remove keyframes when all layer data is removed. --- source/blender/blenkernel/BKE_mask.h | 1 + source/blender/blenkernel/intern/mask.c | 29 ++++++++++++++++--------- source/blender/editors/mask/mask_ops.c | 6 +++++ 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/source/blender/blenkernel/BKE_mask.h b/source/blender/blenkernel/BKE_mask.h index 345a2190e89..dd2c7cb3a18 100644 --- a/source/blender/blenkernel/BKE_mask.h +++ b/source/blender/blenkernel/BKE_mask.h @@ -48,6 +48,7 @@ struct MaskLayer *BKE_mask_layer_active(struct Mask *mask); void BKE_mask_layer_active_set(struct Mask *mask, struct MaskLayer *masklay); void BKE_mask_layer_remove(struct Mask *mask, struct MaskLayer *masklay); +void BKE_mask_layer_free_shapes(struct MaskLayer *masklay); void BKE_mask_layer_free(struct MaskLayer *masklay); void BKE_mask_spline_free(struct MaskSpline *spline); struct MaskSpline *BKE_mask_spline_copy(struct MaskSpline *spline); diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c index a28ff3a175d..012ce97b4d7 100644 --- a/source/blender/blenkernel/intern/mask.c +++ b/source/blender/blenkernel/intern/mask.c @@ -1029,10 +1029,27 @@ void BKE_mask_layer_shape_free(MaskLayerShape *masklay_shape) MEM_freeN(masklay_shape); } +/** \brief Free all animation keys for a mask layer + */ +void BKE_mask_layer_free_shapes(MaskLayer *masklay) +{ + MaskLayerShape *masklay_shape; + + /* free animation data */ + masklay_shape = masklay->splines_shapes.first; + while (masklay_shape) { + MaskLayerShape *next_masklay_shape = masklay_shape->next; + + BLI_remlink(&masklay->splines_shapes, masklay_shape); + BKE_mask_layer_shape_free(masklay_shape); + + masklay_shape = next_masklay_shape; + } +} + void BKE_mask_layer_free(MaskLayer *masklay) { MaskSpline *spline; - MaskLayerShape *masklay_shape; /* free splines */ spline = masklay->splines.first; @@ -1046,15 +1063,7 @@ void BKE_mask_layer_free(MaskLayer *masklay) } /* free animation data */ - masklay_shape = masklay->splines_shapes.first; - while (masklay_shape) { - MaskLayerShape *next_masklay_shape = masklay_shape->next; - - BLI_remlink(&masklay->splines_shapes, masklay_shape); - BKE_mask_layer_shape_free(masklay_shape); - - masklay_shape = next_masklay_shape; - } + BKE_mask_layer_free_shapes(masklay); MEM_freeN(masklay); } diff --git a/source/blender/editors/mask/mask_ops.c b/source/blender/editors/mask/mask_ops.c index 7c94b79010c..315e40380f9 100644 --- a/source/blender/editors/mask/mask_ops.c +++ b/source/blender/editors/mask/mask_ops.c @@ -957,6 +957,12 @@ static int delete_exec(bContext *C, wmOperator *UNUSED(op)) spline = next_spline; } + + /* not essential but confuses users when there are keys with no data! + * assume if they delete all data from the layer they also dont care about keys */ + if (masklay->splines.first == NULL) { + BKE_mask_layer_free_shapes(masklay); + } } /* TODO: only update edited splines */