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
|
#ifndef MBGL_MAP_TRANSFORM
#define MBGL_MAP_TRANSFORM
#include <mbgl/map/transform_state.hpp>
#include <mbgl/util/chrono.hpp>
#include <mbgl/map/update.hpp>
#include <mbgl/util/geo.hpp>
#include <mbgl/util/noncopyable.hpp>
#include <cstdint>
#include <cmath>
#include <functional>
namespace mbgl {
class View;
class Transform : private util::noncopyable {
public:
Transform(View&);
// Map view
bool resize(std::array<uint16_t, 2> size);
// Position
void moveBy(double dx, double dy, const Duration& = Duration::zero());
void setLatLng(LatLng latLng, const Duration& = Duration::zero());
void setLatLngZoom(LatLng latLng, double zoom, const Duration& = Duration::zero());
inline const LatLng getLatLng() const { return state.getLatLng(); }
// Zoom
void scaleBy(double ds, double cx = -1, double cy = -1, const Duration& = Duration::zero());
void setScale(double scale, double cx = -1, double cy = -1, const Duration& = Duration::zero());
void setZoom(double zoom, const Duration& = Duration::zero());
double getZoom() const;
double getScale() const;
// Angle
void rotateBy(double sx, double sy, double ex, double ey, const Duration& = Duration::zero());
void setAngle(double angle, const Duration& = Duration::zero());
void setAngle(double angle, double cx, double cy);
double getAngle() const;
// Transitions
UpdateType updateTransitions(const TimePoint& now);
void cancelTransitions();
// Gesture
void setGestureInProgress(bool);
// Transform state
const TransformState getState() const { return state; }
private:
void _moveBy(double dx, double dy, const Duration& = Duration::zero());
void _setScale(double scale, double cx, double cy, const Duration& = Duration::zero());
void _setScaleXY(double new_scale, double xn, double yn, const Duration& = Duration::zero());
void _setAngle(double angle, const Duration& = Duration::zero());
View &view;
TransformState state;
void startTransition(std::function<Update(double)> frame,
std::function<void()> finish,
const Duration& duration);
TimePoint transitionStart;
Duration transitionDuration;
std::function<Update(const TimePoint)> transitionFrameFn;
std::function<void()> transitionFinishFn;
};
}
#endif
|