diff --git a/repos/gems/src/app/menu_view/animated_geometry.h b/repos/gems/include/gems/animated_geometry.h similarity index 68% rename from repos/gems/src/app/menu_view/animated_geometry.h rename to repos/gems/include/gems/animated_geometry.h index 2e4b626042..854d38a46f 100644 --- a/repos/gems/src/app/menu_view/animated_geometry.h +++ b/repos/gems/include/gems/animated_geometry.h @@ -11,32 +11,36 @@ * under the terms of the GNU Affero General Public License version 3. */ -#ifndef _ANIMATED_GEOMETRY_H_ -#define _ANIMATED_GEOMETRY_H_ +#ifndef _INCLUDE__GEMS__ANIMATED_GEOMETRY_H_ +#define _INCLUDE__GEMS__ANIMATED_GEOMETRY_H_ /* demo includes */ #include #include +#include -/* local includes */ -#include "types.h" - -namespace Menu_view { class Animated_rect; } +namespace Genode { class Animated_rect; } -class Menu_view::Animated_rect : public Rect, Animator::Item, Noncopyable +class Genode::Animated_rect : private Animator::Item, Noncopyable { public: struct Steps { unsigned value; }; + typedef Surface_base::Rect Rect; + typedef Surface_base::Area Area; + typedef Surface_base::Point Point; + private: + Rect _rect { }; + struct Animated_point { bool _initial = true; - Lazy_value _x, _y; + Lazy_value _x { }, _y { }; void animate() { _x.animate(); _y.animate(); } @@ -58,7 +62,7 @@ class Menu_view::Animated_rect : public Rect, Animator::Item, Noncopyable int y() const { return _y >> 10; } }; - Animated_point _p1, _p2; + Animated_point _p1 { }, _p2 { }; public: @@ -71,8 +75,7 @@ class Menu_view::Animated_rect : public Rect, Animator::Item, Noncopyable { _p1.animate(); _p2.animate(); - static_cast(*this) = Rect(Point(_p1.x(), _p1.y()), - Point(_p2.x(), _p2.y())); + _rect = Rect(Point(_p1.x(), _p1.y()), Point(_p2.x(), _p2.y())); /* schedule / de-schedule animation */ Animator::Item::animated(_p1.animated() || _p2.animated()); @@ -93,6 +96,13 @@ class Menu_view::Animated_rect : public Rect, Animator::Item, Noncopyable } bool animated() const { return Animator::Item::animated(); } + + bool initialized() const { return _p1._initial == false; } + + Rect rect() const { return _rect; } + Area area() const { return _rect.area(); } + Point p1() const { return _rect.p1(); } + Point p2() const { return _rect.p2(); } }; -#endif /* _ANIMATED_GEOMETRY_H_ */ +#endif /* _INCLUDE__GEMS__ANIMATED_GEOMETRY_H_ */ diff --git a/repos/gems/src/app/menu_view/widget.h b/repos/gems/src/app/menu_view/widget.h index c0bd818348..70e2f73073 100644 --- a/repos/gems/src/app/menu_view/widget.h +++ b/repos/gems/src/app/menu_view/widget.h @@ -17,10 +17,10 @@ /* Genode includes */ #include #include +#include /* local includes */ #include -#include namespace Menu_view { @@ -182,7 +182,7 @@ class Menu_view::Widget : public List_model::Element Rect geometry() const { return _geometry; } - Rect animated_geometry() const { return _animated_geometry; } + Rect animated_geometry() const { return _animated_geometry.rect(); } /* * Return x/y positions of the edges of the widget with the margin @@ -190,7 +190,7 @@ class Menu_view::Widget : public List_model::Element */ Rect edges() const { - Rect const r = _animated_geometry; + Rect const r = _animated_geometry.rect(); return Rect(Point(r.x1() + margin.left, r.y1() + margin.top), Point(r.x2() - margin.right, r.y2() - margin.bottom)); }