[core] Cleaned up Transform

Eliminated many redundant methods on Transform. Minimized usage of TransformState::x and TransformState::y. Added convenient constructors for AnimationOptions. When scaling, passing in view’s origin as the anchor no longer anchors the scaling operation at the view’s center. To specify no anchor, use NaN.

Increased precision of worldSize(), now that it’s used much more heavily in transform methods.
This commit is contained in:
Minh Nguyễn
2016-01-10 17:28:21 -08:00
committed by Minh Nguyễn
parent 27b308a234
commit d26b956a48
7 changed files with 155 additions and 181 deletions

View File

@@ -59,6 +59,13 @@ struct AnimationOptions {
/** A function that is called once on the last frame of the transition, just
before the corresponding screen update. */
std::function<void()> transitionFinishFn;
/** Creates an animation with no options specified. */
inline AnimationOptions() {}
/** Creates an animation with the specified duration. */
inline AnimationOptions(Duration d)
: duration(d) {}
};
} // namespace mbgl

View File

@@ -111,8 +111,8 @@ public:
void resetPosition();
// Scale
void scaleBy(double ds, const PrecisionPoint& = { 0, 0 }, const Duration& = Duration::zero());
void setScale(double scale, const PrecisionPoint& = { 0, 0 }, const Duration& = Duration::zero());
void scaleBy(double ds, const PrecisionPoint& = { NAN, NAN }, const Duration& = Duration::zero());
void setScale(double scale, const PrecisionPoint& = { NAN, NAN }, const Duration& = Duration::zero());
double getScale() const;
void setZoom(double zoom, const Duration& = Duration::zero());
double getZoom() const;