diff options
Diffstat (limited to 'source/blender/editors/mask/mask_ops.c')
-rw-r--r-- | source/blender/editors/mask/mask_ops.c | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/source/blender/editors/mask/mask_ops.c b/source/blender/editors/mask/mask_ops.c index f6ba4063e90..c255168d854 100644 --- a/source/blender/editors/mask/mask_ops.c +++ b/source/blender/editors/mask/mask_ops.c @@ -1599,3 +1599,72 @@ void MASK_OT_duplicate(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } + +/********************** copy splines to clipboard operator *********************/ + +static int copy_splines_exec(bContext *C, wmOperator *UNUSED(op)) +{ + Mask *mask = CTX_data_edit_mask(C); + MaskLayer *mask_layer = BKE_mask_layer_active(mask); + + BKE_mask_clipboard_copy_from_layer(mask_layer); + + return OPERATOR_FINISHED; +} + +void MASK_OT_copy_splines(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Copy Splines"; + ot->description = "Copy selected splines to clipboard"; + ot->idname = "MASK_OT_copy_splines"; + + /* api callbacks */ + ot->exec = copy_splines_exec; + ot->poll = ED_maskedit_mask_poll; + + /* flags */ + ot->flag = OPTYPE_REGISTER; +} + +/********************** paste tracks from clipboard operator *********************/ + +static int paste_splines_poll(bContext *C) +{ + if (ED_maskedit_mask_poll(C)) { + return BKE_mask_clipboard_is_empty() == false; + } + + return 0; +} + +static int paste_splines_exec(bContext *C, wmOperator *UNUSED(op)) +{ + Scene *scene = CTX_data_scene(C); + Mask *mask = CTX_data_edit_mask(C); + MaskLayer *mask_layer = BKE_mask_layer_active(mask); + + BKE_mask_clipboard_paste_to_layer(CTX_data_main(C), mask_layer); + + /* TODO: only update edited splines */ + BKE_mask_update_display(mask, CFRA); + + WM_event_add_notifier(C, NC_MASK | NA_EDITED, mask); + + return OPERATOR_FINISHED; +} + +void MASK_OT_paste_splines(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Paste Splines"; + ot->description = "Paste splines from clipboard"; + ot->idname = "MASK_OT_paste_splines"; + + /* api callbacks */ + ot->exec = paste_splines_exec; + ot->poll = paste_splines_poll; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; +} |