menu_view: midway re-targeting of geometry motion

This patch fixes the corner case where an animated geometry changes its
destination mid-way while an animation is already in progress. The
'_trigger_animated_geometry' method used to back out early in this case,
which was intended as an optimization.

Fixes #3296
This commit is contained in:
Norman Feske 2019-04-18 13:17:53 +02:00 committed by Christian Helmuth
parent 3f8dfa346c
commit c38c80fd43
2 changed files with 11 additions and 3 deletions

View File

@ -64,6 +64,8 @@ class Genode::Animated_rect : private Animator::Item, Noncopyable
Animated_point _p1 { }, _p2 { };
Steps _remaining { 0 };
public:
Animated_rect(Animator &animator) : Animator::Item(animator) { }
@ -77,6 +79,9 @@ class Genode::Animated_rect : private Animator::Item, Noncopyable
_rect = Rect(Point(_p1.x(), _p1.y()), Point(_p2.x(), _p2.y()));
if (_remaining.value > 1)
_remaining.value--;
/* schedule / de-schedule animation */
Animator::Item::animated(_p1.animated() || _p2.animated());
}
@ -90,6 +95,12 @@ class Genode::Animated_rect : private Animator::Item, Noncopyable
*/
void move_to(Rect rect, Steps steps)
{
/* retarget animation while already in progress */
if (animated())
steps.value = max(_remaining.value, 1U);
_remaining = steps;
_p1.move_to(rect.p1(), steps);
_p2.move_to(rect.p2(), steps);
animate();

View File

@ -163,9 +163,6 @@ class Menu_view::Widget : List_model<Widget>::Element
void _trigger_geometry_animation()
{
if (_animated_geometry.animated())
return;
bool const changed = (_geometry.p1() != _animated_geometry.p1()
|| _geometry.p2() != _animated_geometry.p2());
if (changed)