[Bf-blender-cvs] [7c7c8f34925] blender2.8: GP: Add new layer above active layer
Antonioya
noreply at git.blender.org
Mon Nov 5 09:59:47 CET 2018
Commit: 7c7c8f34925aad3180ff0626f4162aec135a0a5d
Author: Antonioya
Date: Mon Nov 5 09:57:30 2018 +0100
Branches: blender2.8
https://developer.blender.org/rB7c7c8f34925aad3180ff0626f4162aec135a0a5d
GP: Add new layer above active layer
Before, the layer was added to tail always, but this was weird for 2D animators.
===================================================================
M source/blender/blenkernel/intern/gpencil.c
===================================================================
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index c540d6e0c35..3ab7fa88846 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -386,7 +386,8 @@ bGPDframe *BKE_gpencil_frame_addcopy(bGPDlayer *gpl, int cframe)
/* add a new gp-layer and make it the active layer */
bGPDlayer *BKE_gpencil_layer_addnew(bGPdata *gpd, const char *name, bool setactive)
{
- bGPDlayer *gpl;
+ bGPDlayer *gpl = NULL;
+ bGPDlayer *gpl_active = NULL;
/* check that list is ok */
if (gpd == NULL)
@@ -395,8 +396,16 @@ bGPDlayer *BKE_gpencil_layer_addnew(bGPdata *gpd, const char *name, bool setacti
/* allocate memory for frame and add to end of list */
gpl = MEM_callocN(sizeof(bGPDlayer), "bGPDlayer");
+ gpl_active = BKE_gpencil_layer_getactive(gpd);
+
/* add to datablock */
- BLI_addtail(&gpd->layers, gpl);
+ if (gpl_active == NULL) {
+ BLI_addtail(&gpd->layers, gpl);
+ }
+ else {
+ /* if active layer, add after that layer */
+ BLI_insertlinkafter(&gpd->layers,gpl_active, gpl);
+ }
/* annotation vs GP Object behaviour is slightly different */
if (gpd->flag & GP_DATA_ANNOTATIONS) {
More information about the Bf-blender-cvs
mailing list