From ee4160544662c298102f2f7183ba5d3520da63ad Mon Sep 17 00:00:00 2001 From: Ander Conselvan de Oliveira Date: Thu, 21 Feb 2013 18:35:17 +0200 Subject: [PATCH] animation: Make fade more controllable Add parameters to weston_fade_run() for setting the initial and target values for the fade, as well as a parameter to set the spring constant used for the animation. Also add the weston_fade_update() function, that allows the animation to be changed while it is still running. This will be used to move the fade animation from core Weston into the shell. These changes are needed to be able to fade out as well as in, and to be able to reverse the fade in case of user input. --- src/animation.c | 17 ++++++++++++++++- src/compositor.h | 5 +++++ src/shell.c | 2 +- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/animation.c b/src/animation.c index d141b373..147a5c03 100644 --- a/src/animation.c +++ b/src/animation.c @@ -239,10 +239,25 @@ fade_frame(struct weston_surface_animation *animation) WL_EXPORT struct weston_surface_animation * weston_fade_run(struct weston_surface *surface, + float start, float end, float k, weston_surface_animation_done_func_t done, void *data) { - return weston_surface_animation_run(surface, 0, 0, + struct weston_surface_animation *fade; + + fade = weston_surface_animation_run(surface, 0, 0, fade_frame, done, data); + + weston_spring_init(&fade->spring, k, start, end); + surface->alpha = start; + + return fade; +} + +WL_EXPORT void +weston_fade_update(struct weston_surface_animation *fade, + float start, float end, float k) +{ + weston_spring_init(&fade->spring, k, start, end); } static void diff --git a/src/compositor.h b/src/compositor.h index a45fdf67..7cd6a6b6 100644 --- a/src/compositor.h +++ b/src/compositor.h @@ -820,7 +820,12 @@ weston_zoom_run(struct weston_surface *surface, float start, float stop, struct weston_surface_animation * weston_fade_run(struct weston_surface *surface, + float start, float end, float k, weston_surface_animation_done_func_t done, void *data); +void +weston_fade_update(struct weston_surface_animation *fade, + float start, float end, float k); + struct weston_surface_animation * weston_slide_run(struct weston_surface *surface, float start, float stop, weston_surface_animation_done_func_t done, void *data); diff --git a/src/shell.c b/src/shell.c index a4511fd4..da17cfbd 100644 --- a/src/shell.c +++ b/src/shell.c @@ -3026,7 +3026,7 @@ map(struct desktop_shell *shell, struct weston_surface *surface, { switch (shell->win_animation_type) { case ANIMATION_FADE: - weston_fade_run(surface, NULL, NULL); + weston_fade_run(surface, 0.0, 1.0, 200.0, NULL, NULL); break; case ANIMATION_ZOOM: weston_zoom_run(surface, 0.8, 1.0, NULL, NULL);