Пример #1
0
static void rna_NlaStrip_name_set(PointerRNA *ptr, const char *value)
{
	NlaStrip *data= (NlaStrip *)ptr->data;
	
	/* copy the name first */
	BLI_strncpy(data->name, value, sizeof(data->name));
	
	/* validate if there's enough info to do so */
	if (ptr->id.data) {
		AnimData *adt= BKE_animdata_from_id(ptr->id.data);
		BKE_nlastrip_validate_name(adt, data);
	}
}
Пример #2
0
static NlaStrip *rna_NlaStrip_new(NlaTrack *track, bContext *C, ReportList *reports, const char *UNUSED(name),
                                  int start, bAction *action)
{
	NlaStrip *strip = BKE_nlastrip_new(action);
	
	if (strip == NULL) {
		BKE_report(reports, RPT_ERROR, "Unable to create new strip");
		return NULL;
	}
	
	strip->end += (start - strip->start);
	strip->start = start;
	
	if (BKE_nlastrips_add_strip(&track->strips, strip) == 0) {
		BKE_report(reports, RPT_ERROR,
		           "Unable to add strip (the track does not have any space to accommodate this new strip)");
		BKE_nlastrip_free(NULL, strip);
		return NULL;
	}
	
	/* create dummy AnimData block so that BKE_nlastrip_validate_name()
	 * can be used to ensure a valid name, as we don't have one here...
	 *  - only the nla_tracks list is needed there, which we aim to reverse engineer here...
	 */
	{
		AnimData adt = {NULL};
		NlaTrack *nlt, *nlt_p;
		
		/* 'first' NLA track is found by going back up chain of given track's parents until we fall off */
		nlt_p = track; nlt = track;
		while ((nlt = nlt->prev) != NULL)
			nlt_p = nlt;
		adt.nla_tracks.first = nlt_p;
		
		/* do the same thing to find the last track */
		nlt_p = track; nlt = track;
		while ((nlt = nlt->next) != NULL)
			nlt_p = nlt;
		adt.nla_tracks.last = nlt_p;
		
		/* now we can just auto-name as usual */
		BKE_nlastrip_validate_name(&adt, strip);
	}
	
	WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_ADDED, NULL);
	
	return strip;
}