}
WL_EXPORT void
-wlsc_tweener_init(struct wlsc_tweener *tweener,
- double k, double current, double target)
+wlsc_spring_init(struct wlsc_spring *spring,
+ double k, double current, double target)
{
- tweener->k = k;
- tweener->friction = 100.0;
- tweener->current = current;
- tweener->previous = current;
- tweener->target = target;
+ spring->k = k;
+ spring->friction = 100.0;
+ spring->current = current;
+ spring->previous = current;
+ spring->target = target;
}
WL_EXPORT void
-wlsc_tweener_update(struct wlsc_tweener *tweener, uint32_t msec)
+wlsc_spring_update(struct wlsc_spring *spring, uint32_t msec)
{
double force, v, current, step;
- step = (msec - tweener->timestamp) / 500.0;
- tweener->timestamp = msec;
+ step = (msec - spring->timestamp) / 500.0;
+ spring->timestamp = msec;
- current = tweener->current;
- v = current - tweener->previous;
- force = tweener->k * (tweener->target - current) / 10.0 +
- (tweener->previous - current) - v * tweener->friction;
+ current = spring->current;
+ v = current - spring->previous;
+ force = spring->k * (spring->target - current) / 10.0 +
+ (spring->previous - current) - v * spring->friction;
- tweener->current =
- current + (current - tweener->previous) + force * step * step;
- tweener->previous = current;
+ spring->current =
+ current + (current - spring->previous) + force * step * step;
+ spring->previous = current;
- if (tweener->current >= 1.0) {
+ if (spring->current >= 1.0) {
#ifdef TWEENER_BOUNCE
- tweener->current = 2.0 - tweener->current;
- tweener->previous = 2.0 - tweener->previous;
+ spring->current = 2.0 - spring->current;
+ spring->previous = 2.0 - spring->previous;
#else
- tweener->current = 1.0;
- tweener->previous = 1.0;
+ spring->current = 1.0;
+ spring->previous = 1.0;
#endif
}
- if (tweener->current <= 0.0) {
- tweener->current = 0.0;
- tweener->previous = 0.0;
+ if (spring->current <= 0.0) {
+ spring->current = 0.0;
+ spring->previous = 0.0;
}
}
WL_EXPORT int
-wlsc_tweener_done(struct wlsc_tweener *tweener)
+wlsc_spring_done(struct wlsc_spring *spring)
{
- return fabs(tweener->previous - tweener->target) < 0.0002 &&
- fabs(tweener->current - tweener->target) < 0.0002;
+ return fabs(spring->previous - spring->target) < 0.0002 &&
+ fabs(spring->current - spring->target) < 0.0002;
}
WL_EXPORT struct wlsc_surface *
container_of(animation,
struct wlsc_compositor, fade.animation);
- wlsc_tweener_update(&compositor->fade.tweener, msecs);
- if (wlsc_tweener_done(&compositor->fade.tweener)) {
- if (compositor->fade.tweener.current > 0.999) {
+ wlsc_spring_update(&compositor->fade.spring, msecs);
+ if (wlsc_spring_done(&compositor->fade.spring)) {
+ if (compositor->fade.spring.current > 0.999) {
compositor->state = WLSC_COMPOSITOR_SLEEPING;
compositor->shell->lock(compositor->shell);
}
- compositor->fade.tweener.current =
- compositor->fade.tweener.target;
+ compositor->fade.spring.current =
+ compositor->fade.spring.target;
wl_list_remove(&animation->link);
wl_list_init(&animation->link);
}
if (ec->focus)
if (output->set_hardware_cursor(output, ec->input_device) < 0)
using_hardware_cursor = 0;
- if (ec->fade.tweener.current > 0.001)
+ if (ec->fade.spring.current > 0.001)
using_hardware_cursor = 0;
es = container_of(ec->surface_list.next, struct wlsc_surface, link);
&total_damage);
}
- if (ec->fade.tweener.current > 0.001)
- fade_output(output, ec->fade.tweener.current, &total_damage);
+ if (ec->fade.spring.current > 0.001)
+ fade_output(output, ec->fade.spring.current, &total_damage);
}
static int
{
int done;
- done = wlsc_tweener_done(&compositor->fade.tweener);
- compositor->fade.tweener.target = tint;
- if (wlsc_tweener_done(&compositor->fade.tweener))
+ done = wlsc_spring_done(&compositor->fade.spring);
+ compositor->fade.spring.target = tint;
+ if (wlsc_spring_done(&compositor->fade.spring))
return;
if (done)
- compositor->fade.tweener.timestamp =
+ compositor->fade.spring.timestamp =
wlsc_compositor_get_time();
wlsc_compositor_damage_all(compositor);
wl_list_init(&ec->output_list);
wl_list_init(&ec->binding_list);
wl_list_init(&ec->animation_list);
- wlsc_tweener_init(&ec->fade.tweener, 0.8, 0.0, 0.0);
+ wlsc_spring_init(&ec->fade.spring, 0.8, 0.0, 0.0);
ec->fade.animation.frame = fade_frame;
wl_list_init(&ec->fade.animation.link);
struct meego_tablet_zoom {
struct wlsc_surface *surface;
struct wlsc_animation animation;
- struct wlsc_tweener tweener;
+ struct wlsc_spring spring;
struct wlsc_transform transform;
};
struct wlsc_surface *es = zoom->surface;
GLfloat scale;
- wlsc_tweener_update(&zoom->tweener, msecs);
+ wlsc_spring_update(&zoom->spring, msecs);
- if (wlsc_tweener_done(&zoom->tweener)) {
+ if (wlsc_spring_done(&zoom->spring)) {
wl_list_remove(&animation->link);
fprintf(stderr, "animation done\n");
es->transform = NULL;
free(zoom);
}
- scale = zoom->tweener.current;
+ scale = zoom->spring.current;
wlsc_matrix_init(&zoom->transform.matrix);
wlsc_matrix_translate(&zoom->transform.matrix,
-es->width / 2.0, -es->height / 2.0, 0);
wlsc_matrix_translate(&zoom->transform.matrix,
es->width / 2.0, es->height / 2.0, 0);
- scale = 1.0 / zoom->tweener.current;
+ scale = 1.0 / zoom->spring.current;
wlsc_matrix_init(&zoom->transform.inverse);
wlsc_matrix_scale(&zoom->transform.inverse, scale, scale, scale);
zoom->surface = surface;
surface->transform = &zoom->transform;
scale = 0.3;
- wlsc_tweener_init(&zoom->tweener, 100.0, scale, 1.0);
- zoom->tweener.timestamp = wlsc_compositor_get_time();
+ wlsc_spring_init(&zoom->spring, 100.0, scale, 1.0);
+ zoom->spring.timestamp = wlsc_compositor_get_time();
zoom->animation.frame = meego_tablet_zoom_frame;
meego_tablet_zoom_frame(&zoom->animation, NULL,
- zoom->tweener.timestamp);
+ zoom->spring.timestamp);
wl_list_insert(shell->compositor->animation_list.prev,
&zoom->animation.link);
launch_switcher(shell);
- wlsc_tweener_init(&compositor->fade.tweener, 40.0, 1.0, 1.0);
+ wlsc_spring_init(&compositor->fade.spring, 40.0, 1.0, 1.0);
shell->starting = 1;
}