From ffb7406eaa955e104ab9993a4d923152ce205d31 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Kristian=20H=C3=B8gsberg?= Date: Tue, 25 Nov 2008 18:10:39 -0500 Subject: [PATCH] Add different type of overlay animation. --- egl-compositor.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/egl-compositor.c b/egl-compositor.c index 8fd7324..4471753 100644 --- a/egl-compositor.c +++ b/egl-compositor.c @@ -478,10 +478,19 @@ animate_overlay(struct egl_compositor *ec) { double force, y; int32_t top, bottom; +#if 1 + double bounce = 0.0; + double friction = 1.0; + double spring = 0.2; +#else + double bounce = 0.2; + double friction = 0.04; + double spring = 0.09; +#endif y = ec->overlay_y; - force = (ec->overlay_target - ec->overlay_y) / 5.0 + - (ec->overlay_previous - y); + force = (ec->overlay_target - ec->overlay_y) * spring + + (ec->overlay_previous - y) * friction; ec->overlay_y = y + (y - ec->overlay_previous) + force; ec->overlay_previous = y; @@ -494,12 +503,15 @@ animate_overlay(struct egl_compositor *ec) } if (ec->overlay_y <= top) { - ec->overlay_y = top; - ec->overlay_previous = top; + ec->overlay_y = top + bounce * (top - ec->overlay_y); + ec->overlay_previous = + top + bounce * (top - ec->overlay_previous); } ec->overlay->map.y = ec->overlay_y + 0.5; - if ((int) (y + 0.5) != ec->overlay_target) + + if (fabs(y + 0.5 - ec->overlay_target) > 0.2 || + fabs(ec->overlay_y + 5 - ec->overlay_target) > 0.2) schedule_repaint(ec); } -- 2.7.4