From 46a9038f60da4449d58075c4bbeb26b4b3982c55 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 21 Apr 2018 20:22:12 +0200 Subject: Cleanup: variable naming --- source/blender/blenlib/BLI_bitmap_draw_2d.h | 6 +++--- source/blender/blenlib/intern/bitmap_draw_2d.c | 20 ++++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenlib/BLI_bitmap_draw_2d.h b/source/blender/blenlib/BLI_bitmap_draw_2d.h index e41439e38d2..7036196425a 100644 --- a/source/blender/blenlib/BLI_bitmap_draw_2d.h +++ b/source/blender/blenlib/BLI_bitmap_draw_2d.h @@ -27,7 +27,7 @@ void BLI_bitmap_draw_2d_line_v2v2i( const int p1[2], const int p2[2], - bool (*callback)(int, int, void *), void *userData); + bool (*callback)(int, int, void *), void *user_data); void BLI_bitmap_draw_2d_tri_v2i( const int p1[2], const int p2[2], const int p3[2], @@ -35,7 +35,7 @@ void BLI_bitmap_draw_2d_tri_v2i( void BLI_bitmap_draw_2d_poly_v2i_n( const int xmin, const int ymin, const int xmax, const int ymax, - const int polyXY[][2], const int polyCorners, - void (*callback)(int x, int x_end, int y, void *), void *userData); + const int verts[][2], const int verts_len, + void (*callback)(int x, int x_end, int y, void *), void *user_data); #endif /* __BLI_BITMAP_DRAW_2D_H__ */ diff --git a/source/blender/blenlib/intern/bitmap_draw_2d.c b/source/blender/blenlib/intern/bitmap_draw_2d.c index c6386cb3080..ff62d78796b 100644 --- a/source/blender/blenlib/intern/bitmap_draw_2d.c +++ b/source/blender/blenlib/intern/bitmap_draw_2d.c @@ -52,7 +52,7 @@ */ void BLI_bitmap_draw_2d_line_v2v2i( const int p1[2], const int p2[2], - bool (*callback)(int, int, void *), void *userData) + bool (*callback)(int, int, void *), void *user_data) { /* Bresenham's line algorithm. */ int x1 = p1[0]; @@ -60,7 +60,7 @@ void BLI_bitmap_draw_2d_line_v2v2i( int x2 = p2[0]; int y2 = p2[1]; - if (callback(x1, y1, userData) == 0) { + if (callback(x1, y1, user_data) == 0) { return; } @@ -91,7 +91,7 @@ void BLI_bitmap_draw_2d_line_v2v2i( x1 += sign_x; error += delta_y_step; - if (callback(x1, y1, userData) == 0) { + if (callback(x1, y1, user_data) == 0) { return; } } @@ -113,7 +113,7 @@ void BLI_bitmap_draw_2d_line_v2v2i( y1 += sign_y; error += delta_x_step; - if (callback(x1, y1, userData) == 0) { + if (callback(x1, y1, user_data) == 0) { return; } } @@ -353,16 +353,16 @@ static int draw_poly_v2i_n__span_y_sort(const void *a_p, const void *b_p, void * */ void BLI_bitmap_draw_2d_poly_v2i_n( const int xmin, const int ymin, const int xmax, const int ymax, - const int verts[][2], const int nr, - void (*callback)(int x, int x_end, int y, void *), void *userData) + const int verts[][2], const int verts_len, + void (*callback)(int x, int x_end, int y, void *), void *user_data) { /* Originally by Darel Rex Finley, 2007. * Optimized by Campbell Barton, 2016 to track sorted intersections. */ - int (*span_y)[2] = MEM_mallocN(sizeof(*span_y) * (size_t)nr, __func__); + int (*span_y)[2] = MEM_mallocN(sizeof(*span_y) * (size_t)verts_len, __func__); int span_y_len = 0; - for (int i_curr = 0, i_prev = nr - 1; i_curr < nr; i_prev = i_curr++) { + for (int i_curr = 0, i_prev = verts_len - 1; i_curr < verts_len; i_prev = i_curr++) { const int *co_prev = verts[i_prev]; const int *co_curr = verts[i_curr]; @@ -391,7 +391,7 @@ void BLI_bitmap_draw_2d_poly_v2i_n( struct NodeX { int span_y_index; int x; - } *node_x = MEM_mallocN(sizeof(*node_x) * (size_t)(nr + 1), __func__); + } *node_x = MEM_mallocN(sizeof(*node_x) * (size_t)(verts_len + 1), __func__); int node_x_len = 0; int span_y_index = 0; @@ -472,7 +472,7 @@ void BLI_bitmap_draw_2d_poly_v2i_n( } /* for single call per x-span */ if (x_src < x_dst) { - callback(x_src - xmin, x_dst - xmin, pixel_y - ymin, userData); + callback(x_src - xmin, x_dst - xmin, pixel_y - ymin, user_data); } } } -- cgit v1.2.3 From 420e379e99a3351b2dd2a46989aa1d50bdf8abef Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 22 Apr 2018 10:49:45 +0200 Subject: Cleanup: de-dup popup/pie menu RNA definition Also rename pupmenu -> popmenu --- source/blender/makesrna/intern/rna_wm.c | 34 +++++++++++------------------ source/blender/makesrna/intern/rna_wm_api.c | 8 +++---- 2 files changed, 17 insertions(+), 25 deletions(-) (limited to 'source/blender') diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index 265758eb5c3..b71eca3d850 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -1830,44 +1830,36 @@ static void rna_def_timer(BlenderRNA *brna) RNA_define_verify_sdna(1); /* not in sdna */ } -static void rna_def_popupmenu(BlenderRNA *brna) +static void rna_def_popup_menu_wrapper( + BlenderRNA *brna, const char *rna_type, const char *c_type, const char *layout_get_fn) { StructRNA *srna; PropertyRNA *prop; - srna = RNA_def_struct(brna, "UIPopupMenu", NULL); - RNA_def_struct_ui_text(srna, "PopupMenu", ""); - RNA_def_struct_sdna(srna, "uiPopupMenu"); + srna = RNA_def_struct(brna, rna_type, NULL); + /* UI name isn't visible, name same as type. */ + RNA_def_struct_ui_text(srna, rna_type, ""); + RNA_def_struct_sdna(srna, c_type); RNA_define_verify_sdna(0); /* not in sdna */ /* could wrap more, for now this is enough */ prop = RNA_def_property(srna, "layout", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "UILayout"); - RNA_def_property_pointer_funcs(prop, "rna_PopupMenu_layout_get", + RNA_def_property_pointer_funcs(prop, layout_get_fn, NULL, NULL, NULL); RNA_define_verify_sdna(1); /* not in sdna */ } -static void rna_def_piemenu(BlenderRNA *brna) +static void rna_def_popupmenu(BlenderRNA *brna) { - StructRNA *srna; - PropertyRNA *prop; - - srna = RNA_def_struct(brna, "UIPieMenu", NULL); - RNA_def_struct_ui_text(srna, "PieMenu", ""); - RNA_def_struct_sdna(srna, "uiPieMenu"); - - RNA_define_verify_sdna(0); /* not in sdna */ - - /* could wrap more, for now this is enough */ - prop = RNA_def_property(srna, "layout", PROP_POINTER, PROP_NONE); - RNA_def_property_struct_type(prop, "UILayout"); - RNA_def_property_pointer_funcs(prop, "rna_PieMenu_layout_get", - NULL, NULL, NULL); + rna_def_popup_menu_wrapper(brna, "UIPopupMenu", "uiPopupMenu", "rna_PopupMenu_layout_get"); +} - RNA_define_verify_sdna(1); /* not in sdna */ +static void rna_def_piemenu(BlenderRNA *brna) +{ + rna_def_popup_menu_wrapper(brna, "UIPieMenu", "uiPieMenu", "rna_PieMenu_layout_get"); } static void rna_def_window_stereo3d(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_wm_api.c b/source/blender/makesrna/intern/rna_wm_api.c index cbbe50ccf03..d2cd72b2f1e 100644 --- a/source/blender/makesrna/intern/rna_wm_api.c +++ b/source/blender/makesrna/intern/rna_wm_api.c @@ -298,7 +298,7 @@ static void rna_KeyConfig_remove(wmWindowManager *wm, ReportList *reports, Point } /* popup menu wrapper */ -static PointerRNA rna_PupMenuBegin(bContext *C, const char *title, int icon) +static PointerRNA rna_PopMenuBegin(bContext *C, const char *title, int icon) { PointerRNA r_ptr; void *data; @@ -310,7 +310,7 @@ static PointerRNA rna_PupMenuBegin(bContext *C, const char *title, int icon) return r_ptr; } -static void rna_PupMenuEnd(bContext *C, PointerRNA *handle) +static void rna_PopMenuEnd(bContext *C, PointerRNA *handle) { UI_popup_menu_end(C, handle->data); } @@ -479,7 +479,7 @@ void RNA_api_wm(StructRNA *srna) /* wrap UI_popup_menu_begin */ - func = RNA_def_function(srna, "pupmenu_begin__internal", "rna_PupMenuBegin"); + func = RNA_def_function(srna, "popmenu_begin__internal", "rna_PopMenuBegin"); RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_USE_CONTEXT); parm = RNA_def_string(func, "title", NULL, 0, "", ""); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); @@ -491,7 +491,7 @@ void RNA_api_wm(StructRNA *srna) RNA_def_function_return(func, parm); /* wrap UI_popup_menu_end */ - func = RNA_def_function(srna, "pupmenu_end__internal", "rna_PupMenuEnd"); + func = RNA_def_function(srna, "popmenu_end__internal", "rna_PopMenuEnd"); RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_USE_CONTEXT); parm = RNA_def_pointer(func, "menu", "UIPopupMenu", "", ""); RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_RNAPTR); -- cgit v1.2.3