diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/gpencil/gpencil_edit.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index 580480a3b46..cee259eb6e9 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -1186,12 +1186,18 @@ static int gp_move_to_layer_exec(bContext *C, wmOperator *op) bGPDlayer *target_layer = NULL; ListBase strokes = {NULL, NULL}; int layer_num = RNA_enum_get(op->ptr, "layer"); + const bool use_autolock = (bool)(gpd->flag & GP_DATA_AUTOLOCK_LAYERS); if (GPENCIL_MULTIEDIT_SESSIONS_ON(gpd)) { BKE_report(op->reports, RPT_ERROR, "Operator not supported in multiframe edition"); return OPERATOR_CANCELLED; } + /* if autolock enabled, disabled now */ + if (use_autolock) { + gpd->flag &= ~GP_DATA_AUTOLOCK_LAYERS; + } + /* Get layer or create new one */ if (layer_num == -1) { /* Create layer */ @@ -1202,6 +1208,10 @@ static int gp_move_to_layer_exec(bContext *C, wmOperator *op) target_layer = BLI_findlink(&gpd->layers, layer_num); if (target_layer == NULL) { + /* back autolock status */ + if (use_autolock) { + gpd->flag |= GP_DATA_AUTOLOCK_LAYERS; + } BKE_reportf(op->reports, RPT_ERROR, "There is no layer number %d", layer_num); return OPERATOR_CANCELLED; } @@ -1234,6 +1244,11 @@ static int gp_move_to_layer_exec(bContext *C, wmOperator *op) BLI_addtail(&strokes, gps); } } + + /* if new layer and autolock, lock old layer */ + if ((layer_num == -1) && (use_autolock)) { + gpl->flag |= GP_LAYER_LOCKED; + } } CTX_DATA_END; @@ -1245,6 +1260,11 @@ static int gp_move_to_layer_exec(bContext *C, wmOperator *op) BLI_assert((strokes.first == strokes.last) && (strokes.first == NULL)); } + /* back autolock status */ + if (use_autolock) { + gpd->flag |= GP_DATA_AUTOLOCK_LAYERS; + } + /* updates */ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY); WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); |