summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2015-04-01 13:49:35 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2015-04-02 16:12:29 -0700
commit12c07b916b106272ba68f0fc85a10b774fd07a50 (patch)
tree0dcaf8906d8e3b2df9b5c7481778ab176b7ae335 /include
parent9e38d7cc2bcf6db0dc8377693e398e6f79f9b170 (diff)
downloadqtlocation-mapboxgl-12c07b916b106272ba68f0fc85a10b774fd07a50.tar.gz
Rework easing transition code
This brings the easing transition code a bit closer to how easings work in gl-js. Instead of having an array of individual transitions for scale, rotate, and pan, there is a single transition function that does all the required calculations. This permits us to: * Eliminate the "timeout" transition. (Fixes #126) * Replace start/stopPanning() et al with setGestureInProgress(). Apps or SDKs are expected to make paired calls to setGestureInProgress(). This state will be ORed with the active easing state to determine when to use texture interpolation. (Fixes #79) * Run style recalculations only when an ease transition that affects the zoom is in progress. (Fixes #1155)
Diffstat (limited to 'include')
-rw-r--r--include/mbgl/map/map.hpp7
-rw-r--r--include/mbgl/map/transform.hpp28
-rw-r--r--include/mbgl/map/transform_state.hpp1
-rw-r--r--include/mbgl/map/update.hpp1
4 files changed, 16 insertions, 21 deletions
diff --git a/include/mbgl/map/map.hpp b/include/mbgl/map/map.hpp
index 436a07cb47..cdcfa27e42 100644
--- a/include/mbgl/map/map.hpp
+++ b/include/mbgl/map/map.hpp
@@ -100,13 +100,12 @@ public:
// Transition
void cancelTransitions();
+ void setGestureInProgress(bool);
// Position
void moveBy(double dx, double dy, Duration = Duration::zero());
void setLatLng(LatLng latLng, Duration = Duration::zero());
LatLng getLatLng() const;
- void startPanning();
- void stopPanning();
void resetPosition();
// Scale
@@ -117,8 +116,6 @@ public:
double getZoom() const;
void setLatLngZoom(LatLng latLng, double zoom, Duration = Duration::zero());
void resetZoom();
- void startScaling();
- void stopScaling();
double getMinZoom() const;
double getMaxZoom() const;
@@ -128,8 +125,6 @@ public:
void setBearing(double degrees, double cx, double cy);
double getBearing() const;
void resetNorth();
- void startRotating();
- void stopRotating();
// API
void setAccessToken(const std::string &token);
diff --git a/include/mbgl/map/transform.hpp b/include/mbgl/map/transform.hpp
index b15c119c44..ef89a4eefa 100644
--- a/include/mbgl/map/transform.hpp
+++ b/include/mbgl/map/transform.hpp
@@ -3,6 +3,7 @@
#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 <mbgl/util/vec.hpp>
@@ -31,8 +32,6 @@ public:
void setLatLng(LatLng latLng, Duration = Duration::zero());
void setLatLngZoom(LatLng latLng, double zoom, Duration = Duration::zero());
inline const LatLng getLatLng() const { return current.getLatLng(); }
- void startPanning();
- void stopPanning();
// Zoom
void scaleBy(double ds, double cx = -1, double cy = -1, Duration = Duration::zero());
@@ -40,8 +39,6 @@ public:
void setZoom(double zoom, Duration = Duration::zero());
double getZoom() const;
double getScale() const;
- void startScaling();
- void stopScaling();
double getMinZoom() const;
double getMaxZoom() const;
@@ -50,14 +47,15 @@ public:
void setAngle(double angle, Duration = Duration::zero());
void setAngle(double angle, double cx, double cy);
double getAngle() const;
- void startRotating();
- void stopRotating();
// Transitions
bool needsTransition() const;
- void updateTransitions(TimePoint now);
+ UpdateType updateTransitions(TimePoint now);
void cancelTransitions();
+ // Gesture
+ void setGestureInProgress(bool);
+
// Transform state
const TransformState currentState() const;
const TransformState finalState() const;
@@ -69,13 +67,9 @@ private:
void _setScale(double scale, double cx, double cy, Duration = Duration::zero());
void _setScaleXY(double new_scale, double xn, double yn, Duration = Duration::zero());
void _setAngle(double angle, Duration = Duration::zero());
- void _clearPanning();
- void _clearRotating();
- void _clearScaling();
void constrain(double& scale, double& y) const;
-private:
View &view;
mutable std::recursive_mutex mtx;
@@ -92,10 +86,14 @@ private:
const double min_scale = std::pow(2, 0);
const double max_scale = std::pow(2, 18);
- std::forward_list<util::ptr<util::transition>> transitions;
- util::ptr<util::transition> scale_timeout;
- util::ptr<util::transition> rotate_timeout;
- util::ptr<util::transition> pan_timeout;
+ void startTransition(std::function<Update(double)> frame,
+ std::function<void()> finish,
+ Duration);
+
+ TimePoint transitionStart;
+ Duration transitionDuration;
+ std::function<Update(TimePoint)> transitionFrameFn;
+ std::function<void()> transitionFinishFn;
};
}
diff --git a/include/mbgl/map/transform_state.hpp b/include/mbgl/map/transform_state.hpp
index 5f2dfa49e4..c1a324a899 100644
--- a/include/mbgl/map/transform_state.hpp
+++ b/include/mbgl/map/transform_state.hpp
@@ -77,6 +77,7 @@ private:
bool rotating = false;
bool scaling = false;
bool panning = false;
+ bool gestureInProgress = false;
// map position
double x = 0, y = 0;
diff --git a/include/mbgl/map/update.hpp b/include/mbgl/map/update.hpp
index 3d02434c60..3aa871bf03 100644
--- a/include/mbgl/map/update.hpp
+++ b/include/mbgl/map/update.hpp
@@ -11,6 +11,7 @@ enum class Update : UpdateType {
Debug = 1 << 1,
DefaultTransitionDuration = 1 << 2,
Classes = 1 << 3,
+ Zoom = 1 << 4,
};
}