[Bf-blender-cvs] [9361c1c83d8] blender2.8: UI: Add back line to curve map

Campbell Barton noreply at git.blender.org
Mon Nov 5 03:07:44 CET 2018


Commit: 9361c1c83d87429b0aa8755418509ca9ec75e775
Author: Campbell Barton
Date:   Mon Nov 5 13:04:43 2018 +1100
Branches: blender2.8
https://developer.blender.org/rB9361c1c83d87429b0aa8755418509ca9ec75e775

UI: Add back line to curve map

D3894 by @charlie with edits

===================================================================

M	source/blender/editors/interface/interface_draw.c

===================================================================

diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c
index 68058292c44..48526d35510 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -1767,56 +1767,73 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti
 	}
 	immUnbindProgram();
 
-	/* the curve */
-	immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
-	immUniformColor3ubvAlpha((unsigned char *)wcol->item, 128);
-	GPU_blend(true);
-	GPU_polygon_smooth(true);
-	immBegin(GPU_PRIM_TRI_STRIP, (CM_TABLE * 2 + 2) + 4);
+
 
 	if (cuma->table == NULL)
 		curvemapping_changed(cumap, false);
 
 	CurveMapPoint *cmp = cuma->table;
+	rctf line_range;
 
-	float fx, fy;
-
-	/* first point */
+	/* First curve point. */
 	if ((cuma->flag & CUMA_EXTEND_EXTRAPOLATE) == 0) {
-		fx = rect->xmin;
-		fy = rect->ymin + zoomy * (cmp[0].y - offsy);
+		line_range.xmin = rect->xmin;
+		line_range.ymin = rect->ymin + zoomy * (cmp[0].y - offsy);
 	}
 	else {
-		fx = rect->xmin + zoomx * (cmp[0].x - offsx + cuma->ext_in[0]);
-		fy = rect->ymin + zoomy * (cmp[0].y - offsy + cuma->ext_in[1]);
+		line_range.xmin = rect->xmin + zoomx * (cmp[0].x - offsx + cuma->ext_in[0]);
+		line_range.ymin = rect->ymin + zoomy * (cmp[0].y - offsy + cuma->ext_in[1]);
 	}
-	immVertex2f(pos, fx, rect->ymin);
-	immVertex2f(pos, fx, fy);
-	/* curve */
-	for (int a = 0; a <= CM_TABLE; a++) {
-		fx = rect->xmin + zoomx * (cmp[a].x - offsx);
-		fy = rect->ymin + zoomy * (cmp[a].y - offsy);
-		immVertex2f(pos, fx, rect->ymin);
-		immVertex2f(pos, fx, fy);
-	}
-	/* last point */
+	/* Last curve point. */
 	if ((cuma->flag & CUMA_EXTEND_EXTRAPOLATE) == 0) {
-		fx = rect->xmax;
-		fy = rect->ymin + zoomy * (cmp[CM_TABLE].y - offsy);
+		line_range.xmax = rect->xmax;
+		line_range.ymax = rect->ymin + zoomy * (cmp[CM_TABLE].y - offsy);
 	}
 	else {
-		fx = rect->xmin + zoomx * (cmp[CM_TABLE].x - offsx - cuma->ext_out[0]);
-		fy = rect->ymin + zoomy * (cmp[CM_TABLE].y - offsy - cuma->ext_out[1]);
+		line_range.xmax = rect->xmin + zoomx * (cmp[CM_TABLE].x - offsx - cuma->ext_out[0]);
+		line_range.ymax = rect->ymin + zoomy * (cmp[CM_TABLE].y - offsy - cuma->ext_out[1]);
 	}
-	immVertex2f(pos, fx, rect->ymin);
-	immVertex2f(pos, fx, fy);
 
+	immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
+	GPU_blend(true);
+
+	/* Curve filled. */
+	immUniformColor3ubvAlpha((unsigned char *)wcol->item, 128);
+	GPU_polygon_smooth(true);
+	immBegin(GPU_PRIM_TRI_STRIP, (CM_TABLE * 2 + 2) + 4);
+	immVertex2f(pos, line_range.xmin, rect->ymin);
+	immVertex2f(pos, line_range.xmin, line_range.ymin);
+	for (int a = 0; a <= CM_TABLE; a++) {
+		float fx = rect->xmin + zoomx * (cmp[a].x - offsx);
+		float fy = rect->ymin + zoomy * (cmp[a].y - offsy);
+		immVertex2f(pos, fx, rect->ymin);
+		immVertex2f(pos, fx, fy);
+	}
+	immVertex2f(pos, line_range.xmax, rect->ymin);
+	immVertex2f(pos, line_range.xmax, rect->ymax);
 	immEnd();
 	GPU_polygon_smooth(false);
+
+	/* Curve line. */
+	GPU_line_width(1.0f);
+	immUniformColor3ubvAlpha((unsigned char *)wcol->item, 255);
+	GPU_line_smooth(true);
+	immBegin(GPU_PRIM_LINE_STRIP, (CM_TABLE + 1) + 2);
+	immVertex2f(pos, line_range.xmin, line_range.ymin);
+	for (int a = 0; a <= CM_TABLE; a++) {
+		float fx = rect->xmin + zoomx * (cmp[a].x - offsx);
+		float fy = rect->ymin + zoomy * (cmp[a].y - offsy);
+		immVertex2f(pos, fx, fy);
+	}
+	immVertex2f(pos, line_range.xmax, line_range.ymax);
+	immEnd();
+
+	/* Reset state for fill & line. */
+	GPU_line_smooth(false);
 	GPU_blend(false);
 	immUnbindProgram();
 
-	/* the points, use aspect to make them visible on edges */
+	/* The points, use aspect to make them visible on edges. */
 	format = immVertexFormat();
 	pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
 	uint col = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
@@ -1831,8 +1848,8 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti
 			UI_GetThemeColor4fv(TH_TEXT_HI, color);
 		else
 			UI_GetThemeColor4fv(TH_TEXT, color);
-		fx = rect->xmin + zoomx * (cmp[a].x - offsx);
-		fy = rect->ymin + zoomy * (cmp[a].y - offsy);
+		float fx = rect->xmin + zoomx * (cmp[a].x - offsx);
+		float fy = rect->ymin + zoomy * (cmp[a].y - offsy);
 		immAttr4fv(col, color);
 		immVertex2f(pos, fx, fy);
 	}



More information about the Bf-blender-cvs mailing list