made grease pencil delete a frame if you delete all the strokes in it.
authorJoseph Eagar <joeedh@gmail.com>
Fri, 3 Apr 2009 03:16:31 +0000 (03:16 +0000)
committerJoseph Eagar <joeedh@gmail.com>
Fri, 3 Apr 2009 03:16:31 +0000 (03:16 +0000)
source/blender/include/BDR_gpencil.h
source/blender/src/drawgpencil.c
source/blender/src/gpencil.c

index 6af156775bea5f34ef9feac0f33b62db740dc006..6848be2a48194e8471d2c5ebd06843601abb4151 100644 (file)
@@ -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);
index 1b3d869b2f844823b97a0fd3ce9be1117a049113..914a604de443d700014850c4b393c1a73630834d 100644 (file)
@@ -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);
 }
index f4cfc0c0dd6b1acbeb5f6f1f5d3d470337d11930..fa502a1af596e24035dd5a256a996be121078d9e 100644 (file)
@@ -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 */