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>2018-11-05 05:04:43 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-11-05 05:04:43 +0300
commit9361c1c83d87429b0aa8755418509ca9ec75e775 (patch)
tree29ef43a694e937c3965c63593e0f126d35a9b1a7 /source/blender/editors
parent7c5d01466604bd15617a2693f5efc711ada8b083 (diff)
UI: Add back line to curve map
D3894 by @charlie with edits
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/interface/interface_draw.c81
1 files changed, 49 insertions, 32 deletions
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);
}