diff options
author | Joshua Leung <aligorith@gmail.com> | 2015-02-18 02:08:07 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2015-02-18 04:49:41 +0300 |
commit | c7c711bb726b32ded12a921baffda3b434d44ddb (patch) | |
tree | 3861e3a9e1aa3622cb94546f93880a82dd12e7e7 /source/blender/editors/gpencil | |
parent | bd921686432af13b568a80defeae3d95ff9f22c8 (diff) |
GPencil Fix: Added checks to ensure that copy/paste doesn't paste incompatible strokes
There was a problem with the copy/paste functionality, where it would be possible to
paste 3d strokes into 2D editors, or 2D strokes into the 3D view. The problem with
that though is that these will not show up, and because there's no feedback at the
time, users may end up doing this pasting several times.
Diffstat (limited to 'source/blender/editors/gpencil')
-rw-r--r-- | source/blender/editors/gpencil/gpencil_edit.c | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index a830253f634..212d384e5ca 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -805,6 +805,30 @@ static int gp_strokes_paste_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_ERROR, "Can not paste strokes when active layer is hidden or locked"); return OPERATOR_CANCELLED; } + else { + /* Check that some of the strokes in the buffer can be used */ + bGPDstroke *gps; + bool ok = false; + + for (gps = gp_strokes_copypastebuf.first; gps; gps = gps->next) { + if (ED_gpencil_stroke_can_use(C, gps)) { + ok = true; + break; + } + } + + if (ok == false) { + /* XXX: this check is not 100% accurate (i.e. image editor is incompatible with normal 2D strokes), + * but should be enough to give users a good idea of what's going on + */ + if (CTX_wm_area(C)->spacetype == SPACE_VIEW3D) + BKE_report(op->reports, RPT_ERROR, "Cannot paste 2D strokes in 3D View"); + else + BKE_report(op->reports, RPT_ERROR, "Cannot paste 3D strokes in 2D editors"); + + return OPERATOR_CANCELLED; + } + } /* Deselect all strokes first */ CTX_DATA_BEGIN(C, bGPDstroke *, gps, editable_gpencil_strokes) @@ -832,12 +856,14 @@ static int gp_strokes_paste_exec(bContext *C, wmOperator *op) /* Copy each stroke into the layer */ for (gps = gp_strokes_copypastebuf.first; gps; gps = gps->next) { - bGPDstroke *new_stroke = MEM_dupallocN(gps); - - new_stroke->points = MEM_dupallocN(gps->points); - new_stroke->next = new_stroke->prev = NULL; - - BLI_addtail(&gpf->strokes, new_stroke); + if (ED_gpencil_stroke_can_use(C, gps)) { + bGPDstroke *new_stroke = MEM_dupallocN(gps); + + new_stroke->points = MEM_dupallocN(gps->points); + new_stroke->next = new_stroke->prev = NULL; + + BLI_addtail(&gpf->strokes, new_stroke); + } } } |