[core] remove MockView and View dependency in Transform
This commit is contained in:
@@ -36,10 +36,10 @@ static double _normalizeAngle(double angle, double anchorAngle)
|
||||
return angle;
|
||||
}
|
||||
|
||||
Transform::Transform(View &view_, ConstrainMode constrainMode, ViewportMode viewportMode)
|
||||
: view(view_)
|
||||
, state(constrainMode, viewportMode)
|
||||
{
|
||||
Transform::Transform(std::function<void(MapChange)> callback_,
|
||||
ConstrainMode constrainMode,
|
||||
ViewportMode viewportMode)
|
||||
: callback(std::move(callback_)), state(constrainMode, viewportMode) {
|
||||
}
|
||||
|
||||
#pragma mark - Map View
|
||||
@@ -47,13 +47,17 @@ Transform::Transform(View &view_, ConstrainMode constrainMode, ViewportMode view
|
||||
bool Transform::resize(const std::array<uint16_t, 2> size) {
|
||||
if (state.width != size[0] || state.height != size[1]) {
|
||||
|
||||
view.notifyMapChange(MapChangeRegionWillChange);
|
||||
if (callback) {
|
||||
callback(MapChangeRegionWillChange);
|
||||
}
|
||||
|
||||
state.width = size[0];
|
||||
state.height = size[1];
|
||||
state.constrain(state.scale, state.x, state.y);
|
||||
|
||||
view.notifyMapChange(MapChangeRegionDidChange);
|
||||
if (callback) {
|
||||
callback(MapChangeRegionDidChange);
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
@@ -560,8 +564,10 @@ void Transform::startTransition(const CameraOptions& camera,
|
||||
}
|
||||
|
||||
bool isAnimated = duration != Duration::zero();
|
||||
view.notifyMapChange(isAnimated ? MapChangeRegionWillChangeAnimated : MapChangeRegionWillChange);
|
||||
|
||||
if (callback) {
|
||||
callback(isAnimated ? MapChangeRegionWillChangeAnimated : MapChangeRegionWillChange);
|
||||
}
|
||||
|
||||
// Associate the anchor, if given, with a coordinate.
|
||||
optional<ScreenCoordinate> anchor = camera.anchor;
|
||||
LatLng anchorLatLng;
|
||||
@@ -590,7 +596,9 @@ void Transform::startTransition(const CameraOptions& camera,
|
||||
if (animation.transitionFrameFn) {
|
||||
animation.transitionFrameFn(t);
|
||||
}
|
||||
view.notifyMapChange(MapChangeRegionIsChanging);
|
||||
if (callback) {
|
||||
callback(MapChangeRegionIsChanging);
|
||||
}
|
||||
} else {
|
||||
transitionFinishFn();
|
||||
transitionFinishFn = nullptr;
|
||||
@@ -609,7 +617,9 @@ void Transform::startTransition(const CameraOptions& camera,
|
||||
if (animation.transitionFinishFn) {
|
||||
animation.transitionFinishFn();
|
||||
}
|
||||
view.notifyMapChange(isAnimated ? MapChangeRegionDidChangeAnimated : MapChangeRegionDidChange);
|
||||
if (callback) {
|
||||
callback(isAnimated ? MapChangeRegionDidChangeAnimated : MapChangeRegionDidChange);
|
||||
}
|
||||
};
|
||||
|
||||
if (!isAnimated) {
|
||||
|
||||
Reference in New Issue
Block a user