[Bf-blender-cvs] [5b88ab25bd8] master: Fix T75219: Move to New Layer not working

Antonio Vazquez noreply at git.blender.org
Tue Mar 31 18:54:54 CEST 2020


Commit: 5b88ab25bd83804af007136a1c7b9d8a9d1c1514
Author: Antonio Vazquez
Date:   Tue Mar 31 18:54:41 2020 +0200
Branches: master
https://developer.blender.org/rB5b88ab25bd83804af007136a1c7b9d8a9d1c1514

Fix T75219: Move to New Layer not working

This was an old design problem.

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

M	release/scripts/startup/bl_ui/properties_grease_pencil_common.py
M	source/blender/editors/gpencil/gpencil_edit.c

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

diff --git a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
index 64d4b6e2d4a..5647f35383a 100644
--- a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
+++ b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
@@ -332,7 +332,7 @@ class GPENCIL_MT_move_to_layer(Menu):
 
             layout.separator()
 
-        layout.operator("gpencil.layer_add", text="New Layer", icon='ADD')
+        layout.operator("gpencil.move_to_layer", text="New Layer", icon='ADD').layer = -1
 
 
 class GPENCIL_MT_layer_active(Menu):
diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c
index dc7bbfb99fa..91169b34e34 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -1569,7 +1569,13 @@ static int gp_move_to_layer_exec(bContext *C, wmOperator *op)
   }
 
   /* Try to get layer */
-  target_layer = BLI_findlink(&gpd->layers, layer_num);
+  if (layer_num > -1) {
+    target_layer = BLI_findlink(&gpd->layers, layer_num);
+  }
+  else {
+    /* Create a new layer. */
+    target_layer = BKE_gpencil_layer_addnew(gpd, "GP_Layer", true);
+  }
 
   if (target_layer == NULL) {
     /* back autolock status */
@@ -1655,7 +1661,8 @@ void GPENCIL_OT_move_to_layer(wmOperatorType *ot)
   ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 
   /* GPencil layer to use. */
-  ot->prop = RNA_def_int(ot->srna, "layer", 0, 0, INT_MAX, "Grease Pencil Layer", "", 0, INT_MAX);
+  ot->prop = RNA_def_int(
+      ot->srna, "layer", 0, -1, INT_MAX, "Grease Pencil Layer", "", -1, INT_MAX);
   RNA_def_property_flag(ot->prop, PROP_HIDDEN | PROP_SKIP_SAVE);
 }



More information about the Bf-blender-cvs mailing list