diff options
author | Antonio Vazquez <blendergit@gmail.com> | 2021-01-21 18:00:06 +0300 |
---|---|---|
committer | Antonio Vazquez <blendergit@gmail.com> | 2021-01-21 18:00:12 +0300 |
commit | cfd54ad7d78ec798183959bea3342b0d0546d918 (patch) | |
tree | dcd6369c79b601814f957272ce379933f9898e6b /source/blender/editors/gpencil | |
parent | 9c4c3fbabc4f1d535d77f2219db7aedcae222ac9 (diff) |
GPencil: New option to Duplicate Layers with Empty Keyframes
This option allows to duplicate the layer and keyframes but without copying the strokes. This is very handy for the cleanup and paint process.
Diffstat (limited to 'source/blender/editors/gpencil')
-rw-r--r-- | source/blender/editors/gpencil/gpencil_data.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/source/blender/editors/gpencil/gpencil_data.c b/source/blender/editors/gpencil/gpencil_data.c index 8f24ce0ddd8..27e5ba1a30a 100644 --- a/source/blender/editors/gpencil/gpencil_data.c +++ b/source/blender/editors/gpencil/gpencil_data.c @@ -449,20 +449,25 @@ void GPENCIL_OT_layer_annotation_move(wmOperatorType *ot) ot->prop = RNA_def_enum(ot->srna, "type", slot_move, 0, "Type", ""); } /* ********************* Duplicate Layer ************************** */ +enum { + GP_LAYER_DUPLICATE_ALL = 0, + GP_LAYER_DUPLICATE_EMPTY = 1, +}; -static int gpencil_layer_copy_exec(bContext *C, wmOperator *UNUSED(op)) +static int gpencil_layer_copy_exec(bContext *C, wmOperator *op) { bGPdata *gpd = ED_gpencil_data_get_active(C); bGPDlayer *gpl = BKE_gpencil_layer_active_get(gpd); bGPDlayer *new_layer; - + const int mode = RNA_enum_get(op->ptr, "mode"); + const bool dup_strokes = (bool)(mode == GP_LAYER_DUPLICATE_ALL); /* sanity checks */ if (ELEM(NULL, gpd, gpl)) { return OPERATOR_CANCELLED; } /* make copy of layer, and add it immediately after the existing layer */ - new_layer = BKE_gpencil_layer_duplicate(gpl); + new_layer = BKE_gpencil_layer_duplicate(gpl, true, dup_strokes); BLI_insertlinkafter(&gpd->layers, gpl, new_layer); /* ensure new layer has a unique name, and is now the active layer */ @@ -484,6 +489,12 @@ static int gpencil_layer_copy_exec(bContext *C, wmOperator *UNUSED(op)) void GPENCIL_OT_layer_duplicate(wmOperatorType *ot) { + static const EnumPropertyItem copy_mode[] = { + {GP_LAYER_DUPLICATE_ALL, "ALL", 0, "All Data", ""}, + {GP_LAYER_DUPLICATE_EMPTY, "EMPTY", 0, "Empty Keyframes", ""}, + {0, NULL, 0, NULL, NULL}, + }; + /* identifiers */ ot->name = "Duplicate Layer"; ot->idname = "GPENCIL_OT_layer_duplicate"; @@ -495,6 +506,8 @@ void GPENCIL_OT_layer_duplicate(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + RNA_def_enum(ot->srna, "mode", copy_mode, GP_LAYER_DUPLICATE_ALL, "Mode", ""); } /* ********************* Duplicate Layer in a new object ************************** */ |