From add48c007428419ca57a899331e79d934cb1799b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 26 Aug 2020 10:11:13 +1000 Subject: Cleanup: use const variables in interface code --- source/blender/editors/interface/view2d.c | 32 +++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'source/blender/editors/interface/view2d.c') diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index d4f81a89bc3..7651989c2df 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -351,7 +351,7 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy) v2d->scroll |= (V2D_SCROLL_HORIZONTAL_HIDE | V2D_SCROLL_VERTICAL_HIDE); if (do_init) { - float panelzoom = (style) ? style->panelzoom : 1.0f; + const float panelzoom = (style) ? style->panelzoom : 1.0f; v2d->tot.xmin = 0.0f; v2d->tot.xmax = winx; @@ -566,7 +566,7 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize) * - width is not adjusted for changed ratios here. */ if (winx < v2d->oldwinx) { - float temp = v2d->oldwinx - winx; + const float temp = v2d->oldwinx - winx; cur->xmin -= temp; cur->xmax -= temp; @@ -588,7 +588,7 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize) */ if (winy < v2d->oldwiny) { - float temp = v2d->oldwiny - winy; + const float temp = v2d->oldwiny - winy; if (v2d->align & V2D_ALIGN_NO_NEG_Y) { cur->ymin -= temp; @@ -1121,14 +1121,14 @@ static void view2d_map_cur_using_mask(const View2D *v2d, rctf *r_curmasked) *r_curmasked = v2d->cur; if (view2d_scroll_mapped(v2d->scroll)) { - float sizex = BLI_rcti_size_x(&v2d->mask); - float sizey = BLI_rcti_size_y(&v2d->mask); + const float sizex = BLI_rcti_size_x(&v2d->mask); + const float sizey = BLI_rcti_size_y(&v2d->mask); /* prevent tiny or narrow regions to get * invalid coordinates - mask can get negative even... */ if (sizex > 0.0f && sizey > 0.0f) { - float dx = BLI_rctf_size_x(&v2d->cur) / (sizex + 1); - float dy = BLI_rctf_size_y(&v2d->cur) / (sizey + 1); + const float dx = BLI_rctf_size_x(&v2d->cur) / (sizex + 1); + const float dy = BLI_rctf_size_y(&v2d->cur) / (sizey + 1); if (v2d->mask.xmin != 0) { r_curmasked->xmin -= dx * (float)v2d->mask.xmin; @@ -1225,8 +1225,8 @@ void UI_view2d_view_orthoSpecial(ARegion *region, View2D *v2d, const bool xaxis) void UI_view2d_view_restore(const bContext *C) { ARegion *region = CTX_wm_region(C); - int width = BLI_rcti_size_x(®ion->winrct) + 1; - int height = BLI_rcti_size_y(®ion->winrct) + 1; + const int width = BLI_rcti_size_x(®ion->winrct) + 1; + const int height = BLI_rcti_size_y(®ion->winrct) + 1; wmOrtho2(0.0f, (float)width, 0.0f, (float)height); GPU_matrix_identity_set(); @@ -1278,8 +1278,8 @@ void UI_view2d_constant_grid_draw(const View2D *v2d, float step) if (count_x > 0 || count_y > 0) { GPUVertFormat *format = immVertexFormat(); - uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); - uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + const uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + const uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); float theme_color[3]; UI_GetThemeColorShade3fv(TH_BACK, -10, theme_color); @@ -1331,7 +1331,7 @@ void UI_view2d_multi_grid_draw( vertex_count += 2 * ((int)((v2d->cur.ymax - v2d->cur.ymin) / lstep) + 1); GPUVertFormat *format = immVertexFormat(); - uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + const uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); uint color = GPU_vertformat_attr_add( format, "color", GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT); @@ -1428,7 +1428,7 @@ void UI_view2d_scrollers_calc(View2D *v2d, { rcti vert, hor; float fac1, fac2, totsize, scrollsize; - int scroll = view2d_scroll_mapped(v2d->scroll); + const int scroll = view2d_scroll_mapped(v2d->scroll); int smaller; /* Always update before drawing (for dynamically sized scrollers). */ @@ -1910,7 +1910,7 @@ View2D *UI_view2d_fromcontext_rwin(const bContext *C) * disabled. */ void UI_view2d_scroller_size_get(const View2D *v2d, float *r_x, float *r_y) { - int scroll = view2d_scroll_mapped(v2d->scroll); + const int scroll = view2d_scroll_mapped(v2d->scroll); if (r_x) { if (scroll & V2D_SCROLL_VERTICAL) { @@ -2128,7 +2128,7 @@ void UI_view2d_text_cache_add( BLI_assert(str_len == strlen(str)); if (UI_view2d_view_to_region_clip(v2d, x, y, &mval[0], &mval[1])) { - int alloc_len = str_len + 1; + const int alloc_len = str_len + 1; View2DString *v2s; if (g_v2d_strings_arena == NULL) { @@ -2159,7 +2159,7 @@ void UI_view2d_text_cache_add_rectf( BLI_assert(str_len == strlen(str)); if (UI_view2d_view_to_region_rcti_clip(v2d, rect_view, &rect)) { - int alloc_len = str_len + 1; + const int alloc_len = str_len + 1; View2DString *v2s; if (g_v2d_strings_arena == NULL) { -- cgit v1.2.3