diff options
author | Antonioya <blendergit@gmail.com> | 2018-11-05 11:57:30 +0300 |
---|---|---|
committer | Antonioya <blendergit@gmail.com> | 2018-11-05 11:59:38 +0300 |
commit | 7c7c8f34925aad3180ff0626f4162aec135a0a5d (patch) | |
tree | c884bfd52fa3efff085c1eec2fdacaa8f2d829ab /source/blender/blenkernel/intern/gpencil.c | |
parent | efd133a9a650bfd29e55aba60ad9a9d9acef0a2a (diff) |
GP: Add new layer above active layer
Before, the layer was added to tail always, but this was weird for 2D animators.
Diffstat (limited to 'source/blender/blenkernel/intern/gpencil.c')
-rw-r--r-- | source/blender/blenkernel/intern/gpencil.c | 13 |
1 files changed, 11 insertions, 2 deletions
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) { |