diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-04-22 02:19:45 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-04-22 12:48:16 +0300 |
commit | 620b960d3d8cfd90b9f0df6ba3671c33eccb8309 (patch) | |
tree | 64f69db4bf9d44f0a32d1c92b0714bf2dc98ff2d /source/blender/editors/space_graph/graph_select.c | |
parent | bba60bb564cf5a16cfcac744d4ba82cf8eba3da9 (diff) |
Cleanup: style, use braces for editors
Diffstat (limited to 'source/blender/editors/space_graph/graph_select.c')
-rw-r--r-- | source/blender/editors/space_graph/graph_select.c | 162 |
1 files changed, 108 insertions, 54 deletions
diff --git a/source/blender/editors/space_graph/graph_select.c b/source/blender/editors/space_graph/graph_select.c index 05d0ba38461..a5376cd0c0e 100644 --- a/source/blender/editors/space_graph/graph_select.c +++ b/source/blender/editors/space_graph/graph_select.c @@ -122,10 +122,12 @@ void deselect_graph_keys(bAnimContext *ac, bool test, short sel, bool do_channel /* deactivate the F-Curve, and deselect if deselecting keyframes. * otherwise select the F-Curve too since we've selected all the keyframes */ - if (sel == SELECT_SUBTRACT) + if (sel == SELECT_SUBTRACT) { fcu->flag &= ~FCURVE_SELECTED; - else + } + else { fcu->flag |= FCURVE_SELECTED; + } } /* always deactivate all F-Curves if we perform batch ops for selection */ @@ -145,8 +147,9 @@ static int graphkeys_deselectall_exec(bContext *C, wmOperator *op) bAnimListElem *ale_active = NULL; /* get editor data */ - if (ANIM_animdata_get_context(C, &ac) == 0) + if (ANIM_animdata_get_context(C, &ac) == 0) { return OPERATOR_CANCELLED; + } /* find active F-Curve, and preserve this for later * or else it becomes annoying with the current active @@ -277,8 +280,9 @@ static void box_select_graphkeys(bAnimContext *ac, ked.iterflags |= KEYFRAME_ITER_INCL_HANDLES; mapping_flag = 0; } - else + else { mapping_flag = ANIM_UNITCONV_ONLYKEYS; + } mapping_flag |= ANIM_get_normalization_flags(ac); @@ -293,8 +297,9 @@ static void box_select_graphkeys(bAnimContext *ac, /* apply NLA mapping to all the keyframes, since it's easier than trying to * guess when a callback might use something different */ - if (adt) + if (adt) { ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, incl_handles == 0); + } scaled_rectf.xmin = rectf.xmin; scaled_rectf.xmax = rectf.xmax; @@ -322,14 +327,16 @@ static void box_select_graphkeys(bAnimContext *ac, /* only change selection of channel when the visibility of keyframes doesn't depend on this */ if ((sipo->flag & SIPO_SELCUVERTSONLY) == 0) { /* select the curve too now that curve will be touched */ - if (selectmode == SELECT_ADD) + if (selectmode == SELECT_ADD) { fcu->flag |= FCURVE_SELECTED; + } } } /* un-apply NLA mapping from all the keyframes */ - if (adt) + if (adt) { ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, incl_handles == 0); + } } /* cleanup */ @@ -346,8 +353,9 @@ static int graphkeys_box_select_exec(bContext *C, wmOperator *op) short mode = 0; /* get editor data */ - if (ANIM_animdata_get_context(C, &ac) == 0) + if (ANIM_animdata_get_context(C, &ac) == 0) { return OPERATOR_CANCELLED; + } const eSelectOp sel_op = RNA_enum_get(op->ptr, "mode"); const int selectmode = (sel_op != SEL_OP_SUB) ? SELECT_ADD : SELECT_SUBTRACT; @@ -370,13 +378,16 @@ static int graphkeys_box_select_exec(bContext *C, wmOperator *op) * as frame-range one is often used for tweaking timing when "blocking", * while channels is not that useful. */ - if ((BLI_rcti_size_x(&rect)) >= (BLI_rcti_size_y(&rect))) + if ((BLI_rcti_size_x(&rect)) >= (BLI_rcti_size_y(&rect))) { mode = BEZT_OK_FRAMERANGE; - else + } + else { mode = BEZT_OK_VALUERANGE; + } } - else + else { mode = BEZT_OK_REGION; + } BLI_rctf_rcti_copy(&rect_fl, &rect); @@ -432,13 +443,15 @@ static int graphkeys_lassoselect_exec(bContext *C, wmOperator *op) bool incl_handles; /* get editor data */ - if (ANIM_animdata_get_context(C, &ac) == 0) + if (ANIM_animdata_get_context(C, &ac) == 0) { return OPERATOR_CANCELLED; + } data_lasso.rectf_view = &rect_fl; data_lasso.mcords = WM_gesture_lasso_path_to_array(C, op, &data_lasso.mcords_tot); - if (data_lasso.mcords == NULL) + if (data_lasso.mcords == NULL) { return OPERATOR_CANCELLED; + } const eSelectOp sel_op = RNA_enum_get(op->ptr, "mode"); const short selectmode = (sel_op != SEL_OP_SUB) ? SELECT_ADD : SELECT_SUBTRACT; @@ -508,8 +521,9 @@ static int graph_circle_select_exec(bContext *C, wmOperator *op) float radius = RNA_int_get(op->ptr, "radius"); /* get editor data */ - if (ANIM_animdata_get_context(C, &ac) == 0) + if (ANIM_animdata_get_context(C, &ac) == 0) { return OPERATOR_CANCELLED; + } const eSelectOp sel_op = ED_select_op_modal(RNA_enum_get(op->ptr, "mode"), WM_gesture_is_modal_first(op->customdata)); @@ -658,8 +672,9 @@ static void columnselect_graph_keys(bAnimContext *ac, short mode) filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - for (ale = anim_data.first; ale; ale = ale->next) + for (ale = anim_data.first; ale; ale = ale->next) { ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, bezt_to_cfraelem, NULL); + } ANIM_animdata_freelist(&anim_data); break; @@ -718,16 +733,19 @@ static int graphkeys_columnselect_exec(bContext *C, wmOperator *op) short mode; /* get editor data */ - if (ANIM_animdata_get_context(C, &ac) == 0) + if (ANIM_animdata_get_context(C, &ac) == 0) { return OPERATOR_CANCELLED; + } /* action to take depends on the mode */ mode = RNA_enum_get(op->ptr, "mode"); - if (mode == GRAPHKEYS_COLUMNSEL_MARKERS_BETWEEN) + if (mode == GRAPHKEYS_COLUMNSEL_MARKERS_BETWEEN) { markers_selectkeys_between(&ac); - else + } + else { columnselect_graph_keys(&ac, mode); + } /* set notifier that keyframe selection has changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); @@ -767,8 +785,9 @@ static int graphkeys_select_linked_exec(bContext *C, wmOperator *UNUSED(op)) KeyframeEditFunc sel_cb = ANIM_editkeyframes_select(SELECT_ADD); /* get editor data */ - if (ANIM_animdata_get_context(C, &ac) == 0) + if (ANIM_animdata_get_context(C, &ac) == 0) { return OPERATOR_CANCELLED; + } /* loop through all of the keys and select additional keyframes based on these */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); @@ -832,8 +851,9 @@ static void select_moreless_graph_keys(bAnimContext *ac, short mode) FCurve *fcu = (FCurve *)ale->key_data; /* only continue if F-Curve has keyframes */ - if (fcu->bezt == NULL) + if (fcu->bezt == NULL) { continue; + } /* build up map of whether F-Curve's keyframes should be selected or not */ ked.data = MEM_callocN(fcu->totvert, "selmap graphEdit"); @@ -858,8 +878,9 @@ static int graphkeys_select_more_exec(bContext *C, wmOperator *UNUSED(op)) bAnimContext ac; /* get editor data */ - if (ANIM_animdata_get_context(C, &ac) == 0) + if (ANIM_animdata_get_context(C, &ac) == 0) { return OPERATOR_CANCELLED; + } /* perform select changes */ select_moreless_graph_keys(&ac, SELMAP_MORE); @@ -892,8 +913,9 @@ static int graphkeys_select_less_exec(bContext *C, wmOperator *UNUSED(op)) bAnimContext ac; /* get editor data */ - if (ANIM_animdata_get_context(C, &ac) == 0) + if (ANIM_animdata_get_context(C, &ac) == 0) { return OPERATOR_CANCELLED; + } /* perform select changes */ select_moreless_graph_keys(&ac, SELMAP_LESS); @@ -978,8 +1000,9 @@ static void graphkeys_select_leftright(bAnimContext *ac, short leftright, short ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL); ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1); } - else + else { ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL); + } } /* Cleanup */ @@ -995,18 +1018,22 @@ static int graphkeys_select_leftright_exec(bContext *C, wmOperator *op) short selectmode; /* get editor data */ - if (ANIM_animdata_get_context(C, &ac) == 0) + if (ANIM_animdata_get_context(C, &ac) == 0) { return OPERATOR_CANCELLED; + } /* select mode is either replace (deselect all, then add) or add/extend */ - if (RNA_boolean_get(op->ptr, "extend")) + if (RNA_boolean_get(op->ptr, "extend")) { selectmode = SELECT_INVERT; - else + } + else { selectmode = SELECT_REPLACE; + } /* if "test" mode is set, we don't have any info to set this with */ - if (leftright == GRAPHKEYS_LRSEL_TEST) + if (leftright == GRAPHKEYS_LRSEL_TEST) { return OPERATOR_CANCELLED; + } /* do the selecting now */ graphkeys_select_leftright(&ac, leftright, selectmode); @@ -1024,8 +1051,9 @@ static int graphkeys_select_leftright_invoke(bContext *C, wmOperator *op, const short leftright = RNA_enum_get(op->ptr, "mode"); /* get editor data */ - if (ANIM_animdata_get_context(C, &ac) == 0) + if (ANIM_animdata_get_context(C, &ac) == 0) { return OPERATOR_CANCELLED; + } /* handle mode-based testing */ if (leftright == GRAPHKEYS_LRSEL_TEST) { @@ -1036,10 +1064,12 @@ static int graphkeys_select_leftright_invoke(bContext *C, wmOperator *op, const /* determine which side of the current frame mouse is on */ x = UI_view2d_region_to_view_x(v2d, event->mval[0]); - if (x < CFRA) + if (x < CFRA) { RNA_enum_set(op->ptr, "mode", GRAPHKEYS_LRSEL_LEFT); - else + } + else { RNA_enum_set(op->ptr, "mode", GRAPHKEYS_LRSEL_RIGHT); + } } /* perform selection */ @@ -1117,10 +1147,12 @@ typedef enum eGraphVertIndex { // XXX also need to check for int-values only? static bool fcurve_handle_sel_check(SpaceGraph *sipo, BezTriple *bezt) { - if (sipo->flag & SIPO_NOHANDLES) + if (sipo->flag & SIPO_NOHANDLES) { return 0; - if ((sipo->flag & SIPO_SELVHANDLESONLY) && BEZT_ISSEL_ANY(bezt) == 0) + } + if ((sipo->flag & SIPO_SELVHANDLESONLY) && BEZT_ISSEL_ANY(bezt) == 0) { return 0; + } return 1; } @@ -1159,12 +1191,14 @@ static void nearest_fcurve_vert_store(ListBase *matches, /* if there is already a point for the F-Curve, check if this point is closer than that was */ if ((nvi) && (nvi->fcu == fcu)) { /* replace if we are closer, or if equal and that one wasn't selected but we are... */ - if ((nvi->dist > dist) || ((nvi->sel == 0) && BEZT_ISSEL_ANY(bezt))) + if ((nvi->dist > dist) || ((nvi->sel == 0) && BEZT_ISSEL_ANY(bezt))) { replace = 1; + } } /* add new if not replacing... */ - if (replace == 0) + if (replace == 0) { nvi = MEM_callocN(sizeof(tNearestVertInfo), "Nearest Graph Vert Info - Bezt"); + } /* store values */ nvi->fcu = fcu; @@ -1179,8 +1213,9 @@ static void nearest_fcurve_vert_store(ListBase *matches, nvi->sel = BEZT_ISSEL_ANY(bezt); // XXX... should this use the individual verts instead? /* add to list of matches if appropriate... */ - if (replace == 0) + if (replace == 0) { BLI_addtail(matches, nvi); + } } } else if (fpt) { @@ -1205,8 +1240,9 @@ static void get_nearest_fcurve_verts_list(bAnimContext *ac, const int mval[2], L */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); if (sipo->flag & - SIPO_SELCUVERTSONLY) // FIXME: this should really be check for by the filtering code... + SIPO_SELCUVERTSONLY) { // FIXME: this should really be check for by the filtering code... filter |= ANIMFILTER_SEL; + } mapping_flag |= ANIM_get_normalization_flags(ac); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); @@ -1218,8 +1254,9 @@ static void get_nearest_fcurve_verts_list(bAnimContext *ac, const int mval[2], L ac->scene, ale->id, fcu, mapping_flag, &offset); /* apply NLA mapping to all the keyframes */ - if (adt) + if (adt) { ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 0); + } if (fcu->bezt) { BezTriple *bezt1 = fcu->bezt, *prevbezt = NULL; @@ -1276,8 +1313,9 @@ static void get_nearest_fcurve_verts_list(bAnimContext *ac, const int mval[2], L } /* un-apply NLA mapping from all the keyframes */ - if (adt) + if (adt) { ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 0); + } } /* free channels */ @@ -1291,8 +1329,9 @@ static tNearestVertInfo *get_best_nearest_fcurve_vert(ListBase *matches) short found = 0; /* abort if list is empty */ - if (BLI_listbase_is_empty(matches)) + if (BLI_listbase_is_empty(matches)) { return NULL; + } /* if list only has 1 item, remove it from the list and return */ if (BLI_listbase_is_single(matches)) { @@ -1312,8 +1351,9 @@ static tNearestVertInfo *get_best_nearest_fcurve_vert(ListBase *matches) } else { /* if vert is selected, we've got what we want... */ - if (nvi->sel) + if (nvi->sel) { found = 1; + } } } @@ -1362,8 +1402,9 @@ static void mouse_graph_keys(bAnimContext *ac, nvi = find_nearest_fcurve_vert(ac, mval); /* check if anything to select */ - if (nvi == NULL) + if (nvi == NULL) { return; + } /* deselect all other curves? */ if (select_mode == SELECT_REPLACE) { @@ -1377,8 +1418,9 @@ static void mouse_graph_keys(bAnimContext *ac, * selection of channel when the visibility of keyframes * doesn't depend on this */ - if ((sipo->flag & SIPO_SELCUVERTSONLY) == 0) + if ((sipo->flag & SIPO_SELCUVERTSONLY) == 0) { ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR); + } } /* if points can be selected on this F-Curve */ @@ -1415,10 +1457,12 @@ static void mouse_graph_keys(bAnimContext *ac, BEZT_SEL_ALL(bezt); } /* otherwise, select the handle that applied */ - else if (nvi->hpoint == NEAREST_HANDLE_LEFT) + else if (nvi->hpoint == NEAREST_HANDLE_LEFT) { bezt->f1 |= SELECT; - else + } + else { bezt->f3 |= SELECT; + } } } else if (nvi->fpt) { @@ -1446,18 +1490,22 @@ static void mouse_graph_keys(bAnimContext *ac, /* take selection status from item that got hit, to prevent flip/flop on channel * selection status when shift-selecting (i.e. "SELECT_INVERT") points */ - if (BEZT_ISSEL_ANY(bezt)) + if (BEZT_ISSEL_ANY(bezt)) { nvi->fcu->flag |= FCURVE_SELECTED; - else + } + else { nvi->fcu->flag &= ~FCURVE_SELECTED; + } } else { /* Didn't hit any channel, * so just apply that selection mode to the curve's selection status. */ - if (select_mode == SELECT_INVERT) + if (select_mode == SELECT_INVERT) { nvi->fcu->flag ^= FCURVE_SELECTED; - else if (select_mode == SELECT_ADD) + } + else if (select_mode == SELECT_ADD) { nvi->fcu->flag |= FCURVE_SELECTED; + } } } @@ -1493,8 +1541,9 @@ static void graphkeys_mselect_column(bAnimContext *ac, const int mval[2], short nvi = find_nearest_fcurve_vert(ac, mval); /* check if anything to select */ - if (nvi == NULL) + if (nvi == NULL) { return; + } /* get frame number on which elements should be selected */ // TODO: should we restrict to integer frames only? @@ -1528,10 +1577,12 @@ static void graphkeys_mselect_column(bAnimContext *ac, const int mval[2], short AnimData *adt = ANIM_nla_mapping_get(ac, ale); /* set frame for validation callback to refer to */ - if (adt) + if (adt) { ked.f1 = BKE_nla_tweakedit_remap(adt, selx, NLATIME_CONVERT_UNMAP); - else + } + else { ked.f1 = selx; + } /* select elements with frame number matching cfra */ ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL); @@ -1552,14 +1603,17 @@ static int graphkeys_clickselect_invoke(bContext *C, wmOperator *op, const wmEve short selectmode; /* get editor data */ - if (ANIM_animdata_get_context(C, &ac) == 0) + if (ANIM_animdata_get_context(C, &ac) == 0) { return OPERATOR_CANCELLED; + } /* select mode is either replace (deselect all, then add) or add/extend */ - if (RNA_boolean_get(op->ptr, "extend")) + if (RNA_boolean_get(op->ptr, "extend")) { selectmode = SELECT_INVERT; - else + } + else { selectmode = SELECT_REPLACE; + } /* figure out action to take */ if (RNA_boolean_get(op->ptr, "column")) { |