From 620b960d3d8cfd90b9f0df6ba3671c33eccb8309 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 22 Apr 2019 09:19:45 +1000 Subject: Cleanup: style, use braces for editors --- source/blender/editors/space_nla/nla_edit.c | 171 ++++++++++++++++++---------- 1 file changed, 114 insertions(+), 57 deletions(-) (limited to 'source/blender/editors/space_nla/nla_edit.c') diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c index 99c2b7aa99c..76930d3117b 100644 --- a/source/blender/editors/space_nla/nla_edit.c +++ b/source/blender/editors/space_nla/nla_edit.c @@ -113,8 +113,9 @@ static int nlaedit_enable_tweakmode_exec(bContext *C, wmOperator *op) bool ok = false; /* get editor data */ - if (ANIM_animdata_get_context(C, &ac) == 0) + if (ANIM_animdata_get_context(C, &ac) == 0) { return OPERATOR_CANCELLED; + } /* get a list of the AnimData blocks being shown in the NLA */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_ANIMDATA); @@ -257,17 +258,20 @@ static int nlaedit_disable_tweakmode_exec(bContext *C, wmOperator *op) bool ok = false; /* get editor data */ - if (ANIM_animdata_get_context(C, &ac) == 0) + if (ANIM_animdata_get_context(C, &ac) == 0) { return OPERATOR_CANCELLED; + } /* perform operation */ ok = nlaedit_disable_tweakmode(&ac, do_solo); /* success? */ - if (ok) + if (ok) { return OPERATOR_FINISHED; - else + } + else { return OPERATOR_CANCELLED; + } } void NLA_OT_tweakmode_exit(wmOperatorType *ot) @@ -362,13 +366,16 @@ static int nlaedit_previewrange_exec(bContext *C, wmOperator *UNUSED(op)) float min, max; /* get editor data */ - if (ANIM_animdata_get_context(C, &ac) == 0) + if (ANIM_animdata_get_context(C, &ac) == 0) { return OPERATOR_CANCELLED; + } - if (ac.scene == NULL) + if (ac.scene == NULL) { return OPERATOR_CANCELLED; - else + } + else { scene = ac.scene; + } /* set the range directly */ get_nlastrip_extents(&ac, &min, &max, true); @@ -464,8 +471,9 @@ static int nlaedit_viewall(bContext *C, const bool only_sel) float extra; /* get editor data */ - if (ANIM_animdata_get_context(C, &ac) == 0) + if (ANIM_animdata_get_context(C, &ac) == 0) { return OPERATOR_CANCELLED; + } v2d = &ac.ar->v2d; /* set the horizontal range, with an extra offset so that the extreme keys will be in view */ @@ -597,8 +605,9 @@ static int nlaedit_add_actionclip_exec(bContext *C, wmOperator *op) float cfra; /* get editor data */ - if (ANIM_animdata_get_context(C, &ac) == 0) + if (ANIM_animdata_get_context(C, &ac) == 0) { return OPERATOR_CANCELLED; + } scene = ac.scene; cfra = (float)CFRA; @@ -735,8 +744,9 @@ static int nlaedit_add_transition_exec(bContext *C, wmOperator *op) bool done = false; /* get editor data */ - if (ANIM_animdata_get_context(C, &ac) == 0) + if (ANIM_animdata_get_context(C, &ac) == 0) { return OPERATOR_CANCELLED; + } /* get a list of the editable tracks being shown in the NLA */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); @@ -749,8 +759,9 @@ static int nlaedit_add_transition_exec(bContext *C, wmOperator *op) NlaStrip *s1, *s2; /* get initial pair of strips */ - if (ELEM(nlt->strips.first, NULL, nlt->strips.last)) + if (ELEM(nlt->strips.first, NULL, nlt->strips.last)) { continue; + } s1 = nlt->strips.first; s2 = s1->next; @@ -759,20 +770,24 @@ static int nlaedit_add_transition_exec(bContext *C, wmOperator *op) NlaStrip *strip; /* check if both are selected */ - if (ELEM(0, (s1->flag & NLASTRIP_FLAG_SELECT), (s2->flag & NLASTRIP_FLAG_SELECT))) + if (ELEM(0, (s1->flag & NLASTRIP_FLAG_SELECT), (s2->flag & NLASTRIP_FLAG_SELECT))) { continue; + } /* check if there's space between the two */ - if (IS_EQF(s1->end, s2->start)) + if (IS_EQF(s1->end, s2->start)) { continue; + } /* make sure neither one is a transition * - although this is impossible to create with the standard tools, * the user may have altered the settings */ - if (ELEM(NLASTRIP_TYPE_TRANSITION, s1->type, s2->type)) + if (ELEM(NLASTRIP_TYPE_TRANSITION, s1->type, s2->type)) { continue; + } /* also make sure neither one is a soundclip */ - if (ELEM(NLASTRIP_TYPE_SOUND, s1->type, s2->type)) + if (ELEM(NLASTRIP_TYPE_SOUND, s1->type, s2->type)) { continue; + } /* allocate new strip */ strip = MEM_callocN(sizeof(NlaStrip), "NlaStrip"); @@ -856,8 +871,9 @@ static int nlaedit_add_sound_exec(bContext *C, wmOperator *UNUSED(op)) int cfra; /* get editor data */ - if (ANIM_animdata_get_context(C, &ac) == 0) + if (ANIM_animdata_get_context(C, &ac) == 0) { return OPERATOR_CANCELLED; + } scene = ac.scene; cfra = CFRA; @@ -877,8 +893,9 @@ static int nlaedit_add_sound_exec(bContext *C, wmOperator *UNUSED(op)) NlaStrip *strip; /* does this belong to speaker - assumed to live on Object level only */ - if ((GS(ale->id->name) != ID_OB) || (ob->type != OB_SPEAKER)) + if ((GS(ale->id->name) != ID_OB) || (ob->type != OB_SPEAKER)) { continue; + } /* create a new strip, and offset it to start on the current frame */ strip = BKE_nla_add_soundstrip(ac.scene, ob->data); @@ -940,8 +957,9 @@ static int nlaedit_add_meta_exec(bContext *C, wmOperator *UNUSED(op)) int filter; /* get editor data */ - if (ANIM_animdata_get_context(C, &ac) == 0) + if (ANIM_animdata_get_context(C, &ac) == 0) { return OPERATOR_CANCELLED; + } /* get a list of the editable tracks being shown in the NLA */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); @@ -959,8 +977,9 @@ static int nlaedit_add_meta_exec(bContext *C, wmOperator *UNUSED(op)) /* name the metas */ for (strip = nlt->strips.first; strip; strip = strip->next) { /* auto-name this strip if selected (that means it is a meta) */ - if (strip->flag & NLASTRIP_FLAG_SELECT) + if (strip->flag & NLASTRIP_FLAG_SELECT) { BKE_nlastrip_validate_name(adt, strip); + } } ale->update |= ANIM_UPDATE_DEPS; @@ -1004,8 +1023,9 @@ static int nlaedit_remove_meta_exec(bContext *C, wmOperator *UNUSED(op)) int filter; /* get editor data */ - if (ANIM_animdata_get_context(C, &ac) == 0) + if (ANIM_animdata_get_context(C, &ac) == 0) { return OPERATOR_CANCELLED; + } /* get a list of the editable tracks being shown in the NLA */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); @@ -1064,8 +1084,9 @@ static int nlaedit_duplicate_exec(bContext *C, wmOperator *op) bool done = false; /* get editor data */ - if (ANIM_animdata_get_context(C, &ac) == 0) + if (ANIM_animdata_get_context(C, &ac) == 0) { return OPERATOR_CANCELLED; + } /* get a list of editable tracks being shown in the NLA */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); @@ -1127,8 +1148,9 @@ static int nlaedit_duplicate_exec(bContext *C, wmOperator *op) /* done */ return OPERATOR_FINISHED; } - else + else { return OPERATOR_CANCELLED; + } } static int nlaedit_duplicate_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) @@ -1180,8 +1202,9 @@ static int nlaedit_delete_exec(bContext *C, wmOperator *UNUSED(op)) int filter; /* get editor data */ - if (ANIM_animdata_get_context(C, &ac) == 0) + if (ANIM_animdata_get_context(C, &ac) == 0) { return OPERATOR_CANCELLED; + } /* get a list of the editable tracks being shown in the NLA */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); @@ -1198,8 +1221,9 @@ static int nlaedit_delete_exec(bContext *C, wmOperator *UNUSED(op)) /* if selected, delete */ if (strip->flag & NLASTRIP_FLAG_SELECT) { /* if a strip either side of this was a transition, delete those too */ - if ((strip->prev) && (strip->prev->type == NLASTRIP_TYPE_TRANSITION)) + if ((strip->prev) && (strip->prev->type == NLASTRIP_TYPE_TRANSITION)) { BKE_nlastrip_free(&nlt->strips, strip->prev, true); + } if ((nstrip) && (nstrip->type == NLASTRIP_TYPE_TRANSITION)) { nstrip = nstrip->next; BKE_nlastrip_free(&nlt->strips, strip->next, true); @@ -1268,17 +1292,21 @@ static void nlaedit_split_strip_actclip( /* strip extents */ len = strip->end - strip->start; - if (IS_EQF(len, 0.0f)) + if (IS_EQF(len, 0.0f)) { return; - else + } + else { splitframe = strip->start + (len / 2.0f); + } /* action range */ len = strip->actend - strip->actstart; - if (IS_EQF(len, 0.0f)) + if (IS_EQF(len, 0.0f)) { splitaframe = strip->actend; - else + } + else { splitaframe = strip->actstart + (len / 2.0f); + } } /* make a copy (assume that this is possible) and append @@ -1324,8 +1352,9 @@ static int nlaedit_split_exec(bContext *C, wmOperator *UNUSED(op)) int filter; /* get editor data */ - if (ANIM_animdata_get_context(C, &ac) == 0) + if (ANIM_animdata_get_context(C, &ac) == 0) { return OPERATOR_CANCELLED; + } /* get a list of editable tracks being shown in the NLA */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); @@ -1402,8 +1431,9 @@ static int nlaedit_toggle_mute_exec(bContext *C, wmOperator *UNUSED(op)) int filter; /* get editor data */ - if (ANIM_animdata_get_context(C, &ac) == 0) + if (ANIM_animdata_get_context(C, &ac) == 0) { return OPERATOR_CANCELLED; + } /* get a list of the editable tracks being shown in the NLA */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); @@ -1465,8 +1495,9 @@ static int nlaedit_swap_exec(bContext *C, wmOperator *op) int filter; /* get editor data */ - if (ANIM_animdata_get_context(C, &ac) == 0) + if (ANIM_animdata_get_context(C, &ac) == 0) { return OPERATOR_CANCELLED; + } /* get a list of the editable tracks being shown in the NLA */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); @@ -1634,8 +1665,9 @@ static int nlaedit_move_up_exec(bContext *C, wmOperator *UNUSED(op)) int filter; /* get editor data */ - if (ANIM_animdata_get_context(C, &ac) == 0) + if (ANIM_animdata_get_context(C, &ac) == 0) { return OPERATOR_CANCELLED; + } /* get a list of the editable tracks being shown in the NLA */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); @@ -1650,8 +1682,9 @@ static int nlaedit_move_up_exec(bContext *C, wmOperator *UNUSED(op)) NlaStrip *strip, *stripn; /* if this track has no tracks after it, skip for now... */ - if (nltn == NULL) + if (nltn == NULL) { continue; + } /* for every selected strip, try to move */ for (strip = nlt->strips.first; strip; strip = stripn) { @@ -1709,8 +1742,9 @@ static int nlaedit_move_down_exec(bContext *C, wmOperator *UNUSED(op)) int filter; /* get editor data */ - if (ANIM_animdata_get_context(C, &ac) == 0) + if (ANIM_animdata_get_context(C, &ac) == 0) { return OPERATOR_CANCELLED; + } /* get a list of the editable tracks being shown in the NLA */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); @@ -1725,8 +1759,9 @@ static int nlaedit_move_down_exec(bContext *C, wmOperator *UNUSED(op)) NlaStrip *strip, *stripn; /* if this track has no tracks before it, skip for now... */ - if (nltp == NULL) + if (nltp == NULL) { continue; + } /* for every selected strip, try to move */ for (strip = nlt->strips.first; strip; strip = stripn) { @@ -1785,13 +1820,15 @@ static int nlaedit_sync_actlen_exec(bContext *C, wmOperator *op) const bool active_only = RNA_boolean_get(op->ptr, "active"); /* get editor data */ - if (ANIM_animdata_get_context(C, &ac) == 0) + if (ANIM_animdata_get_context(C, &ac) == 0) { return OPERATOR_CANCELLED; + } /* get a list of the editable tracks being shown in the NLA */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); - if (active_only) + if (active_only) { filter |= ANIMFILTER_ACTIVE; + } ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* for each NLA-Track, apply scale of all selected strips */ @@ -1802,18 +1839,21 @@ static int nlaedit_sync_actlen_exec(bContext *C, wmOperator *op) for (strip = nlt->strips.first; strip; strip = strip->next) { /* strip selection/active status check */ if (active_only) { - if ((strip->flag & NLASTRIP_FLAG_ACTIVE) == 0) + if ((strip->flag & NLASTRIP_FLAG_ACTIVE) == 0) { continue; + } } else { - if ((strip->flag & NLASTRIP_FLAG_SELECT) == 0) + if ((strip->flag & NLASTRIP_FLAG_SELECT) == 0) { continue; + } } /* must be action-clip only (transitions don't have scale) */ if (strip->type == NLASTRIP_TYPE_CLIP) { - if (strip->act == NULL) + if (strip->act == NULL) { continue; + } /* recalculate the length of the action */ calc_action_range(strip->act, &strip->actstart, &strip->actend, 0); @@ -1874,8 +1914,9 @@ static int nlaedit_make_single_user_exec(bContext *C, wmOperator *UNUSED(op)) bool copied = false; /* get editor data */ - if (ANIM_animdata_get_context(C, &ac) == 0) + if (ANIM_animdata_get_context(C, &ac) == 0) { return OPERATOR_CANCELLED; + } /* get a list of the editable tracks being shown in the NLA */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); @@ -1892,8 +1933,9 @@ static int nlaedit_make_single_user_exec(bContext *C, wmOperator *UNUSED(op)) for (strip = nlt->strips.last; strip; strip = strip->prev) { /* must be action-clip only (as only these have actions) */ if ((strip->flag & NLASTRIP_FLAG_SELECT) && (strip->type == NLASTRIP_TYPE_CLIP)) { - if (strip->act == NULL) + if (strip->act == NULL) { continue; + } /* multi-user? */ if (ID_REAL_USERS(strip->act) > 1) { @@ -1975,8 +2017,9 @@ static int nlaedit_apply_scale_exec(bContext *C, wmOperator *UNUSED(op)) KeyframeEditData ked = {{NULL}}; /* get editor data */ - if (ANIM_animdata_get_context(C, &ac) == 0) + if (ANIM_animdata_get_context(C, &ac) == 0) { return OPERATOR_CANCELLED; + } /* get a list of the editable tracks being shown in the NLA */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); @@ -1993,8 +2036,9 @@ static int nlaedit_apply_scale_exec(bContext *C, wmOperator *UNUSED(op)) if ((strip->flag & NLASTRIP_FLAG_SELECT) && (strip->type == NLASTRIP_TYPE_CLIP)) { /* if the referenced action is used by other strips, * make this strip use its own copy */ - if (strip->act == NULL) + if (strip->act == NULL) { continue; + } if (strip->act->id.us > 1) { /* make a copy of the Action to work on */ bAction *act = BKE_action_copy(bmain, strip->act); @@ -2067,8 +2111,9 @@ static int nlaedit_clear_scale_exec(bContext *C, wmOperator *UNUSED(op)) int filter; /* get editor data */ - if (ANIM_animdata_get_context(C, &ac) == 0) + if (ANIM_animdata_get_context(C, &ac) == 0) { return OPERATOR_CANCELLED; + } /* get a list of the editable tracks being shown in the NLA */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); @@ -2145,8 +2190,9 @@ static int nlaedit_snap_exec(bContext *C, wmOperator *op) float secf; /* get editor data */ - if (ANIM_animdata_get_context(C, &ac) == 0) + if (ANIM_animdata_get_context(C, &ac) == 0) { return OPERATOR_CANCELLED; + } /* get a list of the editable tracks being shown in the NLA */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); @@ -2294,10 +2340,12 @@ static const EnumPropertyItem *nla_fmodifier_itemf(bContext *C, int index; /* check if modifier is valid for this context */ - if (fmi == NULL) + if (fmi == NULL) { continue; - if (i == FMODIFIER_TYPE_CYCLES) /* we already have repeat... */ + } + if (i == FMODIFIER_TYPE_CYCLES) { /* we already have repeat... */ continue; + } index = RNA_enum_from_value(rna_enum_fmodifier_type_items, fmi->type); if (index != -1) { /* Not all types are implemented yet... */ @@ -2324,8 +2372,9 @@ static int nla_fmodifier_add_exec(bContext *C, wmOperator *op) const bool active_only = RNA_boolean_get(op->ptr, "only_active"); /* get editor data */ - if (ANIM_animdata_get_context(C, &ac) == 0) + if (ANIM_animdata_get_context(C, &ac) == 0) { return OPERATOR_CANCELLED; + } /* get a list of the editable tracks being shown in the NLA */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); @@ -2340,18 +2389,21 @@ static int nla_fmodifier_add_exec(bContext *C, wmOperator *op) /* can F-Modifier be added to the current strip? */ if (active_only) { /* if not active, cannot add since we're only adding to active strip */ - if ((strip->flag & NLASTRIP_FLAG_ACTIVE) == 0) + if ((strip->flag & NLASTRIP_FLAG_ACTIVE) == 0) { continue; + } } else { /* strip must be selected, since we're not just doing active */ - if ((strip->flag & NLASTRIP_FLAG_SELECT) == 0) + if ((strip->flag & NLASTRIP_FLAG_SELECT) == 0) { continue; + } } /* sound clips are not affected by FModifiers */ - if (strip->type == NLASTRIP_TYPE_SOUND) + if (strip->type == NLASTRIP_TYPE_SOUND) { continue; + } /* add F-Modifier of specified type to selected, and make it the active one */ fcm = add_fmodifier(&strip->modifiers, type, NULL); @@ -2418,8 +2470,9 @@ static int nla_fmodifier_copy_exec(bContext *C, wmOperator *op) bool ok = false; /* get editor data */ - if (ANIM_animdata_get_context(C, &ac) == 0) + if (ANIM_animdata_get_context(C, &ac) == 0) { return OPERATOR_CANCELLED; + } /* clear buffer first */ ANIM_fmodifiers_copybuf_free(); @@ -2435,8 +2488,9 @@ static int nla_fmodifier_copy_exec(bContext *C, wmOperator *op) for (strip = nlt->strips.first; strip; strip = strip->next) { /* only add F-Modifier if on active strip? */ - if ((strip->flag & NLASTRIP_FLAG_ACTIVE) == 0) + if ((strip->flag & NLASTRIP_FLAG_ACTIVE) == 0) { continue; + } // TODO: when 'active' vs 'all' boolean is added, change last param! ok |= ANIM_fmodifiers_copy_to_buf(&strip->modifiers, 0); @@ -2494,8 +2548,9 @@ static int nla_fmodifier_paste_exec(bContext *C, wmOperator *op) const bool replace = RNA_boolean_get(op->ptr, "replace"); /* get editor data */ - if (ANIM_animdata_get_context(C, &ac) == 0) + if (ANIM_animdata_get_context(C, &ac) == 0) { return OPERATOR_CANCELLED; + } /* get a list of the editable tracks being shown in the NLA */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT | @@ -2511,13 +2566,15 @@ static int nla_fmodifier_paste_exec(bContext *C, wmOperator *op) /* can F-Modifier be added to the current strip? */ if (active_only) { /* if not active, cannot add since we're only adding to active strip */ - if ((strip->flag & NLASTRIP_FLAG_ACTIVE) == 0) + if ((strip->flag & NLASTRIP_FLAG_ACTIVE) == 0) { continue; + } } else { /* strip must be selected, since we're not just doing active */ - if ((strip->flag & NLASTRIP_FLAG_SELECT) == 0) + if ((strip->flag & NLASTRIP_FLAG_SELECT) == 0) { continue; + } } /* paste FModifiers from buffer */ -- cgit v1.2.3