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:
authorClément Foucault <foucault.clem@gmail.com>2018-11-09 17:33:51 +0300
committerClément Foucault <foucault.clem@gmail.com>2018-11-09 17:35:31 +0300
commit8bf5af7bd3cec04e0076ae3ed0cd0a988393f26a (patch)
tree0bf7605775c622ee4941fa20e354e4c18406cabf
parent36e6a41f6f76b7a670f0ed0d59a9a1f73832a216 (diff)
UI: Make Region overlap slide instead of fade
Requested by @billreynish. Increases the TIMESTEP to 60Hz to have smooth animation.
-rw-r--r--source/blender/editors/screen/screen_ops.c2
-rw-r--r--source/blender/windowmanager/intern/wm_draw.c30
2 files changed, 29 insertions, 3 deletions
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index 53a878bd655..9c7e18b0889 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -4512,7 +4512,7 @@ typedef struct RegionAlphaInfo {
} RegionAlphaInfo;
#define TIMEOUT 0.1f
-#define TIMESTEP 0.05f
+#define TIMESTEP (1.0f / 60.0f)
float ED_region_blend_alpha(ARegion *ar)
{
diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c
index c8e0360ed88..d760780beb8 100644
--- a/source/blender/windowmanager/intern/wm_draw.c
+++ b/source/blender/windowmanager/intern/wm_draw.c
@@ -461,9 +461,35 @@ void wm_draw_region_blend(ARegion *ar, int view, bool blend)
GPUShader *shader = GPU_shader_get_builtin_shader(GPU_SHADER_2D_IMAGE_RECT_COLOR);
GPU_shader_bind(shader);
+ rcti rect_geo = ar->winrct;
+ rect_geo.xmax += 1;
+ rect_geo.ymax += 1;
+
+ rctf rect_tex;
+ rect_tex.xmin = halfx;
+ rect_tex.ymin = halfy;
+ rect_tex.xmax = 1.0f + halfx;
+ rect_tex.ymax = 1.0f + halfy;
+
+ float alpha_easing = 1.0f - alpha;
+ alpha_easing = 1.0f - alpha_easing * alpha_easing;
+
+ /* Slide vertical panels */
+ float ofs_x = BLI_rcti_size_x(&ar->winrct) * (1.0f - alpha_easing);
+ if (ar->alignment == RGN_ALIGN_RIGHT) {
+ rect_geo.xmin += ofs_x;
+ rect_tex.xmax *= alpha_easing;
+ alpha = 1.0f;
+ }
+ else if (ar->alignment == RGN_ALIGN_LEFT) {
+ rect_geo.xmax -= ofs_x;
+ rect_tex.xmin += 1.0f - alpha_easing;
+ alpha = 1.0f;
+ }
+
glUniform1i(GPU_shader_get_uniform(shader, "image"), 0);
- glUniform4f(GPU_shader_get_uniform(shader, "rect_icon"), halfx, halfy, 1.0f + halfx, 1.0f + halfy);
- glUniform4f(GPU_shader_get_uniform(shader, "rect_geom"), ar->winrct.xmin, ar->winrct.ymin, ar->winrct.xmax + 1, ar->winrct.ymax + 1);
+ glUniform4f(GPU_shader_get_uniform(shader, "rect_icon"), rect_tex.xmin, rect_tex.ymin, rect_tex.xmax, rect_tex.ymax);
+ glUniform4f(GPU_shader_get_uniform(shader, "rect_geom"), rect_geo.xmin, rect_geo.ymin, rect_geo.xmax, rect_geo.ymax);
glUniform4f(GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_COLOR), alpha, alpha, alpha, alpha);
GPU_draw_primitive(GPU_PRIM_TRI_STRIP, 4);