From 8ca30120a206c8b78645dd3d45c9891acaeebac1 Mon Sep 17 00:00:00 2001 From: Joseph Eagar Date: Fri, 3 Apr 2009 03:16:31 +0000 Subject: made grease pencil delete a frame if you delete all the strokes in it. --- source/blender/include/BDR_gpencil.h | 2 +- source/blender/src/drawgpencil.c | 2 +- source/blender/src/gpencil.c | 10 ++++++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/source/blender/include/BDR_gpencil.h b/source/blender/include/BDR_gpencil.h index 6af156775be..6848be2a481 100644 --- a/source/blender/include/BDR_gpencil.h +++ b/source/blender/include/BDR_gpencil.h @@ -65,7 +65,7 @@ struct bGPdata *gpencil_data_getactive(struct ScrArea *sa); short gpencil_data_setactive(struct ScrArea *sa, struct bGPdata *gpd); struct ScrArea *gpencil_data_findowner(struct bGPdata *gpd); -void gpencil_frame_delete_laststroke(struct bGPDframe *gpf); +void gpencil_frame_delete_laststroke(struct bGPDframe *gpf, bGPDlayer *gpl); struct bGPDframe *gpencil_layer_getframe(struct bGPDlayer *gpl, int cframe, short addnew); void gpencil_layer_delframe(struct bGPDlayer *gpl, struct bGPDframe *gpf); diff --git a/source/blender/src/drawgpencil.c b/source/blender/src/drawgpencil.c index 1b3d869b2f8..914a604de44 100644 --- a/source/blender/src/drawgpencil.c +++ b/source/blender/src/drawgpencil.c @@ -140,7 +140,7 @@ void gp_ui_delstroke_cb (void *gpd, void *gpl) bGPDframe *gpf= gpencil_layer_getframe(gpl, CFRA, 0); gpencil_layer_setactive(gpd, gpl); - gpencil_frame_delete_laststroke(gpf); + gpencil_frame_delete_laststroke(gpf, gpl); scrarea_queue_winredraw(curarea); } diff --git a/source/blender/src/gpencil.c b/source/blender/src/gpencil.c index f4cfc0c0dd6..fa502a1af59 100644 --- a/source/blender/src/gpencil.c +++ b/source/blender/src/gpencil.c @@ -484,7 +484,7 @@ ScrArea *gpencil_data_findowner (bGPdata *gpd) /* -------- GP-Frame API ---------- */ /* delete the last stroke of the given frame */ -void gpencil_frame_delete_laststroke (bGPDframe *gpf) +void gpencil_frame_delete_laststroke (bGPDframe *gpf, bGPDlayer *gpl) { bGPDstroke *gps= (gpf) ? gpf->strokes.last : NULL; @@ -495,6 +495,11 @@ void gpencil_frame_delete_laststroke (bGPDframe *gpf) /* free the stroke and its data */ MEM_freeN(gps->points); BLI_freelinkN(&gpf->strokes, gps); + + if (gpf->strokes.first == NULL) { + gpencil_layer_delframe(gpl, gpf); + gpencil_layer_getframe(gpl, CFRA, 0); + } } /* -------- GP-Layer API ---------- */ @@ -603,6 +608,7 @@ bGPDframe *gpencil_layer_getframe (bGPDlayer *gpl, int cframe, short addnew) else if (found) gpl->actframe= gpf; else { + gpl->actframe = gpl->frames.first; /* unresolved errogenous situation! */ printf("Error: cannot find appropriate gp-frame \n"); /* gpl->actframe should still be NULL */ @@ -696,7 +702,7 @@ void gpencil_delete_laststroke (bGPdata *gpd) bGPDlayer *gpl= gpencil_layer_getactive(gpd); bGPDframe *gpf= gpencil_layer_getframe(gpl, CFRA, 0); - gpencil_frame_delete_laststroke(gpf); + gpencil_frame_delete_laststroke(gpf, gpl); } /* delete the active frame */ -- cgit v1.2.3