From 6dbe96757bc345efa8a432861b057f65b26ae69f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 25 Mar 2019 12:19:55 +1100 Subject: Cleanup: return argument naming --- source/blender/editors/include/UI_interface.h | 6 +- source/blender/editors/include/UI_view2d.h | 6 +- .../blender/editors/interface/interface_handlers.c | 2 +- .../blender/editors/interface/interface_intern.h | 4 +- .../blender/editors/interface/interface_layout.c | 34 ++++---- source/blender/editors/interface/interface_panel.c | 24 +++--- .../blender/editors/interface/interface_widgets.c | 12 +-- source/blender/editors/interface/view2d.c | 94 +++++++++++----------- 8 files changed, 93 insertions(+), 89 deletions(-) diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 45b379f42ee..f6014f58043 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -906,7 +906,7 @@ int UI_autocomplete_end(AutoComplete *autocpl, char *autoname); * not clear yet so we postpone that. */ void UI_panels_begin(const struct bContext *C, struct ARegion *ar); -void UI_panels_end(const struct bContext *C, struct ARegion *ar, int *x, int *y); +void UI_panels_end(const struct bContext *C, struct ARegion *ar, int *r_x, int *r_y); void UI_panels_draw(const struct bContext *C, struct ARegion *ar); struct Panel *UI_panel_find_by_type(struct ListBase *lb, struct PanelType *pt); @@ -916,7 +916,7 @@ struct Panel *UI_panel_begin( bool *r_open); void UI_panel_end(uiBlock *block, int width, int height); void UI_panels_scale(struct ARegion *ar, float new_width); -void UI_panel_label_offset(struct uiBlock *block, int *x, int *y); +void UI_panel_label_offset(struct uiBlock *block, int *r_x, int *r_y); int UI_panel_size_y(const struct Panel *pa); bool UI_panel_category_is_visible(struct ARegion *ar); @@ -1034,7 +1034,7 @@ enum { uiLayout *UI_block_layout(uiBlock *block, int dir, int type, int x, int y, int size, int em, int padding, struct uiStyle *style); void UI_block_layout_set_current(uiBlock *block, uiLayout *layout); -void UI_block_layout_resolve(uiBlock *block, int *x, int *y); +void UI_block_layout_resolve(uiBlock *block, int *r_x, int *r_y); void UI_region_message_subscribe(struct ARegion *ar, struct wmMsgBus *mbus); diff --git a/source/blender/editors/include/UI_view2d.h b/source/blender/editors/include/UI_view2d.h index df1dd0f5f63..98e00eab9c9 100644 --- a/source/blender/editors/include/UI_view2d.h +++ b/source/blender/editors/include/UI_view2d.h @@ -209,10 +209,10 @@ bool UI_view2d_view_to_region_rcti_clip(struct View2D *v2d, const struct rctf * struct View2D *UI_view2d_fromcontext(const struct bContext *C); struct View2D *UI_view2d_fromcontext_rwin(const struct bContext *C); -void UI_view2d_scale_get(struct View2D *v2d, float *x, float *y); -void UI_view2d_scale_get_inverse(struct View2D *v2d, float *x, float *y); +void UI_view2d_scale_get(struct View2D *v2d, float *r_x, float *r_y); +void UI_view2d_scale_get_inverse(struct View2D *v2d, float *r_x, float *r_y); -void UI_view2d_center_get(struct View2D *v2d, float *x, float *y); +void UI_view2d_center_get(struct View2D *v2d, float *r_x, float *r_y); void UI_view2d_center_set(struct View2D *v2d, float x, float y); void UI_view2d_offset(struct View2D *v2d, float xfac, float yfac); diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index b79bf86c03f..7448de07e0e 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -6016,7 +6016,7 @@ static bool ui_numedit_but_HSVCIRCLE( } - ui_hsvcircle_vals_from_pos(hsv, hsv + 1, &rect, mx_fl, my_fl); + ui_hsvcircle_vals_from_pos(&rect, mx_fl, my_fl, hsv, hsv + 1); if ((cpicker->use_color_cubic) && (U.color_picker_type == USER_CP_CIRCLE_HSV)) { hsv[1] = 1.0f - sqrt3f(1.0f - hsv[1]); diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 2b0bf853cae..58d81be1b51 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -462,8 +462,8 @@ extern void ui_but_v3_get(uiBut *but, float vec[3]); extern void ui_but_v3_set(uiBut *but, const float vec[3]); extern void ui_hsvcircle_vals_from_pos( - float *val_rad, float *val_dist, const rcti *rect, - const float mx, const float my); + const rcti *rect, const float mx, const float my, + float *r_val_rad, float *r_val_dist); extern void ui_hsvcircle_pos_from_vals(const ColorPicker *cpicker, const rcti *rect, const float *hsv, float *xpos, float *ypos); extern void ui_hsvcube_pos_from_vals(const struct uiBut *but, const rcti *rect, const float *hsv, float *xp, float *yp); diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index bb3172d7174..160b12526b8 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -2135,24 +2135,24 @@ void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname /* Pointer RNA button with search */ -static void search_id_collection(StructRNA *ptype, PointerRNA *ptr, PropertyRNA **prop) +static void search_id_collection(StructRNA *ptype, PointerRNA *r_ptr, PropertyRNA **r_prop) { StructRNA *srna; /* look for collection property in Main */ /* Note: using global Main is OK-ish here, UI shall not access other Mains anyay... */ - RNA_main_pointer_create(G_MAIN, ptr); + RNA_main_pointer_create(G_MAIN, r_ptr); - *prop = NULL; + *r_prop = NULL; - RNA_STRUCT_BEGIN (ptr, iprop) + RNA_STRUCT_BEGIN (r_ptr, iprop) { /* if it's a collection and has same pointer type, we've got it */ if (RNA_property_type(iprop) == PROP_COLLECTION) { - srna = RNA_property_pointer_type(ptr, iprop); + srna = RNA_property_pointer_type(r_ptr, iprop); if (ptype == srna) { - *prop = iprop; + *r_prop = iprop; break; } } @@ -4442,7 +4442,7 @@ static void ui_item_layout(uiItem *item) } } -static void ui_layout_end(uiBlock *block, uiLayout *layout, int *x, int *y) +static void ui_layout_end(uiBlock *block, uiLayout *layout, int *r_x, int *r_y) { if (layout->root->handlefunc) { UI_block_func_handle_set(block, layout->root->handlefunc, layout->root->argv); @@ -4451,11 +4451,11 @@ static void ui_layout_end(uiBlock *block, uiLayout *layout, int *x, int *y) ui_item_estimate(&layout->item); ui_item_layout(&layout->item); - if (x) { - *x = layout->x; + if (r_x) { + *r_x = layout->x; } - if (y) { - *y = layout->y; + if (r_y) { + *r_y = layout->y; } } @@ -4599,17 +4599,17 @@ void uiLayoutSetFunc(uiLayout *layout, uiMenuHandleFunc handlefunc, void *argv) layout->root->argv = argv; } -void UI_block_layout_resolve(uiBlock *block, int *x, int *y) +void UI_block_layout_resolve(uiBlock *block, int *r_x, int *r_y) { uiLayoutRoot *root; BLI_assert(block->active); - if (x) { - *x = 0; + if (r_x) { + *r_x = 0; } - if (y) { - *y = 0; + if (r_y) { + *r_y = 0; } block->curlayout = NULL; @@ -4618,7 +4618,7 @@ void UI_block_layout_resolve(uiBlock *block, int *x, int *y) ui_layout_add_padding_button(root); /* NULL in advance so we don't interfere when adding button */ - ui_layout_end(block, root->layout, x, y); + ui_layout_end(block, root->layout, r_x, r_y); ui_layout_free(root->layout); } diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index 9146e537dd5..c34992ceb9c 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -191,9 +191,9 @@ static bool panel_active_animation_changed(ListBase *lb, Panel **pa_animation, b return false; } -static bool panels_need_realign(ScrArea *sa, ARegion *ar, Panel **pa_animate) +static bool panels_need_realign(ScrArea *sa, ARegion *ar, Panel **r_pa_animate) { - *pa_animate = NULL; + *r_pa_animate = NULL; if (sa->spacetype == SPACE_PROPERTIES && ar->regiontype == RGN_TYPE_WINDOW) { SpaceProperties *sbuts = sa->spacedata.first; @@ -219,7 +219,7 @@ static bool panels_need_realign(ScrArea *sa, ARegion *ar, Panel **pa_animate) /* Detect panel marked for animation, if we're not already animating. */ if (pa_animation) { if (!no_animation) { - *pa_animate = pa_animation; + *r_pa_animate = pa_animation; } return true; } @@ -630,16 +630,16 @@ static void ui_draw_panel_dragwidget(uint pos, uint col, const rctf *rect) } /* For button layout next to label. */ -void UI_panel_label_offset(uiBlock *block, int *x, int *y) +void UI_panel_label_offset(uiBlock *block, int *r_x, int *r_y) { Panel *panel = block->panel; const bool is_subpanel = (panel->type && panel->type->parent); - *x = UI_UNIT_X * 1.0f; - *y = UI_UNIT_Y * 1.5f; + *r_x = UI_UNIT_X * 1.0f; + *r_y = UI_UNIT_Y * 1.5f; if (is_subpanel) { - *x += (0.7f * UI_UNIT_X); + *r_x += (0.7f * UI_UNIT_X); } } @@ -1167,7 +1167,7 @@ static bool uiAlignPanelStep(ScrArea *sa, ARegion *ar, const float fac, const bo return done; } -static void ui_panels_size(ScrArea *sa, ARegion *ar, int *x, int *y) +static void ui_panels_size(ScrArea *sa, ARegion *ar, int *r_x, int *r_y) { Panel *pa; int align = panel_aligned(sa, ar); @@ -1200,8 +1200,8 @@ static void ui_panels_size(ScrArea *sa, ARegion *ar, int *x, int *y) sizey = -UI_PANEL_WIDTH; } - *x = sizex; - *y = sizey; + *r_x = sizex; + *r_y = sizey; } static void ui_do_animate(const bContext *C, Panel *panel) @@ -1250,7 +1250,7 @@ void UI_panels_begin(const bContext *UNUSED(C), ARegion *ar) } /* only draws blocks with panels */ -void UI_panels_end(const bContext *C, ARegion *ar, int *x, int *y) +void UI_panels_end(const bContext *C, ARegion *ar, int *r_x, int *r_y) { ScrArea *sa = CTX_wm_area(C); uiBlock *block; @@ -1313,7 +1313,7 @@ void UI_panels_end(const bContext *C, ARegion *ar, int *x, int *y) } /* compute size taken up by panel */ - ui_panels_size(sa, ar, x, y); + ui_panels_size(sa, ar, r_x, r_y); } void UI_panels_draw(const bContext *C, ARegion *ar) diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index f99cf389935..be571de4c4e 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -2680,8 +2680,8 @@ static void ui_hsv_cursor(float x, float y) } void ui_hsvcircle_vals_from_pos( - float *val_rad, float *val_dist, const rcti *rect, - const float mx, const float my) + const rcti *rect, const float mx, const float my, + float *r_val_rad, float *r_val_dist) { /* duplication of code... well, simple is better now */ const float centx = BLI_rcti_cent_x_fl(rect); @@ -2690,8 +2690,8 @@ void ui_hsvcircle_vals_from_pos( const float m_delta[2] = {mx - centx, my - centy}; const float dist_sq = len_squared_v2(m_delta); - *val_dist = (dist_sq < (radius * radius)) ? sqrtf(dist_sq) / radius : 1.0f; - *val_rad = atan2f(m_delta[0], m_delta[1]) / (2.0f * (float)M_PI) + 0.5f; + *r_val_dist = (dist_sq < (radius * radius)) ? sqrtf(dist_sq) / radius : 1.0f; + *r_val_rad = atan2f(m_delta[0], m_delta[1]) / (2.0f * (float)M_PI) + 0.5f; } /* cursor in hsv circle, in float units -1 to 1, to map on radius */ @@ -2780,7 +2780,9 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, const uiWidgetColors *wcol, const float hsv_ang[3]; float rgb_ang[3]; - ui_hsvcircle_vals_from_pos(hsv_ang, hsv_ang + 1, rect, centx + co * radius, centy + si * radius); + ui_hsvcircle_vals_from_pos( + rect, centx + co * radius, centy + si * radius, + hsv_ang, hsv_ang + 1); hsv_ang[2] = hsv[2]; ui_color_picker_to_rgb_v(hsv_ang, rgb_ang); diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index 5f0b8f8935a..7d5a2e73113 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -1115,9 +1115,9 @@ void UI_view2d_zoom_cache_reset(void) /* View Matrix Setup */ /* mapping function to ensure 'cur' draws extended over the area where sliders are */ -static void view2d_map_cur_using_mask(View2D *v2d, rctf *curmasked) +static void view2d_map_cur_using_mask(View2D *v2d, rctf *r_curmasked) { - *curmasked = v2d->cur; + *r_curmasked = v2d->cur; if (view2d_scroll_mapped(v2d->scroll)) { float sizex = BLI_rcti_size_x(&v2d->mask); @@ -1130,17 +1130,17 @@ static void view2d_map_cur_using_mask(View2D *v2d, rctf *curmasked) float dy = BLI_rctf_size_y(&v2d->cur) / (sizey + 1); if (v2d->mask.xmin != 0) { - curmasked->xmin -= dx * (float)v2d->mask.xmin; + r_curmasked->xmin -= dx * (float)v2d->mask.xmin; } if (v2d->mask.xmax + 1 != v2d->winx) { - curmasked->xmax += dx * (float)(v2d->winx - v2d->mask.xmax - 1); + r_curmasked->xmax += dx * (float)(v2d->winx - v2d->mask.xmax - 1); } if (v2d->mask.ymin != 0) { - curmasked->ymin -= dy * (float)v2d->mask.ymin; + r_curmasked->ymin -= dy * (float)v2d->mask.ymin; } if (v2d->mask.ymax + 1 != v2d->winy) { - curmasked->ymax += dy * (float)(v2d->winy - v2d->mask.ymax - 1); + r_curmasked->ymax += dy * (float)(v2d->winy - v2d->mask.ymax - 1); } } } @@ -1244,14 +1244,14 @@ struct View2DGrid { /* --------------- */ /* try to write step as a power of 10 */ -static void step_to_grid(float *step, int *power, int unit) +static void step_to_grid(float *step, const int unit, int *r_power) { const float loga = (float)log10(*step); float rem; - *power = (int)(loga); + int power = (int)(loga); - rem = loga - (*power); + rem = loga - power; rem = (float)pow(10.0, rem); if (loga < 0.0f) { @@ -1265,7 +1265,7 @@ static void step_to_grid(float *step, int *power, int unit) rem = 1.0f; } - *step = rem * (float)pow(10.0, (*power)); + *step = rem * (float)pow(10.0, power); /* for frames, we want 1.0 frame intervals only */ if (unit == V2D_UNIT_FRAMES) { @@ -1277,7 +1277,7 @@ static void step_to_grid(float *step, int *power, int unit) /* prevents printing 1.0 2.0 3.0 etc */ if (rem == 1.0f) { - (*power)++; + power++; } } else { @@ -1291,14 +1291,16 @@ static void step_to_grid(float *step, int *power, int unit) rem = 10.0f; } - *step = rem * (float)pow(10.0, (*power)); + *step = rem * (float)pow(10.0, power); - (*power)++; + power++; /* prevents printing 1.0, 2.0, 3.0, etc. */ if (rem == 10.0f) { - (*power)++; + power++; } } + + *r_power = power; } /** @@ -1347,7 +1349,7 @@ View2DGrid *UI_view2d_grid_calc( const float pixels = (float)BLI_rcti_size_x(&v2d->mask); if (pixels != 0.0f) { grid->dx = (U.v2d_min_gridsize * UI_DPI_FAC * space) / (seconddiv * pixels); - step_to_grid(&grid->dx, &grid->powerx, xunits); + step_to_grid(&grid->dx, xunits, &grid->powerx); grid->dx *= seconddiv; } } @@ -1366,7 +1368,7 @@ View2DGrid *UI_view2d_grid_calc( const float pixels = (float)winy; if (pixels != 0.0f) { grid->dy = U.v2d_min_gridsize * UI_DPI_FAC * space / pixels; - step_to_grid(&grid->dy, &grid->powery, yunits); + step_to_grid(&grid->dy, yunits, &grid->powery); } } @@ -2234,11 +2236,11 @@ void UI_view2d_listview_cell_to_view( * (like for Animation Editor channel lists, to make the first entry more visible), these will be * the min-coordinates of the first item. * \param viewx, viewy: 2D-coordinates (in 2D-view / 'tot' rect space) to get the cell for - * \param column, row: the 'coordinates' of the relevant 'cell' + * \param r_column, r_row: the 'coordinates' of the relevant 'cell' */ void UI_view2d_listview_view_to_cell( View2D *v2d, float columnwidth, float rowheight, float startx, float starty, - float viewx, float viewy, int *column, int *row) + float viewx, float viewy, int *r_column, int *r_row) { /* adjust view coordinates to be all positive ints, corrected for the start offset */ const int x = (int)(floorf(fabsf(viewx) + 0.5f) - startx); @@ -2246,30 +2248,30 @@ void UI_view2d_listview_view_to_cell( /* sizes must not be negative */ if ((v2d == NULL) || ((columnwidth <= 0) && (rowheight <= 0))) { - if (column) { - *column = 0; + if (r_column) { + *r_column = 0; } - if (row) { - *row = 0; + if (r_row) { + *r_row = 0; } return; } /* get column */ - if ((column) && (columnwidth > 0)) { - *column = x / columnwidth; + if ((r_column) && (columnwidth > 0)) { + *r_column = x / columnwidth; } - else if (column) { - *column = 0; + else if (r_column) { + *r_column = 0; } /* get row */ - if ((row) && (rowheight > 0)) { - *row = y / rowheight; + if ((r_row) && (rowheight > 0)) { + *r_row = y / rowheight; } - else if (row) { - *row = 0; + else if (r_row) { + *r_row = 0; } } @@ -2512,27 +2514,27 @@ View2D *UI_view2d_fromcontext_rwin(const bContext *C) * Is used to inverse correct drawing of icons, etc. that need to follow view * but not be affected by scale * - * \param x, y: scale on each axis + * \param r_x, r_y: scale on each axis */ -void UI_view2d_scale_get(View2D *v2d, float *x, float *y) +void UI_view2d_scale_get(View2D *v2d, float *r_x, float *r_y) { - if (x) { - *x = BLI_rcti_size_x(&v2d->mask) / BLI_rctf_size_x(&v2d->cur); + if (r_x) { + *r_x = BLI_rcti_size_x(&v2d->mask) / BLI_rctf_size_x(&v2d->cur); } - if (y) { - *y = BLI_rcti_size_y(&v2d->mask) / BLI_rctf_size_y(&v2d->cur); + if (r_y) { + *r_y = BLI_rcti_size_y(&v2d->mask) / BLI_rctf_size_y(&v2d->cur); } } /** * Same as ``UI_view2d_scale_get() - 1.0f / x, y`` */ -void UI_view2d_scale_get_inverse(View2D *v2d, float *x, float *y) +void UI_view2d_scale_get_inverse(View2D *v2d, float *r_x, float *r_y) { - if (x) { - *x = BLI_rctf_size_x(&v2d->cur) / BLI_rcti_size_x(&v2d->mask); + if (r_x) { + *r_x = BLI_rctf_size_x(&v2d->cur) / BLI_rcti_size_x(&v2d->mask); } - if (y) { - *y = BLI_rctf_size_y(&v2d->cur) / BLI_rcti_size_y(&v2d->mask); + if (r_y) { + *r_y = BLI_rctf_size_y(&v2d->cur) / BLI_rcti_size_y(&v2d->mask); } } @@ -2540,14 +2542,14 @@ void UI_view2d_scale_get_inverse(View2D *v2d, float *x, float *y) * Simple functions for consistent center offset access. * Used by node editor to shift view center for each individual node tree. */ -void UI_view2d_center_get(struct View2D *v2d, float *x, float *y) +void UI_view2d_center_get(struct View2D *v2d, float *r_x, float *r_y) { /* get center */ - if (x) { - *x = BLI_rctf_cent_x(&v2d->cur); + if (r_x) { + *r_x = BLI_rctf_cent_x(&v2d->cur); } - if (y) { - *y = BLI_rctf_cent_y(&v2d->cur); + if (r_y) { + *r_y = BLI_rctf_cent_y(&v2d->cur); } } void UI_view2d_center_set(struct View2D *v2d, float x, float y) -- cgit v1.2.3