Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_nla/nla_edit.c
| Show First 20 Lines • Show All 687 Lines • ▼ Show 20 Lines | static int nlaedit_add_actionclip_exec(bContext *C, wmOperator *op) | ||||
| ANIM_animdata_freelist(&anim_data); | ANIM_animdata_freelist(&anim_data); | ||||
| /* refresh auto strip properties */ | /* refresh auto strip properties */ | ||||
| ED_nla_postop_refresh(&ac); | ED_nla_postop_refresh(&ac); | ||||
| DEG_relations_tag_update(ac.bmain); | DEG_relations_tag_update(ac.bmain); | ||||
| /* set notifier that things have changed */ | /* set notifier that things have changed */ | ||||
| WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); | WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_ADDED, NULL); | ||||
| /* done */ | /* done */ | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| void NLA_OT_actionclip_add(wmOperatorType *ot) | void NLA_OT_actionclip_add(wmOperatorType *ot) | ||||
| { | { | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| ▲ Show 20 Lines • Show All 113 Lines • ▼ Show 20 Lines | static int nlaedit_add_transition_exec(bContext *C, wmOperator *op) | ||||
| ANIM_animdata_freelist(&anim_data); | ANIM_animdata_freelist(&anim_data); | ||||
| /* was anything added? */ | /* was anything added? */ | ||||
| if (done) { | if (done) { | ||||
| /* refresh auto strip properties */ | /* refresh auto strip properties */ | ||||
| ED_nla_postop_refresh(&ac); | ED_nla_postop_refresh(&ac); | ||||
| /* set notifier that things have changed */ | /* set notifier that things have changed */ | ||||
| WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); | WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_ADDED, NULL); | ||||
| /* done */ | /* done */ | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| BKE_report(op->reports, | BKE_report(op->reports, | ||||
| RPT_ERROR, | RPT_ERROR, | ||||
| "Needs at least a pair of adjacent selected strips with a gap between them"); | "Needs at least a pair of adjacent selected strips with a gap between them"); | ||||
| ▲ Show 20 Lines • Show All 80 Lines • ▼ Show 20 Lines | static int nlaedit_add_sound_exec(bContext *C, wmOperator *UNUSED(op)) | ||||
| /* free temp data */ | /* free temp data */ | ||||
| ANIM_animdata_freelist(&anim_data); | ANIM_animdata_freelist(&anim_data); | ||||
| /* refresh auto strip properties */ | /* refresh auto strip properties */ | ||||
| ED_nla_postop_refresh(&ac); | ED_nla_postop_refresh(&ac); | ||||
| /* set notifier that things have changed */ | /* set notifier that things have changed */ | ||||
| WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); | WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_ADDED, NULL); | ||||
| /* done */ | /* done */ | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| void NLA_OT_soundclip_add(wmOperatorType *ot) | void NLA_OT_soundclip_add(wmOperatorType *ot) | ||||
| { | { | ||||
| /* identifiers */ | /* identifiers */ | ||||
| ▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | for (ale = anim_data.first; ale; ale = ale->next) { | ||||
| ale->update |= ANIM_UPDATE_DEPS; | ale->update |= ANIM_UPDATE_DEPS; | ||||
| } | } | ||||
| /* free temp data */ | /* free temp data */ | ||||
| ANIM_animdata_update(&ac, &anim_data); | ANIM_animdata_update(&ac, &anim_data); | ||||
| ANIM_animdata_freelist(&anim_data); | ANIM_animdata_freelist(&anim_data); | ||||
| /* set notifier that things have changed */ | /* set notifier that things have changed */ | ||||
| WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); | WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_ADDED, NULL); | ||||
| /* done */ | /* done */ | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| void NLA_OT_meta_add(wmOperatorType *ot) | void NLA_OT_meta_add(wmOperatorType *ot) | ||||
| { | { | ||||
| /* identifiers */ | /* identifiers */ | ||||
| ▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | for (ale = anim_data.first; ale; ale = ale->next) { | ||||
| ale->update |= ANIM_UPDATE_DEPS; | ale->update |= ANIM_UPDATE_DEPS; | ||||
| } | } | ||||
| /* free temp data */ | /* free temp data */ | ||||
| ANIM_animdata_update(&ac, &anim_data); | ANIM_animdata_update(&ac, &anim_data); | ||||
| ANIM_animdata_freelist(&anim_data); | ANIM_animdata_freelist(&anim_data); | ||||
| /* set notifier that things have changed */ | /* set notifier that things have changed */ | ||||
| WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); | WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_REMOVED, NULL); | ||||
| /* done */ | /* done */ | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| void NLA_OT_meta_remove(wmOperatorType *ot) | void NLA_OT_meta_remove(wmOperatorType *ot) | ||||
| { | { | ||||
| /* identifiers */ | /* identifiers */ | ||||
| ▲ Show 20 Lines • Show All 85 Lines • ▼ Show 20 Lines | if (done) { | ||||
| /* refresh auto strip properties */ | /* refresh auto strip properties */ | ||||
| ED_nla_postop_refresh(&ac); | ED_nla_postop_refresh(&ac); | ||||
| if (!linked) { | if (!linked) { | ||||
| DEG_relations_tag_update(ac.bmain); | DEG_relations_tag_update(ac.bmain); | ||||
| } | } | ||||
| /* set notifier that things have changed */ | /* set notifier that things have changed */ | ||||
| WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); | WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_ADDED, NULL); | ||||
| /* done */ | /* done */ | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 88 Lines • ▼ Show 20 Lines | static int nlaedit_delete_exec(bContext *C, wmOperator *UNUSED(op)) | ||||
| ANIM_animdata_freelist(&anim_data); | ANIM_animdata_freelist(&anim_data); | ||||
| /* refresh auto strip properties */ | /* refresh auto strip properties */ | ||||
| ED_nla_postop_refresh(&ac); | ED_nla_postop_refresh(&ac); | ||||
| DEG_relations_tag_update(ac.bmain); | DEG_relations_tag_update(ac.bmain); | ||||
| /* set notifier that things have changed */ | /* set notifier that things have changed */ | ||||
| WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); | WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_REMOVED, NULL); | ||||
| /* done */ | /* done */ | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| void NLA_OT_delete(wmOperatorType *ot) | void NLA_OT_delete(wmOperatorType *ot) | ||||
| { | { | ||||
| /* identifiers */ | /* identifiers */ | ||||
| ▲ Show 20 Lines • Show All 138 Lines • ▼ Show 20 Lines | static int nlaedit_split_exec(bContext *C, wmOperator *UNUSED(op)) | ||||
| /* free temp data */ | /* free temp data */ | ||||
| ANIM_animdata_freelist(&anim_data); | ANIM_animdata_freelist(&anim_data); | ||||
| /* refresh auto strip properties */ | /* refresh auto strip properties */ | ||||
| ED_nla_postop_refresh(&ac); | ED_nla_postop_refresh(&ac); | ||||
| /* set notifier that things have changed */ | /* set notifier that things have changed */ | ||||
| WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); | WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_ADDED, NULL); | ||||
| /* done */ | /* done */ | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| void NLA_OT_split(wmOperatorType *ot) | void NLA_OT_split(wmOperatorType *ot) | ||||
| { | { | ||||
| /* identifiers */ | /* identifiers */ | ||||
| ▲ Show 20 Lines • Show All 227 Lines • ▼ Show 20 Lines | static int nlaedit_swap_exec(bContext *C, wmOperator *op) | ||||
| /* free temp data */ | /* free temp data */ | ||||
| ANIM_animdata_freelist(&anim_data); | ANIM_animdata_freelist(&anim_data); | ||||
| /* refresh auto strip properties */ | /* refresh auto strip properties */ | ||||
| ED_nla_postop_refresh(&ac); | ED_nla_postop_refresh(&ac); | ||||
| /* set notifier that things have changed */ | /* set notifier that things have changed */ | ||||
| WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); | WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); | ||||
| WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ORDER, NULL); | |||||
| /* done */ | /* done */ | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| void NLA_OT_swap(wmOperatorType *ot) | void NLA_OT_swap(wmOperatorType *ot) | ||||
| { | { | ||||
| /* identifiers */ | /* identifiers */ | ||||
| ▲ Show 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | static int nlaedit_move_up_exec(bContext *C, wmOperator *UNUSED(op)) | ||||
| /* free temp data */ | /* free temp data */ | ||||
| ANIM_animdata_freelist(&anim_data); | ANIM_animdata_freelist(&anim_data); | ||||
| /* refresh auto strip properties */ | /* refresh auto strip properties */ | ||||
| ED_nla_postop_refresh(&ac); | ED_nla_postop_refresh(&ac); | ||||
| /* set notifier that things have changed */ | /* set notifier that things have changed */ | ||||
| WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); | WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); | ||||
| WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ORDER, NULL); | |||||
| /* done */ | /* done */ | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| void NLA_OT_move_up(wmOperatorType *ot) | void NLA_OT_move_up(wmOperatorType *ot) | ||||
| { | { | ||||
| /* identifiers */ | /* identifiers */ | ||||
| ▲ Show 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | static int nlaedit_move_down_exec(bContext *C, wmOperator *UNUSED(op)) | ||||
| /* free temp data */ | /* free temp data */ | ||||
| ANIM_animdata_freelist(&anim_data); | ANIM_animdata_freelist(&anim_data); | ||||
| /* refresh auto strip properties */ | /* refresh auto strip properties */ | ||||
| ED_nla_postop_refresh(&ac); | ED_nla_postop_refresh(&ac); | ||||
| /* set notifier that things have changed */ | /* set notifier that things have changed */ | ||||
| WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); | WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); | ||||
| WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ORDER, NULL); | |||||
| /* done */ | /* done */ | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| void NLA_OT_move_down(wmOperatorType *ot) | void NLA_OT_move_down(wmOperatorType *ot) | ||||
| { | { | ||||
| /* identifiers */ | /* identifiers */ | ||||
| ▲ Show 20 Lines • Show All 157 Lines • ▼ Show 20 Lines | static int nlaedit_make_single_user_exec(bContext *C, wmOperator *UNUSED(op)) | ||||
| ANIM_animdata_update(&ac, &anim_data); | ANIM_animdata_update(&ac, &anim_data); | ||||
| ANIM_animdata_freelist(&anim_data); | ANIM_animdata_freelist(&anim_data); | ||||
| if (copied) { | if (copied) { | ||||
| DEG_relations_tag_update(ac.bmain); | DEG_relations_tag_update(ac.bmain); | ||||
| } | } | ||||
| /* set notifier that things have changed */ | /* set notifier that things have changed */ | ||||
| WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); | WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_ADDED, NULL); | ||||
| /* done */ | /* done */ | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| void NLA_OT_make_single_user(wmOperatorType *ot) | void NLA_OT_make_single_user(wmOperatorType *ot) | ||||
| { | { | ||||
| /* identifiers */ | /* identifiers */ | ||||
| ▲ Show 20 Lines • Show All 222 Lines • ▼ Show 20 Lines | static int nlaedit_snap_exec(bContext *C, wmOperator *op) | ||||
| /* get a list of the editable tracks being shown in the NLA */ | /* get a list of the editable tracks being shown in the NLA */ | ||||
| filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); | filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); | ||||
| ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); | ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); | ||||
| /* get some necessary vars */ | /* get some necessary vars */ | ||||
| scene = ac.scene; | scene = ac.scene; | ||||
| secf = (float)FPS; | secf = (float)FPS; | ||||
| bool any_added = false; | |||||
| /* since we may add tracks, perform this in reverse order */ | /* since we may add tracks, perform this in reverse order */ | ||||
| for (ale = anim_data.last; ale; ale = ale->prev) { | for (ale = anim_data.last; ale; ale = ale->prev) { | ||||
| ListBase tmp_strips = {NULL, NULL}; | ListBase tmp_strips = {NULL, NULL}; | ||||
| AnimData *adt = ale->adt; | AnimData *adt = ale->adt; | ||||
| NlaTrack *nlt = (NlaTrack *)ale->data; | NlaTrack *nlt = (NlaTrack *)ale->data; | ||||
| NlaStrip *strip, *stripn; | NlaStrip *strip, *stripn; | ||||
| NlaTrack *track; | NlaTrack *track; | ||||
| ▲ Show 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | for (strip = tmp_strips.first; strip; strip = stripn) { | ||||
| if (BKE_nlatrack_add_strip(nlt, strip, is_liboverride) == 0) { | if (BKE_nlatrack_add_strip(nlt, strip, is_liboverride) == 0) { | ||||
| /* need to add a new track above the current one */ | /* need to add a new track above the current one */ | ||||
| track = BKE_nlatrack_add(adt, nlt, is_liboverride); | track = BKE_nlatrack_add(adt, nlt, is_liboverride); | ||||
| BKE_nlatrack_add_strip(track, strip, is_liboverride); | BKE_nlatrack_add_strip(track, strip, is_liboverride); | ||||
| /* clear temp meta-strips on this new track, | /* clear temp meta-strips on this new track, | ||||
| * as we may not be able to get back to it */ | * as we may not be able to get back to it */ | ||||
| BKE_nlastrips_clear_metas(&track->strips, 0, 1); | BKE_nlastrips_clear_metas(&track->strips, 0, 1); | ||||
| any_added = true; | |||||
Severin: Better don't do this in a loop, but at the end of the function. You can always send it, or use… | |||||
| } | } | ||||
| } | } | ||||
| /* remove the meta-strips now that we're done */ | /* remove the meta-strips now that we're done */ | ||||
| BKE_nlastrips_clear_metas(&nlt->strips, 0, 1); | BKE_nlastrips_clear_metas(&nlt->strips, 0, 1); | ||||
| /* tag for recalculating the animation */ | /* tag for recalculating the animation */ | ||||
| ale->update |= ANIM_UPDATE_DEPS; | ale->update |= ANIM_UPDATE_DEPS; | ||||
| } | } | ||||
| /* cleanup */ | /* cleanup */ | ||||
| ANIM_animdata_update(&ac, &anim_data); | ANIM_animdata_update(&ac, &anim_data); | ||||
| ANIM_animdata_freelist(&anim_data); | ANIM_animdata_freelist(&anim_data); | ||||
| /* refresh auto strip properties */ | /* refresh auto strip properties */ | ||||
| ED_nla_postop_refresh(&ac); | ED_nla_postop_refresh(&ac); | ||||
| /* set notifier that things have changed */ | /* set notifier that things have changed */ | ||||
| WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); | WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); | ||||
| if (any_added) { | |||||
| WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_ADDED, NULL); | |||||
| } | |||||
| /* done */ | /* done */ | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| void NLA_OT_snap(wmOperatorType *ot) | void NLA_OT_snap(wmOperatorType *ot) | ||||
| { | { | ||||
| /* identifiers */ | /* identifiers */ | ||||
| ▲ Show 20 Lines • Show All 333 Lines • Show Last 20 Lines | |||||
Better don't do this in a loop, but at the end of the function. You can always send it, or use a any_added boolean.