diff options
author | Antonioya <blendergit@gmail.com> | 2019-02-12 20:14:36 +0300 |
---|---|---|
committer | Antonioya <blendergit@gmail.com> | 2019-02-12 20:15:00 +0300 |
commit | 70c56997344edc1a69d95fe209a6a61fc55605f1 (patch) | |
tree | 5dd2231c65780ec40295b3cda4583a707e74e146 /source/blender/editors/gpencil | |
parent | a1d440de4a3dc7ac3064c4c6df555be238a646c7 (diff) |
GP: Move to new layer did not work with autolock
When the autolock layer option was enabled, the move to new layer operator was not working as expected.
Diffstat (limited to 'source/blender/editors/gpencil')
-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); |