diff options
author | Antonioya <blendergit@gmail.com> | 2018-10-31 13:00:02 +0300 |
---|---|---|
committer | Antonioya <blendergit@gmail.com> | 2018-10-31 13:00:28 +0300 |
commit | 14e1dfda4e145fb4d6975fd1531fad149b761bbb (patch) | |
tree | a6f4811ddf599540f871c77a1dd9d0c918e55951 /source/blender/makesrna/intern/rna_gpencil.c | |
parent | 7bc84559aa80841591f1ccf5c09f843931d6dabb (diff) |
GP: New Autolock Inactive Layer
This option locks any layer no active to avoid any accidental change.
Diffstat (limited to 'source/blender/makesrna/intern/rna_gpencil.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_gpencil.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c index 73f26e9848e..9a8673e9a26 100644 --- a/source/blender/makesrna/intern/rna_gpencil.c +++ b/source/blender/makesrna/intern/rna_gpencil.c @@ -101,6 +101,38 @@ static void rna_GPencil_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Pointe WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL); } +static void rna_GPencil_autolock(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + bGPdata *gpd = (bGPdata *)ptr->id.data; + bGPDlayer *gpl = NULL; + + if (gpd->flag & GP_DATA_AUTOLOCK_LAYERS) { + bGPDlayer *layer = BKE_gpencil_layer_getactive(gpd); + + /* Lock all other layers */ + for (gpl = gpd->layers.first; gpl; gpl = gpl->next) { + /* unlock active layer */ + if (gpl == layer) { + gpl->flag &= ~GP_LAYER_LOCKED; + } + else { + gpl->flag |= GP_LAYER_LOCKED; + } + } + } + else { + /* If disable is better unlock all layers by default or it looks there is + * a problem in the UI because the user expects all layers will be unlocked + */ + for (gpl = gpd->layers.first; gpl; gpl = gpl->next) { + gpl->flag &= ~GP_LAYER_LOCKED; + } + } + + /* standard update */ + rna_GPencil_update(bmain, scene, ptr); +} + static void rna_GPencil_editmode_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { bGPdata *gpd = (bGPdata *)ptr->id.data; @@ -1410,6 +1442,12 @@ static void rna_def_gpencil_data(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Adaptative UV", "Automatic UVs are calculated depending of the stroke size"); RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); + prop = RNA_def_property(srna, "use_autolock_layers", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_DATA_AUTOLOCK_LAYERS); + RNA_def_property_ui_text(prop, "Autolock Layers", + "Lock automatically all layers except active one to avoid accidental changes"); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_autolock"); + prop = RNA_def_property(srna, "edit_line_color", PROP_FLOAT, PROP_COLOR_GAMMA); RNA_def_property_float_sdna(prop, NULL, "line_color"); RNA_def_property_array(prop, 4); |