Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2014-06-22 09:01:54 +0400
committerCampbell Barton <ideasman42@gmail.com>2014-06-22 09:01:54 +0400
commit27624320526540094b6f635215e36de8092ec94f (patch)
tree056df47018bac230ae40fa8b8b598437c18de84d /source/blender/editors/interface
parentf69d5cc4b84ef3a87a56d23e6228f72feb6e2fb0 (diff)
Code cleanup: de-duplicate widget_num_tria, widget_scroll_circle
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r--source/blender/editors/interface/interface_widgets.c67
1 files changed, 26 insertions, 41 deletions
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index 2bd473874b1..6ea0a55729d 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -477,13 +477,17 @@ static void round_box_edges(uiWidgetBase *wt, int roundboxalign, const rcti *rec
/* based on button rect, return scaled array of triangles */
-static void widget_num_tria(uiWidgetTrias *tria, const rcti *rect, float triasize, char where)
+static void widget_draw_tria_ex(
+ uiWidgetTrias *tria, const rcti *rect, float triasize, char where,
+ /* input data */
+ const float verts[][2], const int verts_tot,
+ const unsigned int tris[][3], const int tris_tot)
{
float centx, centy, sizex, sizey, minsize;
int a, i1 = 0, i2 = 1;
-
+
minsize = min_ii(BLI_rcti_size_x(rect), BLI_rcti_size_y(rect));
-
+
/* center position and size */
centx = (float)rect->xmin + 0.5f * minsize;
centy = (float)rect->ymin + 0.5f * minsize;
@@ -502,49 +506,30 @@ static void widget_num_tria(uiWidgetTrias *tria, const rcti *rect, float triasiz
sizex = -sizex;
i2 = 0; i1 = 1;
}
-
- for (a = 0; a < 3; a++) {
- tria->vec[a][0] = sizex * num_tria_vert[a][i1] + centx;
- tria->vec[a][1] = sizey * num_tria_vert[a][i2] + centy;
+
+ for (a = 0; a < verts_tot; a++) {
+ tria->vec[a][0] = sizex * verts[a][i1] + centx;
+ tria->vec[a][1] = sizey * verts[a][i2] + centy;
}
-
- tria->tot = 1;
- tria->index = num_tria_face;
+
+ tria->tot = tris_tot;
+ tria->index = tris;
}
-static void widget_scroll_circle(uiWidgetTrias *tria, const rcti *rect, float triasize, char where)
+static void widget_num_tria(uiWidgetTrias *tria, const rcti *rect, float triasize, char where)
{
- float centx, centy, sizex, sizey, minsize;
- int a, i1 = 0, i2 = 1;
-
- minsize = min_ii(BLI_rcti_size_x(rect), BLI_rcti_size_y(rect));
-
- /* center position and size */
- centx = (float)rect->xmin + 0.5f * minsize;
- centy = (float)rect->ymin + 0.5f * minsize;
- sizex = sizey = -0.5f * triasize * minsize;
+ widget_draw_tria_ex(
+ tria, rect, triasize, where,
+ num_tria_vert, ARRAY_SIZE(num_tria_vert),
+ num_tria_face, ARRAY_SIZE(num_tria_face));
+}
- if (where == 'r') {
- centx = (float)rect->xmax - 0.5f * minsize;
- sizex = -sizex;
- }
- else if (where == 't') {
- centy = (float)rect->ymax - 0.5f * minsize;
- sizey = -sizey;
- i2 = 0; i1 = 1;
- }
- else if (where == 'b') {
- sizex = -sizex;
- i2 = 0; i1 = 1;
- }
-
- for (a = 0; a < 16; a++) {
- tria->vec[a][0] = sizex * scroll_circle_vert[a][i1] + centx;
- tria->vec[a][1] = sizey * scroll_circle_vert[a][i2] + centy;
- }
-
- tria->tot = 14;
- tria->index = scroll_circle_face;
+static void widget_scroll_circle(uiWidgetTrias *tria, const rcti *rect, float triasize, char where)
+{
+ widget_draw_tria_ex(
+ tria, rect, triasize, where,
+ scroll_circle_vert, ARRAY_SIZE(scroll_circle_vert),
+ scroll_circle_face, ARRAY_SIZE(scroll_circle_face));
}
static void widget_trias_draw(uiWidgetTrias *tria)