1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
#pragma once
#include "gui/element.hpp"
#include "std/shared_ptr.hpp"
#include "std/unique_ptr.hpp"
#include "std/function.hpp"
namespace anim
{
class Task;
}
namespace graphics
{
class DisplayList;
namespace gl
{
class OverlayRenderer;
}
}
class Framework;
class Ruler : public gui::Element
{
typedef gui::Element BaseT;
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;
int m_textLengthInPx;
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;
double CalcMetresDiff(double value);
void UpdateText(const string & text);
void MainFrameAnimEnded(bool isVisible, RulerFrame * frame);
void AnimFrameAnimEnded(bool isVisible, RulerFrame * frame);
RulerFrame * GetMainFrame();
RulerFrame * GetMainFrame() const;
unique_ptr<RulerFrame> m_mainFrame;
unique_ptr<RulerFrame> m_animFrame;
Framework * m_framework;
public:
struct Params : public Element::Params
{
Framework * m_framework;
Params();
};
Ruler(Params const & p);
void AnimateShow();
void AnimateHide();
/// @name Override from graphics::OverlayElement and gui::Element.
//@{
virtual m2::RectD GetBoundRect() const;
void draw(graphics::OverlayRenderer * r, math::Matrix<double, 3, 3> const & m) const;
void update();
void layout();
void cache();
void purge();
//@}
int GetTextOffsetFromLine() const;
};
|