diff options
author | ExMix <rahuba.youri@mapswithme.com> | 2014-03-13 10:47:12 +0400 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 02:12:41 +0300 |
commit | b04784b71678a4c96a51e23f875c3ef5ef69bf2b (patch) | |
tree | 0923b29073325dc81a78b31af53c1fd55955ba7b /map/ruler.hpp | |
parent | 69f6e406743e9bfa4813989cec71d9465b1524e2 (diff) |
prev frame animation for ruler
Diffstat (limited to 'map/ruler.hpp')
-rw-r--r-- | map/ruler.hpp | 99 |
1 files changed, 59 insertions, 40 deletions
diff --git a/map/ruler.hpp b/map/ruler.hpp index 81a35e9991..e786d43f71 100644 --- a/map/ruler.hpp +++ b/map/ruler.hpp @@ -1,6 +1,5 @@ #pragma once -#include "../std/shared_ptr.hpp" #include "../gui/element.hpp" @@ -10,6 +9,9 @@ #include "../graphics/display_list.hpp" +#include "../std/shared_ptr.hpp" +#include "../std/list.hpp" + namespace anim { class Task; @@ -32,49 +34,70 @@ class Framework; class Ruler : public gui::Element { -private: - - shared_ptr<anim::Task> m_rulerAnim; - void AlfaAnimEnded(bool isVisible); - bool IsHidingAnim() const; - float GetCurrentAlfa() const; - void CreateAnim(double startAlfa, double endAlfa, double timeInterval, double timeOffset, bool isVisibleAtEnd); - - /// @todo Remove this variables. All this stuff are constants - /// (get values from Framework constructor) - unsigned m_minPxWidth; - - double m_minMetersWidth; - double m_maxMetersWidth; - //@} - - /// Current diff in units between two endpoints of the ruler. - /// @todo No need to store it here. It's calculated once for calculating ruler's m_path. - double m_metresDiff; - - double m_cacheLength; - double m_scaleKoeff; - m2::PointD m_scalerOrg; - - m2::RectD m_boundRect; - typedef gui::Element base_t; mutable vector<m2::AnyRectD> m_boundRects; - typedef double (*ConversionFn)(double); - ConversionFn m_conversionFn; + class RulerFrame + { + public: + typedef function<void (bool isVisible, RulerFrame *)> frame_end_fn; + + RulerFrame(Framework & f, + frame_end_fn const & fn, + double depth); + + RulerFrame(RulerFrame const & other, const frame_end_fn & fn); + ~RulerFrame(); + + bool IsValid() const; + + void Cache(const string & text, const graphics::FontDesc & f); + void Purge(); + bool IsHidingAnim() const; + bool IsAnimActive() const; + void SetScale(double scale); + double GetScale() const; + void SetOrgPoint(m2::PointD const & org); + m2::PointD const & GetOrgPoint() const; + + void ShowAnimate(bool needPause); + void HideAnimate(bool needPause); + void Draw(graphics::OverlayRenderer * r, math::Matrix<double, 3, 3> const & m); + + private: + void CreateAnim(double startAlfa, double endAlfa, + double timeInterval, double timeOffset, + bool isVisibleAtEnd); + float GetCurrentAlfa(); + void AnimEnded(bool isVisible); + + private: + Framework & m_f; + shared_ptr<graphics::DisplayList> m_dl; + shared_ptr<graphics::DisplayList> m_textDL; + double m_scale; + double m_depth; + m2::PointD m_orgPt; + frame_end_fn m_callback; + + shared_ptr<anim::Task> m_frameAnim; + }; +private: + int m_currentRangeIndex; int m_currSystem; - void CalcMetresDiff(double v); + double CalcMetresDiff(double value); + void UpdateText(const string & text); - graphics::DisplayList * m_dl; - void PurgeMainDL(); - void CacheMainDL(); + void MainFrameAnimEnded(bool isVisible, RulerFrame * frame); + void AnimFrameAnimEnded(bool isVisible, RulerFrame * frame); - graphics::DisplayList * m_textDL[2]; - void PurgeTextDL(int index); - void UpdateText(const string & text); + RulerFrame * GetMainFrame(); + RulerFrame * GetMainFrame() const; + RulerFrame * m_mainFrame; + //list<RulerFrame *> m_animFrames; + RulerFrame * m_animFrames; Framework * m_framework; @@ -91,10 +114,6 @@ public: void AnimateShow(); void AnimateHide(); - void setMinPxWidth(unsigned minPxWidth); - void setMinMetersWidth(double v); - void setMaxMetersWidth(double v); - vector<m2::AnyRectD> const & boundRects() const; void draw(graphics::OverlayRenderer * r, math::Matrix<double, 3, 3> const & m) const; |