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_graph/graph_buttons.c | 54 +++-- source/blender/editors/space_graph/graph_draw.c | 45 ++-- source/blender/editors/space_graph/graph_edit.c | 258 ++++++++++++++------- source/blender/editors/space_graph/graph_ops.c | 36 ++- source/blender/editors/space_graph/graph_select.c | 162 ++++++++----- source/blender/editors/space_graph/graph_utils.c | 42 ++-- source/blender/editors/space_graph/space_graph.c | 27 ++- 7 files changed, 416 insertions(+), 208 deletions(-) (limited to 'source/blender/editors/space_graph') diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c index f8f75234852..3b1e70b8db7 100644 --- a/source/blender/editors/space_graph/graph_buttons.c +++ b/source/blender/editors/space_graph/graph_buttons.c @@ -81,20 +81,25 @@ static int graph_panel_context(const bContext *C, bAnimListElem **ale, FCurve ** * to work correctly is able to be correctly retrieved. * There's no point showing empty panels? */ - if (ANIM_animdata_get_context(C, &ac) == 0) + if (ANIM_animdata_get_context(C, &ac) == 0) { return 0; + } /* try to find 'active' F-Curve */ elem = get_active_fcurve_channel(&ac); - if (elem == NULL) + if (elem == NULL) { return 0; + } - if (fcu) + if (fcu) { *fcu = (FCurve *)elem->data; - if (ale) + } + if (ale) { *ale = elem; - else + } + else { MEM_freeN(elem); + } return 1; } @@ -130,10 +135,12 @@ static void graph_panel_view(const bContext *C, Panel *pa) sub = uiLayoutColumn(col, true); uiLayoutSetActive(sub, RNA_boolean_get(&spaceptr, "show_cursor")); row = uiLayoutSplit(sub, 0.7f, true); - if (sipo->mode == SIPO_MODE_DRIVERS) + if (sipo->mode == SIPO_MODE_DRIVERS) { uiItemR(row, &spaceptr, "cursor_position_x", 0, IFACE_("Cursor X"), ICON_NONE); - else + } + else { uiItemR(row, &sceneptr, "frame_current", 0, IFACE_("Cursor X"), ICON_NONE); + } uiItemEnumO(row, "GRAPH_OT_snap", IFACE_("To Keys"), 0, "type", GRAPHKEYS_SNAP_CFRA); row = uiLayoutSplit(sub, 0.7f, true); @@ -153,8 +160,9 @@ static void graph_panel_properties(const bContext *C, Panel *pa) char name[256]; int icon = 0; - if (!graph_panel_context(C, &ale, &fcu)) + if (!graph_panel_context(C, &ale, &fcu)) { return; + } /* F-Curve pointer */ RNA_pointer_create(ale->id, &RNA_FCurve, fcu, &fcu_ptr); @@ -179,8 +187,9 @@ static void graph_panel_properties(const bContext *C, Panel *pa) } /* icon */ - if (ale->type == ANIMTYPE_NLACURVE) + if (ale->type == ANIMTYPE_NLACURVE) { icon = ICON_NLA; + } } uiItemL(col, name, icon); @@ -221,8 +230,9 @@ static short get_active_fcurve_keyframe_edit(FCurve *fcu, BezTriple **bezt, BezT *bezt = *prevbezt = NULL; /* sanity checks */ - if ((fcu->bezt == NULL) || (fcu->totvert == 0)) + if ((fcu->bezt == NULL) || (fcu->totvert == 0)) { return 0; + } /* find first selected keyframe for now, and call it the active one * - this is a reasonable assumption, given that whenever anyone @@ -332,8 +342,9 @@ static void graph_panel_key_properties(const bContext *C, Panel *pa) uiLayout *col; uiBlock *block; - if (!graph_panel_context(C, &ale, &fcu)) + if (!graph_panel_context(C, &ale, &fcu)) { return; + } block = uiLayoutGetBlock(layout); /* UI_block_func_handle_set(block, do_graph_region_buttons, NULL); */ @@ -367,8 +378,9 @@ static void graph_panel_key_properties(const bContext *C, Panel *pa) } /* easing type */ - if (bezt->ipo > BEZT_IPO_BEZ) + if (bezt->ipo > BEZT_IPO_BEZ) { uiItemR(col, &bezt_ptr, "easing", 0, NULL, 0); + } /* easing extra */ switch (bezt->ipo) { @@ -567,8 +579,9 @@ static void graph_panel_key_properties(const bContext *C, Panel *pa) IFACE_("F-Curve doesn't have any keyframes as it only contains sampled points"), ICON_NONE); } - else + else { uiItemL(layout, IFACE_("No active keyframe on F-Curve"), ICON_NONE); + } } MEM_freeN(ale); @@ -695,8 +708,9 @@ static bool graph_panel_drivers_poll(const bContext *C, PanelType *UNUSED(pt)) { SpaceGraph *sipo = CTX_wm_space_graph(C); - if (sipo->mode != SIPO_MODE_DRIVERS) + if (sipo->mode != SIPO_MODE_DRIVERS) { return 0; + } return graph_panel_context(C, NULL, NULL); } @@ -969,8 +983,9 @@ static void graph_draw_driver_settings_panel(uiLayout *layout, col = uiLayoutColumn(layout, true); block = uiLayoutGetBlock(col); - if (driver->flag & DRIVER_FLAG_INVALID) + if (driver->flag & DRIVER_FLAG_INVALID) { uiItemL(col, IFACE_("ERROR: Invalid target channel(s)"), ICON_ERROR); + } /* Warnings about a lack of variables * NOTE: The lack of variables is generally a bad thing, since it indicates @@ -1201,8 +1216,9 @@ static void graph_panel_driven_property(const bContext *C, Panel *pa) bAnimListElem *ale; FCurve *fcu; - if (!graph_panel_context(C, &ale, &fcu)) + if (!graph_panel_context(C, &ale, &fcu)) { return; + } graph_draw_driven_property_panel(pa->layout, ale->id, fcu); @@ -1217,8 +1233,9 @@ static void graph_panel_drivers(const bContext *C, Panel *pa) FCurve *fcu; /* Get settings from context */ - if (!graph_panel_context(C, &ale, &fcu)) + if (!graph_panel_context(C, &ale, &fcu)) { return; + } graph_draw_driver_settings_panel(pa->layout, ale->id, fcu, false); @@ -1306,8 +1323,9 @@ static void graph_panel_modifiers(const bContext *C, Panel *pa) uiBlock *block; bool active; - if (!graph_panel_context(C, &ale, &fcu)) + if (!graph_panel_context(C, &ale, &fcu)) { return; + } block = uiLayoutGetBlock(pa->layout); UI_block_func_handle_set(block, do_graph_region_modifier_buttons, NULL); diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c index 3c41b076738..eb392538d23 100644 --- a/source/blender/editors/space_graph/graph_draw.c +++ b/source/blender/editors/space_graph/graph_draw.c @@ -185,8 +185,9 @@ static void draw_fcurve_selected_keyframe_vertices( * - only draw those with correct selection state for the current drawing color * - */ - if ((bezt->f2 & SELECT) == sel) + if ((bezt->f2 & SELECT) == sel) { immVertex2fv(pos, bezt->vec[1]); + } } else { /* no check for selection here, as curve is not editable... */ @@ -360,8 +361,9 @@ static void draw_fcurve_handles(SpaceGraph *sipo, FCurve *fcu) * check that keyframe is selected */ if (sipo->flag & SIPO_SELVHANDLESONLY) { - if (BEZT_ISSEL_ANY(bezt) == 0) + if (BEZT_ISSEL_ANY(bezt) == 0) { continue; + } } /* draw handle with appropriate set of colors if selection is ok */ @@ -464,8 +466,9 @@ static void draw_fcurve_samples(SpaceGraph *sipo, ARegion *ar, FCurve *fcu) /* draw */ if (first && last) { /* anti-aliased lines for more consistent appearance */ - if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) + if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) { GPU_line_smooth(true); + } GPU_blend(true); uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); @@ -479,8 +482,9 @@ static void draw_fcurve_samples(SpaceGraph *sipo, ARegion *ar, FCurve *fcu) immUnbindProgram(); GPU_blend(false); - if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) + if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) { GPU_line_smooth(false); + } } } @@ -502,8 +506,9 @@ static void draw_fcurve_curve( /* when opening a blend file on a different sized screen or while dragging the toolbar this can * happen best just bail out in this case. */ UI_view2d_grid_size(grid, &dx, &dy); - if (dx <= 0.0f) + if (dx <= 0.0f) { return; + } /* disable any drivers */ FCurve fcurve_for_draw = *fcu_; @@ -540,13 +545,15 @@ static void draw_fcurve_curve( * This one still amounts to 10 sample-frames for each 1-frame interval * which should be quite a decent approximation in many situations. */ - if (samplefreq < 0.1f) + if (samplefreq < 0.1f) { samplefreq = 0.1f; + } } else { /* "Higher Precision" but slower - especially on larger windows (e.g. T40372) */ - if (samplefreq < 0.00001f) + if (samplefreq < 0.00001f) { samplefreq = 0.00001f; + } } /* the start/end times are simply the horizontal extents of the 'cur' rect */ @@ -613,8 +620,9 @@ static void draw_fcurve_curve_samples( else { /* extrapolate linear doesn't use the handle, use the next points center instead */ fac = (prevfpt->vec[0] - fpt->vec[0]) / (prevfpt->vec[0] - v[0]); - if (fac) + if (fac) { fac = 1.0f / fac; + } v[1] = prevfpt->vec[1] - fac * (prevfpt->vec[1] - fpt->vec[1]); } @@ -647,8 +655,9 @@ static void draw_fcurve_curve_samples( /* extrapolate linear doesn't use the handle, use the previous points center instead */ fpt = prevfpt - 1; fac = (prevfpt->vec[0] - fpt->vec[0]) / (prevfpt->vec[0] - v[0]); - if (fac) + if (fac) { fac = 1.0f / fac; + } v[1] = prevfpt->vec[1] - fac * (prevfpt->vec[1] - fpt->vec[1]); } @@ -716,15 +725,17 @@ static void draw_fcurve_curve_bezts( else if (prevbezt->ipo == BEZT_IPO_LIN) { /* extrapolate linear dosnt use the handle, use the next points center instead */ fac = (prevbezt->vec[1][0] - bezt->vec[1][0]) / (prevbezt->vec[1][0] - v1[0]); - if (fac) + if (fac) { fac = 1.0f / fac; + } v1[1] = prevbezt->vec[1][1] - fac * (prevbezt->vec[1][1] - bezt->vec[1][1]); } else { /* based on angle of handle 1 (relative to keyframe) */ fac = (prevbezt->vec[0][0] - prevbezt->vec[1][0]) / (prevbezt->vec[1][0] - v1[0]); - if (fac) + if (fac) { fac = 1.0f / fac; + } v1[1] = prevbezt->vec[1][1] - fac * (prevbezt->vec[0][1] - prevbezt->vec[1][1]); } @@ -782,8 +793,9 @@ static void draw_fcurve_curve_bezts( else { /* clamp resolution to max of 32 */ /* NOTE: higher values will crash */ - if (resol > 32) + if (resol > 32) { resol = 32; + } v1[0] = prevbezt->vec[1][0]; v1[1] = prevbezt->vec[1][1]; @@ -833,15 +845,17 @@ static void draw_fcurve_curve_bezts( /* extrapolate linear dosnt use the handle, use the previous points center instead */ bezt = prevbezt - 1; fac = (prevbezt->vec[1][0] - bezt->vec[1][0]) / (prevbezt->vec[1][0] - v1[0]); - if (fac) + if (fac) { fac = 1.0f / fac; + } v1[1] = prevbezt->vec[1][1] - fac * (prevbezt->vec[1][1] - bezt->vec[1][1]); } else { /* based on angle of handle 1 (relative to keyframe) */ fac = (prevbezt->vec[2][0] - prevbezt->vec[1][0]) / (prevbezt->vec[1][0] - v1[0]); - if (fac) + if (fac) { fac = 1.0f / fac; + } v1[1] = prevbezt->vec[1][1] - fac * (prevbezt->vec[2][1] - prevbezt->vec[1][1]); } @@ -1197,8 +1211,9 @@ void graph_draw_curves( } /* undo mapping of keyframes for drawing if scaled F-Curve */ - if (adt) + if (adt) { ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 0); + } } /* free list of curves */ diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c index a526ada2300..1bb14bc3ce2 100644 --- a/source/blender/editors/space_graph/graph_edit.c +++ b/source/blender/editors/space_graph/graph_edit.c @@ -94,14 +94,18 @@ void get_graph_keyframe_extents(bAnimContext *ac, ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* set large values initial values that will be easy to override */ - if (xmin) + if (xmin) { *xmin = 999999999.0f; - if (xmax) + } + if (xmax) { *xmax = -999999999.0f; - if (ymin) + } + if (ymin) { *ymin = 999999999.0f; - if (ymax) + } + if (ymax) { *ymax = -999999999.0f; + } /* check if any channels to set range with */ if (anim_data.first) { @@ -132,14 +136,18 @@ void get_graph_keyframe_extents(bAnimContext *ac, tymax *= unitFac; /* try to set cur using these values, if they're more extreme than previously set values */ - if ((xmin) && (txmin < *xmin)) + if ((xmin) && (txmin < *xmin)) { *xmin = txmin; - if ((xmax) && (txmax > *xmax)) + } + if ((xmax) && (txmax > *xmax)) { *xmax = txmax; - if ((ymin) && (tymin < *ymin)) + } + if ((ymin) && (tymin < *ymin)) { *ymin = tymin; - if ((ymax) && (tymax > *ymax)) + } + if ((ymax) && (tymax > *ymax)) { *ymax = tymax; + } foundBounds = true; } @@ -157,14 +165,18 @@ void get_graph_keyframe_extents(bAnimContext *ac, } } else { - if (xmin) + if (xmin) { *xmin = (float)PSFRA; - if (xmax) + } + if (xmax) { *xmax = (float)PEFRA; - if (ymin) + } + if (ymin) { *ymin = -5; - if (ymax) + } + if (ymax) { *ymax = 5; + } } /* free memory */ @@ -173,22 +185,28 @@ void get_graph_keyframe_extents(bAnimContext *ac, else { /* set default range */ if (ac->scene) { - if (xmin) + if (xmin) { *xmin = (float)PSFRA; - if (xmax) + } + if (xmax) { *xmax = (float)PEFRA; + } } else { - if (xmin) + if (xmin) { *xmin = -5; - if (xmax) + } + if (xmax) { *xmax = 100; + } } - if (ymin) + if (ymin) { *ymin = -5; - if (ymax) + } + if (ymax) { *ymax = 5; + } } } @@ -201,12 +219,15 @@ static int graphkeys_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_graph_keyframe_extents(&ac, &min, &max, NULL, NULL, false, false); @@ -248,8 +269,9 @@ static int graphkeys_viewall(bContext *C, rctf cur_new; /* get editor data */ - if (ANIM_animdata_get_context(C, &ac) == 0) + if (ANIM_animdata_get_context(C, &ac) == 0) { return OPERATOR_CANCELLED; + } /* set the horizontal range, with an extra offset so that the extreme keys will be in view */ get_graph_keyframe_extents(&ac, @@ -444,8 +466,9 @@ static int graphkeys_create_ghostcurves_exec(bContext *C, wmOperator *UNUSED(op) int start, end; /* get editor data */ - if (ANIM_animdata_get_context(C, &ac) == 0) + if (ANIM_animdata_get_context(C, &ac) == 0) { return OPERATOR_CANCELLED; + } /* Ghost curves are snapshots of the visible portions of the curves, * so set range to be the visible range. */ @@ -489,8 +512,9 @@ static int graphkeys_clear_ghostcurves_exec(bContext *C, wmOperator *UNUSED(op)) SpaceGraph *sipo; /* get editor data */ - if (ANIM_animdata_get_context(C, &ac) == 0) + if (ANIM_animdata_get_context(C, &ac) == 0) { return OPERATOR_CANCELLED; + } sipo = (SpaceGraph *)ac.sl; /* if no ghost curves, don't do anything */ @@ -579,21 +603,26 @@ static void insert_graph_keys(bAnimContext *ac, eGraphKeys_InsertKey_Types mode) /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); - if (mode & GRAPHKEYS_INSERTKEY_SEL) + if (mode & GRAPHKEYS_INSERTKEY_SEL) { filter |= ANIMFILTER_SEL; - else if (mode & GRAPHKEYS_INSERTKEY_ACTIVE) + } + else if (mode & GRAPHKEYS_INSERTKEY_ACTIVE) { filter |= ANIMFILTER_ACTIVE; + } num_items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); if (num_items == 0) { - if (mode & GRAPHKEYS_INSERTKEY_ACTIVE) + if (mode & GRAPHKEYS_INSERTKEY_ACTIVE) { BKE_report(reports, RPT_ERROR, "No active F-Curve to add a keyframe to. Select an editable F-Curve first"); - else if (mode & GRAPHKEYS_INSERTKEY_SEL) + } + else if (mode & GRAPHKEYS_INSERTKEY_SEL) { BKE_report(reports, RPT_ERROR, "No selected F-Curves to add keyframes to"); - else + } + else { BKE_report(reports, RPT_ERROR, "No channels to add keyframes to"); + } return; } @@ -615,18 +644,23 @@ static void insert_graph_keys(bAnimContext *ac, eGraphKeys_InsertKey_Types mode) float x, y; /* perform time remapping for x-coordinate (if necessary) */ - if ((sipo) && (sipo->mode == SIPO_MODE_DRIVERS)) + if ((sipo) && (sipo->mode == SIPO_MODE_DRIVERS)) { x = sipo->cursorTime; - else if (adt) + } + else if (adt) { x = BKE_nla_tweakedit_remap(adt, (float)CFRA, NLATIME_CONVERT_UNMAP); - else + } + else { x = (float)CFRA; + } /* normalise units of cursor's value */ - if (sipo) + if (sipo) { y = (sipo->cursorVal / unit_scale) - offset; - else + } + else { y = 0.0f; + } /* insert keyframe directly into the F-Curve */ insert_vert_fcurve(fcu, x, y, ts->keyframe_type, 0); @@ -669,10 +703,12 @@ static void insert_graph_keys(bAnimContext *ac, eGraphKeys_InsertKey_Types mode) AnimData *adt = ANIM_nla_mapping_get(ac, ale); /* adjust current frame for NLA-mapping */ - if ((sipo) && (sipo->mode == SIPO_MODE_DRIVERS)) + if ((sipo) && (sipo->mode == SIPO_MODE_DRIVERS)) { cfra = sipo->cursorTime; - else if (adt) + } + else if (adt) { cfra = BKE_nla_tweakedit_remap(adt, (float)CFRA, NLATIME_CONVERT_UNMAP); + } const float curval = evaluate_fcurve_only_curve(fcu, cfra); insert_vert_fcurve(fcu, cfra, curval, ts->keyframe_type, 0); @@ -696,8 +732,9 @@ static int graphkeys_insertkey_exec(bContext *C, wmOperator *op) eGraphKeys_InsertKey_Types mode; /* get editor data */ - if (ANIM_animdata_get_context(C, &ac) == 0) + if (ANIM_animdata_get_context(C, &ac) == 0) { return OPERATOR_CANCELLED; + } /* which channels to affect? */ mode = RNA_enum_get(op->ptr, "type"); @@ -741,14 +778,16 @@ static int graphkeys_click_insert_exec(bContext *C, wmOperator *op) float frame, val; /* get animation context */ - if (ANIM_animdata_get_context(C, &ac) == 0) + if (ANIM_animdata_get_context(C, &ac) == 0) { return OPERATOR_CANCELLED; + } /* get active F-Curve 'anim-list-element' */ ale = get_active_fcurve_channel(&ac); if (ELEM(NULL, ale, ale->data)) { - if (ale) + if (ale) { MEM_freeN(ale); + } return OPERATOR_CANCELLED; } fcu = ale->data; @@ -797,12 +836,15 @@ static int graphkeys_click_insert_exec(bContext *C, wmOperator *op) } else { /* warn about why this can't happen */ - if (fcu->fpt) + if (fcu->fpt) { BKE_report(op->reports, RPT_ERROR, "Keyframes cannot be added to sampled F-Curves"); - else if (fcu->flag & FCURVE_PROTECTED) + } + else if (fcu->flag & FCURVE_PROTECTED) { BKE_report(op->reports, RPT_ERROR, "Active F-Curve is not editable"); - else + } + else { BKE_report(op->reports, RPT_ERROR, "Remove F-Modifiers from F-Curve to add keyframes"); + } } /* free temp data */ @@ -824,8 +866,9 @@ static int graphkeys_click_insert_invoke(bContext *C, wmOperator *op, const wmEv float x, y; /* get animation context */ - if (ANIM_animdata_get_context(C, &ac) == 0) + if (ANIM_animdata_get_context(C, &ac) == 0) { return OPERATOR_CANCELLED; + } /* store mouse coordinates in View2D space, into the operator's properties */ ar = ac.ar; @@ -919,8 +962,9 @@ static short paste_graph_keys(bAnimContext *ac, filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); - if (ANIM_animdata_filter(ac, &anim_data, filter | ANIMFILTER_SEL, ac->data, ac->datatype) == 0) + if (ANIM_animdata_filter(ac, &anim_data, filter | ANIMFILTER_SEL, ac->data, ac->datatype) == 0) { ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); + } /* paste keyframes */ ok = paste_animedit_keys(ac, &anim_data, offset_mode, merge_mode, flip); @@ -938,8 +982,9 @@ static int graphkeys_copy_exec(bContext *C, wmOperator *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; + } /* copy keyframes */ if (copy_graph_keys(&ac)) { @@ -975,8 +1020,9 @@ static int graphkeys_paste_exec(bContext *C, wmOperator *op) const bool flipped = RNA_boolean_get(op->ptr, "flipped"); /* get editor data */ - if (ANIM_animdata_get_context(C, &ac) == 0) + if (ANIM_animdata_get_context(C, &ac) == 0) { return OPERATOR_CANCELLED; + } /* ac.reports by default will be the global reports list, which won't show warnings */ ac.reports = op->reports; @@ -1060,8 +1106,9 @@ static int graphkeys_duplicate_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; + } /* duplicate keyframes */ duplicate_graph_keys(&ac); @@ -1140,12 +1187,14 @@ static int graphkeys_delete_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; + } /* delete keyframes */ - if (!delete_graph_keys(&ac)) + if (!delete_graph_keys(&ac)) { return OPERATOR_CANCELLED; + } /* set notifier that keyframes have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_REMOVED, NULL); @@ -1202,8 +1251,9 @@ static int graphkeys_clean_exec(bContext *C, wmOperator *op) bool clean_chan; /* get editor data */ - if (ANIM_animdata_get_context(C, &ac) == 0) + if (ANIM_animdata_get_context(C, &ac) == 0) { return OPERATOR_CANCELLED; + } /* get cleaning threshold */ thresh = RNA_float_get(op->ptr, "threshold"); @@ -1283,8 +1333,9 @@ static int graphkeys_bake_exec(bContext *C, wmOperator *UNUSED(op)) int start, end; /* get editor data */ - if (ANIM_animdata_get_context(C, &ac) == 0) + if (ANIM_animdata_get_context(C, &ac) == 0) { return OPERATOR_CANCELLED; + } /* for now, init start/end from preview-range extents */ // TODO: add properties for this @@ -1346,8 +1397,9 @@ static float fcurve_samplingcb_sound(FCurve *UNUSED(fcu), void *data, float eval tSoundBakeInfo *sbi = (tSoundBakeInfo *)data; int position = evaltime - sbi->cfra; - if ((position < 0) || (position >= sbi->length)) + if ((position < 0) || (position >= sbi->length)) { return 0.0f; + } return sbi->samples[position]; } @@ -1368,8 +1420,9 @@ static int graphkeys_sound_bake_exec(bContext *C, wmOperator *op) char path[FILE_MAX]; /* get editor data */ - if (ANIM_animdata_get_context(C, &ac) == 0) + if (ANIM_animdata_get_context(C, &ac) == 0) { return OPERATOR_CANCELLED; + } RNA_string_get(op->ptr, "filepath", path); @@ -1447,8 +1500,9 @@ static int graphkeys_sound_bake_invoke(bContext *C, wmOperator *op, const wmEven bAnimContext ac; /* verify editor data */ - if (ANIM_animdata_get_context(C, &ac) == 0) + if (ANIM_animdata_get_context(C, &ac) == 0) { return OPERATOR_CANCELLED; + } return WM_operator_filesel(C, op, event); } @@ -1588,8 +1642,9 @@ static int graphkeys_sample_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; + } /* sample keyframes */ sample_graph_keys(&ac); @@ -1690,8 +1745,9 @@ static void setexpo_graph_keys(bAnimContext *ac, short mode) for (fcm = fcu->modifiers.first; fcm; fcm = fcn) { fcn = fcm->next; - if (fcm->type == FMODIFIER_TYPE_CYCLES) + if (fcm->type == FMODIFIER_TYPE_CYCLES) { remove_fmodifier(&fcu->modifiers, fcm); + } } } } @@ -1711,8 +1767,9 @@ static int graphkeys_expo_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; + } /* get handle setting mode */ mode = RNA_enum_get(op->ptr, "type"); @@ -1782,8 +1839,9 @@ static int graphkeys_ipo_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; + } /* get handle setting mode */ mode = RNA_enum_get(op->ptr, "type"); @@ -1852,8 +1910,9 @@ static int graphkeys_easing_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; + } /* get handle setting mode */ mode = RNA_enum_get(op->ptr, "type"); @@ -1932,8 +1991,9 @@ static int graphkeys_handletype_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; + } /* get handle setting mode */ mode = RNA_enum_get(op->ptr, "type"); @@ -2001,8 +2061,9 @@ static int graphkeys_euler_filter_exec(bContext *C, wmOperator *op) int groups = 0, failed = 0; /* get editor data */ - if (ANIM_animdata_get_context(C, &ac) == 0) + if (ANIM_animdata_get_context(C, &ac) == 0) { return OPERATOR_CANCELLED; + } /* The process is done in two passes: * 1) Sets of three related rotation curves are identified from the selected channels, @@ -2023,8 +2084,9 @@ static int graphkeys_euler_filter_exec(bContext *C, wmOperator *op) * - only rotation curves * - for pchan curves, make sure we're only using the euler curves */ - if (strstr(fcu->rna_path, "rotation_euler") == NULL) + if (strstr(fcu->rna_path, "rotation_euler") == NULL) { continue; + } else if (ELEM(fcu->array_index, 0, 1, 2) == 0) { BKE_reportf(op->reports, RPT_WARNING, @@ -2099,8 +2161,9 @@ static int graphkeys_euler_filter_exec(bContext *C, wmOperator *op) unsigned int i; /* skip if not enough vets to do a decent analysis of... */ - if (fcu->totvert <= 2) + if (fcu->totvert <= 2) { continue; + } /* prev follows bezt, bezt = "current" point to be fixed */ /* our method depends on determining a "difference" from the previous vert */ @@ -2178,8 +2241,9 @@ void GRAPH_OT_euler_filter(wmOperatorType *ot) static bool graphkeys_framejump_poll(bContext *C) { /* prevent changes during render */ - if (G.is_rendering) + if (G.is_rendering) { return 0; + } return graphop_visible_keyframes_poll(C); } @@ -2194,8 +2258,9 @@ static int graphkeys_framejump_exec(bContext *C, wmOperator *UNUSED(op)) KeyframeEditData ked; /* get editor data */ - if (ANIM_animdata_get_context(C, &ac) == 0) + if (ANIM_animdata_get_context(C, &ac) == 0) { return OPERATOR_CANCELLED; + } /* init edit data */ memset(&ked, 0, sizeof(KeyframeEditData)); @@ -2219,8 +2284,9 @@ static int graphkeys_framejump_exec(bContext *C, wmOperator *UNUSED(op)) ANIM_fcurve_keyframes_loop(¤t_ked, ale->key_data, NULL, bezt_calc_average, NULL); ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1); } - else + else { ANIM_fcurve_keyframes_loop(¤t_ked, ale->key_data, NULL, bezt_calc_average, NULL); + } ked.f1 += current_ked.f1; ked.i1 += current_ked.i1; @@ -2368,8 +2434,9 @@ static void snap_graph_keys(bAnimContext *ac, short mode) ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, calchandles_fcurve); ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 0); } - else + else { ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, calchandles_fcurve); + } ale->update |= ANIM_UPDATE_DEFAULT; } @@ -2386,8 +2453,9 @@ static int graphkeys_snap_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; + } /* get snapping mode */ mode = RNA_enum_get(op->ptr, "type"); @@ -2477,10 +2545,12 @@ static void mirror_graph_keys(bAnimContext *ac, short mode) marker = ED_markers_get_first_selected(ac->markers); /* store marker's time (if available) */ - if (marker) + if (marker) { ked.f1 = (float)marker->frame; - else + } + else { return; + } } else if (mode == GRAPHKEYS_MIRROR_VALUE) { cursor_value = (sipo) ? sipo->cursorVal : 0.0f; @@ -2523,8 +2593,9 @@ static void mirror_graph_keys(bAnimContext *ac, short mode) ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, calchandles_fcurve); ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 0); } - else + else { ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, calchandles_fcurve); + } ale->update |= ANIM_UPDATE_DEFAULT; } @@ -2541,8 +2612,9 @@ static int graphkeys_mirror_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; + } /* get mirroring mode */ mode = RNA_enum_get(op->ptr, "type"); @@ -2585,8 +2657,9 @@ static int graphkeys_smooth_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; + } /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | @@ -2652,8 +2725,9 @@ static const EnumPropertyItem *graph_fmodifier_itemf(bContext *C, int index; /* check if modifier is valid for this context */ - if (fmi == NULL) + if (fmi == NULL) { continue; + } index = RNA_enum_from_value(rna_enum_fmodifier_type_items, fmi->type); if (index != -1) { /* Not all types are implemented yet... */ @@ -2676,19 +2750,22 @@ static int graph_fmodifier_add_exec(bContext *C, wmOperator *op) short type; /* get editor data */ - if (ANIM_animdata_get_context(C, &ac) == 0) + if (ANIM_animdata_get_context(C, &ac) == 0) { return OPERATOR_CANCELLED; + } /* get type of modifier to add */ type = RNA_enum_get(op->ptr, "type"); /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); - if (RNA_boolean_get(op->ptr, "only_active")) + if (RNA_boolean_get(op->ptr, "only_active")) { filter |= ANIMFILTER_ACTIVE; // FIXME: enforce in this case only a single channel to get handled? - else + } + else { filter |= (ANIMFILTER_SEL | ANIMFILTER_CURVE_VISIBLE); + } ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* add f-modifier to each curve */ @@ -2753,8 +2830,9 @@ static int graph_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(); @@ -2778,8 +2856,9 @@ static int graph_fmodifier_copy_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_ERROR, "No F-Modifiers available to be copied"); return OPERATOR_CANCELLED; } - else + else { return OPERATOR_FINISHED; + } } void GRAPH_OT_fmodifier_copy(wmOperatorType *ot) @@ -2820,8 +2899,9 @@ static int graph_fmodifier_paste_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; + } /* filter data */ if (RNA_boolean_get(op->ptr, "only_active")) { @@ -2906,8 +2986,9 @@ static int graph_driver_vars_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_driver_vars_copybuf_free(); @@ -2926,10 +3007,12 @@ static int graph_driver_vars_copy_exec(bContext *C, wmOperator *op) } /* successful or not? */ - if (ok) + if (ok) { return OPERATOR_FINISHED; - else + } + else { return OPERATOR_CANCELLED; + } } void GRAPH_OT_driver_variables_copy(wmOperatorType *ot) @@ -2961,8 +3044,9 @@ static int graph_driver_vars_paste_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; + } /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_ACTIVE | ANIMFILTER_FOREDIT | @@ -3028,8 +3112,9 @@ static int graph_driver_delete_invalid_exec(bContext *C, wmOperator *op) unsigned int deleted = 0; /* get editor data */ - if (ANIM_animdata_get_context(C, &ac) == 0) + if (ANIM_animdata_get_context(C, &ac) == 0) { return OPERATOR_CANCELLED; + } /* NOTE: we might need a scene update to evaluate the driver flags */ @@ -3081,8 +3166,9 @@ static bool graph_driver_delete_invalid_poll(bContext *C) ScrArea *sa = CTX_wm_area(C); /* firstly, check if in Graph Editor */ - if ((sa == NULL) || (sa->spacetype != SPACE_GRAPH)) + if ((sa == NULL) || (sa->spacetype != SPACE_GRAPH)) { return 0; + } /* try to init Anim-Context stuff ourselves and check */ return ANIM_animdata_get_context(C, &ac) != 0; diff --git a/source/blender/editors/space_graph/graph_ops.c b/source/blender/editors/space_graph/graph_ops.c index 30f3960e18a..79df4760939 100644 --- a/source/blender/editors/space_graph/graph_ops.c +++ b/source/blender/editors/space_graph/graph_ops.c @@ -64,8 +64,9 @@ static bool graphview_cursor_poll(bContext *C) { /* prevent changes during render */ - if (G.is_rendering) + if (G.is_rendering) { return 0; + } return ED_operator_graphedit_active(C); } @@ -132,8 +133,9 @@ static void graphview_cursor_setprops(bContext *C, wmOperator *op, const wmEvent float viewx, viewy; /* abort if not active region (should not really be possible) */ - if (ar == NULL) + if (ar == NULL) { return; + } /* convert from region coordinates to View2D 'tot' space */ UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &viewx, &viewy); @@ -157,8 +159,9 @@ static int graphview_cursor_invoke(bContext *C, wmOperator *op, const wmEvent *e graphview_cursor_apply(C, op); /* Signal that a scrubbing operating is starting */ - if (screen) + if (screen) { screen->scrubbing = true; + } /* add temp handler */ WM_event_add_modal_handler(C, op); @@ -174,8 +177,9 @@ static int graphview_cursor_modal(bContext *C, wmOperator *op, const wmEvent *ev /* execute the events */ switch (event->type) { case ESCKEY: - if (screen) + if (screen) { screen->scrubbing = false; + } WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); return OPERATOR_FINISHED; @@ -191,8 +195,9 @@ static int graphview_cursor_modal(bContext *C, wmOperator *op, const wmEvent *ev case MIDDLEMOUSE: /* We check for either mouse-button to end, to work with all user keymaps. */ if (event->val == KM_RELEASE) { - if (screen) + if (screen) { screen->scrubbing = false; + } WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); return OPERATOR_FINISHED; @@ -236,8 +241,9 @@ static int graphview_curves_hide_exec(bContext *C, wmOperator *op) const bool unselected = RNA_boolean_get(op->ptr, "unselected"); /* get editor data */ - if (ANIM_animdata_get_context(C, &ac) == 0) + if (ANIM_animdata_get_context(C, &ac) == 0) { return OPERATOR_CANCELLED; + } /* get list of all channels that selection may need to be flushed to * - hierarchy must not affect what we have access to here... @@ -250,10 +256,12 @@ static int graphview_curves_hide_exec(bContext *C, wmOperator *op) * selected/unselected (depending on "unselected" prop) */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); - if (unselected) + if (unselected) { filter |= ANIMFILTER_UNSEL; - else + } + else { filter |= ANIMFILTER_SEL; + } ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); @@ -261,8 +269,9 @@ static int graphview_curves_hide_exec(bContext *C, wmOperator *op) /* hack: skip object channels for now, since flushing those will always flush everything, * but they are always included */ /* TODO: find out why this is the case, and fix that */ - if (ale->type == ANIMTYPE_OBJECT) + if (ale->type == ANIMTYPE_OBJECT) { continue; + } /* change the hide setting, and unselect it... */ ANIM_channel_setting_set(&ac, ale, ACHANNEL_SETTING_VISIBLE, ACHANNEL_SETFLAG_CLEAR); @@ -290,8 +299,9 @@ static int graphview_curves_hide_exec(bContext *C, wmOperator *op) * will always flush everything, but they are always included */ /* TODO: find out why this is the case, and fix that */ - if (ale->type == ANIMTYPE_OBJECT) + if (ale->type == ANIMTYPE_OBJECT) { continue; + } /* change the hide setting, and unselect it... */ ANIM_channel_setting_set(&ac, ale, ACHANNEL_SETTING_VISIBLE, ACHANNEL_SETFLAG_ADD); @@ -341,8 +351,9 @@ static int graphview_curves_reveal_exec(bContext *C, wmOperator *op) const bool select = RNA_boolean_get(op->ptr, "select"); /* get editor data */ - if (ANIM_animdata_get_context(C, &ac) == 0) + if (ANIM_animdata_get_context(C, &ac) == 0) { return OPERATOR_CANCELLED; + } /* get list of all channels that selection may need to be flushed to * - hierarchy must not affect what we have access to here... @@ -360,8 +371,9 @@ static int graphview_curves_reveal_exec(bContext *C, wmOperator *op) /* hack: skip object channels for now, since flushing those will always flush everything, * but they are always included. */ /* TODO: find out why this is the case, and fix that */ - if (ale->type == ANIMTYPE_OBJECT) + if (ale->type == ANIMTYPE_OBJECT) { continue; + } /* select if it is not visible */ if (ANIM_channel_setting_get(&ac, ale, ACHANNEL_SETTING_VISIBLE) == 0) { 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")) { diff --git a/source/blender/editors/space_graph/graph_utils.c b/source/blender/editors/space_graph/graph_utils.c index d8cb173f944..b823ddec696 100644 --- a/source/blender/editors/space_graph/graph_utils.c +++ b/source/blender/editors/space_graph/graph_utils.c @@ -139,20 +139,23 @@ bool graphop_visible_keyframes_poll(bContext *C) /* firstly, check if in Graph Editor */ // TODO: also check for region? - if ((sa == NULL) || (sa->spacetype != SPACE_GRAPH)) + if ((sa == NULL) || (sa->spacetype != SPACE_GRAPH)) { return 0; + } /* try to init Anim-Context stuff ourselves and check */ - if (ANIM_animdata_get_context(C, &ac) == 0) + if (ANIM_animdata_get_context(C, &ac) == 0) { return 0; + } /* loop over the visible (selection doesn't matter) F-Curves, and see if they're suitable * stopping on the first successful match */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE); items = ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - if (items == 0) + if (items == 0) { return 0; + } for (ale = anim_data.first; ale; ale = ale->next) { FCurve *fcu = (FCurve *)ale->data; @@ -162,8 +165,9 @@ bool graphop_visible_keyframes_poll(bContext *C) * - F-Curve modifiers do not interfere with the result too much * (i.e. the modifier-control drawing check returns false) */ - if (fcu->bezt == NULL) + if (fcu->bezt == NULL) { continue; + } if (fcurve_are_keyframes_usable(fcu)) { found = 1; break; @@ -188,20 +192,23 @@ bool graphop_editable_keyframes_poll(bContext *C) /* firstly, check if in Graph Editor */ // TODO: also check for region? - if ((sa == NULL) || (sa->spacetype != SPACE_GRAPH)) + if ((sa == NULL) || (sa->spacetype != SPACE_GRAPH)) { return 0; + } /* try to init Anim-Context stuff ourselves and check */ - if (ANIM_animdata_get_context(C, &ac) == 0) + if (ANIM_animdata_get_context(C, &ac) == 0) { return 0; + } /* loop over the editable F-Curves, and see if they're suitable * stopping on the first successful match */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVE_VISIBLE); items = ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - if (items == 0) + if (items == 0) { return 0; + } for (ale = anim_data.first; ale; ale = ale->next) { FCurve *fcu = (FCurve *)ale->data; @@ -212,8 +219,9 @@ bool graphop_editable_keyframes_poll(bContext *C) * - F-Curve modifiers do not interfere with the result too much * (i.e. the modifier-control drawing check returns false) */ - if (fcu->bezt == NULL) + if (fcu->bezt == NULL) { continue; + } if (fcurve_is_keyframable(fcu)) { found = 1; break; @@ -235,17 +243,20 @@ bool graphop_active_fcurve_poll(bContext *C) /* firstly, check if in Graph Editor */ // TODO: also check for region? - if ((sa == NULL) || (sa->spacetype != SPACE_GRAPH)) + if ((sa == NULL) || (sa->spacetype != SPACE_GRAPH)) { return 0; + } /* try to init Anim-Context stuff ourselves and check */ - if (ANIM_animdata_get_context(C, &ac) == 0) + if (ANIM_animdata_get_context(C, &ac) == 0) { return 0; + } /* try to get the Active F-Curve */ ale = get_active_fcurve_channel(&ac); - if (ale == NULL) + if (ale == NULL) { return 0; + } /* Do we have a suitable F-Curves? * - For most cases, NLA Control Curves are sufficiently similar to NLA @@ -277,20 +288,23 @@ bool graphop_selected_fcurve_poll(bContext *C) /* firstly, check if in Graph Editor */ // TODO: also check for region? - if ((sa == NULL) || (sa->spacetype != SPACE_GRAPH)) + if ((sa == NULL) || (sa->spacetype != SPACE_GRAPH)) { return 0; + } /* try to init Anim-Context stuff ourselves and check */ - if (ANIM_animdata_get_context(C, &ac) == 0) + if (ANIM_animdata_get_context(C, &ac) == 0) { return 0; + } /* Get the editable + selected F-Curves, and as long as we got some, we can return. * NOTE: curve-visible flag isn't included, * otherwise selecting a curve via list to edit is too cumbersome. */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT); items = ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - if (items == 0) + if (items == 0) { return 0; + } /* cleanup and return findings */ ANIM_animdata_freelist(&anim_data); diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c index 7f6ee09813a..e45a27a08fb 100644 --- a/source/blender/editors/space_graph/space_graph.c +++ b/source/blender/editors/space_graph/space_graph.c @@ -297,8 +297,9 @@ static void graph_main_region_draw(const bContext *C, ARegion *ar) if (sipo->mode != SIPO_MODE_DRIVERS) { /* current frame */ - if (sipo->flag & SIPO_DRAWTIME) + if (sipo->flag & SIPO_DRAWTIME) { cfra_flag |= DRAWCFRA_UNIT_SECONDS; + } ANIM_draw_cfra(C, v2d, cfra_flag); } @@ -434,8 +435,9 @@ static void graph_region_listener(wmWindow *UNUSED(win), ED_region_tag_redraw(ar); break; case ND_SEQUENCER: - if (wmn->action == NA_SELECTED) + if (wmn->action == NA_SELECTED) { ED_region_tag_redraw(ar); + } break; } break; @@ -447,8 +449,9 @@ static void graph_region_listener(wmWindow *UNUSED(win), ED_region_tag_redraw(ar); break; case ND_MODIFIER: - if (wmn->action == NA_RENAME) + if (wmn->action == NA_RENAME) { ED_region_tag_redraw(ar); + } break; } break; @@ -461,8 +464,9 @@ static void graph_region_listener(wmWindow *UNUSED(win), } break; case NC_ID: - if (wmn->action == NA_RENAME) + if (wmn->action == NA_RENAME) { ED_region_tag_redraw(ar); + } break; case NC_SCREEN: if (ELEM(wmn->data, ND_LAYER)) { @@ -470,8 +474,9 @@ static void graph_region_listener(wmWindow *UNUSED(win), } break; default: - if (wmn->data == ND_KEYS) + if (wmn->data == ND_KEYS) { ED_region_tag_redraw(ar); + } break; } } @@ -564,10 +569,12 @@ static void graph_listener(wmWindow *UNUSED(win), case NC_ANIMATION: /* for selection changes of animation data, we can just redraw... * otherwise autocolor might need to be done again */ - if (ELEM(wmn->data, ND_KEYFRAME, ND_ANIMCHAN) && (wmn->action == NA_SELECTED)) + if (ELEM(wmn->data, ND_KEYFRAME, ND_ANIMCHAN) && (wmn->action == NA_SELECTED)) { ED_area_tag_redraw(sa); - else + } + else { ED_area_tag_refresh(sa); + } break; case NC_SCENE: switch (wmn->data) { @@ -607,8 +614,9 @@ static void graph_listener(wmWindow *UNUSED(win), } break; case NC_SPACE: - if (wmn->data == ND_SPACE_GRAPH) + if (wmn->data == ND_SPACE_GRAPH) { ED_area_tag_redraw(sa); + } break; case NC_WINDOW: if (sipo->runtime.flag & @@ -636,8 +644,9 @@ static void graph_refresh_fcurve_colors(const bContext *C) int filter; int i; - if (ANIM_animdata_get_context(C, &ac) == false) + if (ANIM_animdata_get_context(C, &ac) == false) { return; + } UI_SetTheme(SPACE_GRAPH, RGN_TYPE_WINDOW); -- cgit v1.2.3