diff options
author | Antonioya <blendergit@gmail.com> | 2019-02-14 18:36:40 +0300 |
---|---|---|
committer | Antonioya <blendergit@gmail.com> | 2019-02-14 18:52:14 +0300 |
commit | 76747d0a11582ccd49fde494a51187dc191d6aee (patch) | |
tree | a87cb4d649d9ec1d2e9361691a516e5fe1b54392 /source/blender/editors/gpencil | |
parent | a2510434bb3121a39a792c60bde35e100c0c6e00 (diff) |
GP: Avoid eraser in empty frames and add warning.
Also capture event to avoid Move transform.
Note: Now it's using a report message. Maybe this can be removed, but without the message, the event is captured by move transform.
Diffstat (limited to 'source/blender/editors/gpencil')
-rw-r--r-- | source/blender/editors/gpencil/gpencil_paint.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index 8fc7978aa44..3ab2b205596 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -2084,7 +2084,8 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode, Deps if (p->custom_color[3]) copy_v3_v3(p->gpl->color, p->custom_color); } - if (p->gpl->flag & GP_LAYER_LOCKED) { + if ((paintmode != GP_PAINTMODE_ERASER) && + (p->gpl->flag & GP_LAYER_LOCKED)) { p->status = GP_STATUS_ERROR; if (G.debug & G_DEBUG) printf("Error: Cannot paint on locked layer\n"); @@ -3123,6 +3124,8 @@ static void gpencil_guide_event_handling(bContext *C, wmOperator *op, const wmEv static int gpencil_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event) { tGPsdata *p = NULL; + Object *ob = CTX_data_active_object(C); + bGPdata *gpd = (bGPdata *)ob->data; if (G.debug & G_DEBUG) printf("GPencil - Starting Drawing\n"); @@ -3141,6 +3144,23 @@ static int gpencil_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event return OPERATOR_CANCELLED; } } + else { + /* don't erase empty frames */ + bool has_layer_to_erase = false; + for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) { + /* Skip if layer not editable */ + if (gpencil_layer_is_editable(gpl)) { + if (gpl->actframe && gpl->actframe->strokes.first) { + has_layer_to_erase = true; + break; + } + } + } + if (!has_layer_to_erase) { + BKE_report(op->reports, RPT_ERROR, "Nothing to erase or all layers locked"); + return OPERATOR_FINISHED; + } + } /* try to initialize context data needed while drawing */ if (!gpencil_draw_init(C, op, event)) { @@ -3193,7 +3213,6 @@ static int gpencil_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event gpencil_guide_event_handling(C, op, event, p); } - Object *ob = CTX_data_active_object(C); if (ob && (ob->type == OB_GPENCIL) && ((p->gpd->flag & GP_DATA_STROKE_PAINTMODE) == 0)) { /* FIXME: use the mode switching operator, this misses notifiers, messages. */ /* Just set paintmode flag... */ |