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.
This commit is contained in:
parent
cbdebc2370
commit
ee41605446
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user