Example #1
0
/* Delete selected grease-pencil layers */
void delete_gpencil_layers (void)
{
	ListBase act_data = {NULL, NULL};
	bActListElem *ale, *next;
	void *data;
	short datatype;
	int filter;
	
	/* determine what type of data we are operating on */
	data = get_action_context(&datatype);
	if (data == NULL) return;
	if (datatype != ACTCONT_GPENCIL) return;
	
	/* filter data */
	filter= (ACTFILTER_VISIBLE | ACTFILTER_FOREDIT | ACTFILTER_CHANNELS | ACTFILTER_SEL);
	actdata_filter(&act_data, filter, data, datatype);
	
	/* clean up grease-pencil layers */
	for (ale= act_data.first; ale; ale= next) {
		bGPdata *gpd= (bGPdata *)ale->owner;
		bGPDlayer *gpl= (bGPDlayer *)ale->data;
		next= ale->next;
		
		/* free layer and its data */
		if (SEL_GPL(gpl)) {
			free_gpencil_frames(gpl);
			BLI_freelinkN(&gpd->layers, gpl);
		}
		
		/* free temp memory */
		BLI_freelinkN(&act_data, ale);
	}
	
	BIF_undo_push("Delete GPencil Layers");
}
Example #2
0
/* delete the active gp-layer */
void gpencil_layer_delete(bGPdata *gpd, bGPDlayer *gpl)
{
	/* error checking */
	if (ELEM(NULL, gpd, gpl)) 
		return;
	
	/* free layer */
	free_gpencil_frames(gpl);
	BLI_freelinkN(&gpd->layers, gpl);
}
Example #3
0
/* Free all of the gp-layers for a viewport (list should be &gpd->layers or so) */
void free_gpencil_layers(ListBase *list)
{
	bGPDlayer *gpl, *gpln;
	
	/* error checking */
	if (list == NULL) return;
	
	/* delete layers */
	for (gpl = list->first; gpl; gpl = gpln) {
		gpln = gpl->next;
		
		/* free layers and their data */
		free_gpencil_frames(gpl);
		BLI_freelinkN(list, gpl);
	}
}
Example #4
0
static void rna_GPencil_layer_clear(bGPDlayer *layer)
{
	free_gpencil_frames(layer);

	WM_main_add_notifier(NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
}