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:
authorSergey Sharybin <sergey.vfx@gmail.com>2014-01-27 13:41:16 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2014-01-27 13:42:46 +0400
commit1d12c3fd534b8307ac01f8f0eb6e0ee61c1bd6e4 (patch)
tree4ac7cd082b81ec63f840e7f55ac513e2cbe6016b /source/blender/editors/mask
parentbee6c1779e9337fbc0b34d9747b4aeb647b44cfa (diff)
Implement clipboard for mask splines
So now it's possible to copy-paste splines between layers. Implementation is pretty much straightforward and duplicates some logic which we've got in sequencer/tracking clipboards. Will work on a common routine for clipboards later, for now it's not so much crucial to have.
Diffstat (limited to 'source/blender/editors/mask')
-rw-r--r--source/blender/editors/mask/mask_edit.c4
-rw-r--r--source/blender/editors/mask/mask_intern.h2
-rw-r--r--source/blender/editors/mask/mask_ops.c69
3 files changed, 75 insertions, 0 deletions
diff --git a/source/blender/editors/mask/mask_edit.c b/source/blender/editors/mask/mask_edit.c
index 62eb9cc240a..ad287a3af9f 100644
--- a/source/blender/editors/mask/mask_edit.c
+++ b/source/blender/editors/mask/mask_edit.c
@@ -456,6 +456,10 @@ void ED_operatortypes_mask(void)
/* duplicate */
WM_operatortype_append(MASK_OT_duplicate);
+
+ /* clipboard */
+ WM_operatortype_append(MASK_OT_copy_splines);
+ WM_operatortype_append(MASK_OT_paste_splines);
}
void ED_keymap_mask(wmKeyConfig *keyconf)
diff --git a/source/blender/editors/mask/mask_intern.h b/source/blender/editors/mask/mask_intern.h
index 09ca2290781..9461922ef78 100644
--- a/source/blender/editors/mask/mask_intern.h
+++ b/source/blender/editors/mask/mask_intern.h
@@ -79,6 +79,8 @@ struct MaskSplinePoint *ED_mask_point_find_nearest(
void MASK_OT_layer_move(struct wmOperatorType *ot);
void MASK_OT_duplicate(struct wmOperatorType *ot);
+void MASK_OT_copy_splines(struct wmOperatorType *ot);
+void MASK_OT_paste_splines(struct wmOperatorType *ot);
/* mask_relationships.c */
void MASK_OT_parent_set(struct wmOperatorType *ot);
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;
+}