made grease pencil delete a frame if you delete all the strokes in it.

This commit is contained in:
Joseph Eagar 2009-04-03 03:16:31 +00:00
parent b22705f169
commit 8ca30120a2
3 changed files with 10 additions and 4 deletions

@ -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);

@ -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);
}

@ -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 */