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:
Diffstat (limited to 'source/blender/windowmanager/intern/wm_gesture.c')
-rw-r--r--source/blender/windowmanager/intern/wm_gesture.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/source/blender/windowmanager/intern/wm_gesture.c b/source/blender/windowmanager/intern/wm_gesture.c
index b245bbe054d..6d36000abb4 100644
--- a/source/blender/windowmanager/intern/wm_gesture.c
+++ b/source/blender/windowmanager/intern/wm_gesture.c
@@ -199,10 +199,61 @@ int wm_gesture_evaluate(wmGesture *gesture, const wmEvent *event)
/* ******************* gesture draw ******************* */
+static void wm_gesture_draw_line_active_side(rcti *rect)
+{
+ GPUVertFormat *format = immVertexFormat();
+ uint shdr_pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ uint shdr_col = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
+
+ GPU_blend(GPU_BLEND_ALPHA);
+ immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR);
+
+ const float gradient_length = 150.0f * U.pixelsize;
+ float line_dir[2];
+ float gradient_dir[2];
+ float gradient_point[2][2];
+
+ const float line_start[2] = {rect->xmin, rect->ymin};
+ const float line_end[2] = {rect->xmax, rect->ymax};
+ const float color_line_gradient_start[4] = {0.2f, 0.2f, 0.2f, 0.4f};
+ const float color_line_gradient_end[4] = {0.0f, 0.0f, 0.0f, 0.0f};
+
+ sub_v2_v2v2(line_dir, line_end, line_start);
+ normalize_v2(line_dir);
+ ortho_v2_v2(gradient_dir, line_dir);
+ mul_v2_fl(gradient_dir, -1.0f);
+ mul_v2_fl(gradient_dir, gradient_length);
+ add_v2_v2v2(gradient_point[0], line_start, gradient_dir);
+ add_v2_v2v2(gradient_point[1], line_end, gradient_dir);
+
+ immBegin(GPU_PRIM_TRIS, 6);
+ immAttr4f(shdr_col, UNPACK4(color_line_gradient_start));
+ immVertex2f(shdr_pos, line_start[0], line_start[1]);
+ immAttr4f(shdr_col, UNPACK4(color_line_gradient_start));
+ immVertex2f(shdr_pos, line_end[0], line_end[1]);
+ immAttr4f(shdr_col, UNPACK4(color_line_gradient_end));
+ immVertex2f(shdr_pos, gradient_point[1][0], gradient_point[1][1]);
+
+ immAttr4f(shdr_col, UNPACK4(color_line_gradient_start));
+ immVertex2f(shdr_pos, line_start[0], line_start[1]);
+ immAttr4f(shdr_col, UNPACK4(color_line_gradient_end));
+ immVertex2f(shdr_pos, gradient_point[1][0], gradient_point[1][1]);
+ immAttr4f(shdr_col, UNPACK4(color_line_gradient_end));
+ immVertex2f(shdr_pos, gradient_point[0][0], gradient_point[0][1]);
+ immEnd();
+
+ immUnbindProgram();
+ GPU_blend(GPU_BLEND_NONE);
+}
+
static void wm_gesture_draw_line(wmGesture *gt)
{
rcti *rect = (rcti *)gt->customdata;
+ if (gt->draw_active_side) {
+ wm_gesture_draw_line_active_side(rect);
+ }
+
uint shdr_pos = GPU_vertformat_attr_add(
immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);