[Bf-blender-cvs] [1abb1ba9a35] master: GPencil: Fix unreported autolock layers using Dopesheet

Antonio Vazquez noreply at git.blender.org
Tue Sep 3 18:59:17 CEST 2019


Commit: 1abb1ba9a353b5d377da20ae4b41d3cf3439857a
Author: Antonio Vazquez
Date:   Tue Sep 3 18:58:57 2019 +0200
Branches: master
https://developer.blender.org/rB1abb1ba9a353b5d377da20ae4b41d3cf3439857a

GPencil: Fix unreported autolock layers using Dopesheet

When select a layer in Dopesheet, the autolock layer was not working.

Now the Dopesheet code calls the function for autolock. Also some code cleanup to move the logic to new function.

===================================================================

M	source/blender/blenkernel/BKE_gpencil.h
M	source/blender/blenkernel/intern/gpencil.c
M	source/blender/editors/animation/anim_channels_edit.c
M	source/blender/editors/space_action/action_select.c
M	source/blender/makesrna/intern/rna_gpencil.c

===================================================================

diff --git a/source/blender/blenkernel/BKE_gpencil.h b/source/blender/blenkernel/BKE_gpencil.h
index 310eba86231..011590100de 100644
--- a/source/blender/blenkernel/BKE_gpencil.h
+++ b/source/blender/blenkernel/BKE_gpencil.h
@@ -149,6 +149,7 @@ bool BKE_gpencil_layer_delframe(struct bGPDlayer *gpl, struct bGPDframe *gpf);
 struct bGPDlayer *BKE_gpencil_layer_getactive(struct bGPdata *gpd);
 void BKE_gpencil_layer_setactive(struct bGPdata *gpd, struct bGPDlayer *active);
 void BKE_gpencil_layer_delete(struct bGPdata *gpd, struct bGPDlayer *gpl);
+void BKE_gpencil_layer_autolock_set(struct bGPdata *gpd);
 
 /* Brush */
 struct Material *BKE_gpencil_brush_material_get(struct Brush *brush);
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index 4e564b805cc..47ed9f3bd83 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -267,7 +267,8 @@ bGPDframe *BKE_gpencil_frame_addnew(bGPDlayer *gpl, int cframe)
 
   /* check whether frame was added successfully */
   if (state == -1) {
-    CLOG_ERROR(&LOG, "Frame (%d) existed already for this layer. Using existing frame", cframe);
+    CLOG_ERROR(
+        &LOG, "Frame (%d) existed already for this layer_active. Using existing frame", cframe);
 
     /* free the newly created one, and use the old one instead */
     MEM_freeN(gpf);
@@ -1015,6 +1016,37 @@ void BKE_gpencil_layer_setactive(bGPdata *gpd, bGPDlayer *active)
   }
 }
 
+/* Set locked layers for autolock mode. */
+void BKE_gpencil_layer_autolock_set(bGPdata *gpd)
+{
+  BLI_assert(gpd != NULL);
+
+  bGPDlayer *gpl;
+
+  if (gpd->flag & GP_DATA_AUTOLOCK_LAYERS) {
+    bGPDlayer *layer_active = BKE_gpencil_layer_getactive(gpd);
+
+    /* Lock all other layers */
+    for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
+      /* unlock active layer */
+      if (gpl == layer_active) {
+        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;
+    }
+  }
+}
+
 /* delete the active gp-layer */
 void BKE_gpencil_layer_delete(bGPdata *gpd, bGPDlayer *gpl)
 {
diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c
index 7e913014a87..61b8e4a2341 100644
--- a/source/blender/editors/animation/anim_channels_edit.c
+++ b/source/blender/editors/animation/anim_channels_edit.c
@@ -3114,6 +3114,7 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index,
         ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, gpl, ANIMTYPE_GPLAYER);
         /* update other layer status */
         BKE_gpencil_layer_setactive(gpd, gpl);
+        BKE_gpencil_layer_autolock_set(gpd);
       }
 
       /* Grease Pencil updates */
diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c
index 8504ab9f469..cbf4d0628e6 100644
--- a/source/blender/editors/space_action/action_select.c
+++ b/source/blender/editors/space_action/action_select.c
@@ -1724,6 +1724,7 @@ static void mouse_action_keys(bAnimContext *ac,
         /* Update other layer status. */
         if (BKE_gpencil_layer_getactive(gpd) != gpl) {
           BKE_gpencil_layer_setactive(gpd, gpl);
+          BKE_gpencil_layer_autolock_set(gpd);
           WM_main_add_notifier(NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
         }
       }
diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c
index bd3321377d3..01ecf2f8cae 100644
--- a/source/blender/makesrna/intern/rna_gpencil.c
+++ b/source/blender/makesrna/intern/rna_gpencil.c
@@ -151,30 +151,7 @@ static void rna_GPencil_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Pointe
 static void rna_GPencil_autolock(Main *bmain, Scene *scene, PointerRNA *ptr)
 {
   bGPdata *gpd = (bGPdata *)ptr->owner_id;
-  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;
-    }
-  }
+  BKE_gpencil_layer_autolock_set(gpd);
 
   /* standard update */
   rna_GPencil_update(bmain, scene, ptr);



More information about the Bf-blender-cvs mailing list