[core, osx] Added optional padding to convenience methods
Methods that offer a convenient way to jump or ease now accept an optional padding parameter. MGLMapView specifies the padding to ensure that keyboard-based zooming and rotation respects the toolbar.
This commit is contained in:
committed by
Minh Nguyễn
parent
c86646519a
commit
bf87eaa7b8
@@ -397,12 +397,19 @@ void Transform::setLatLng(const LatLng& latLng, const PrecisionPoint& point, con
|
||||
}
|
||||
|
||||
void Transform::setLatLngZoom(const LatLng& latLng, double zoom, const Duration& duration) {
|
||||
setLatLngZoom(latLng, zoom, {}, duration);
|
||||
}
|
||||
|
||||
void Transform::setLatLngZoom(const LatLng& latLng, double zoom, const EdgeInsets& padding, const Duration& duration) {
|
||||
if (!latLng || std::isnan(zoom)) {
|
||||
return;
|
||||
}
|
||||
|
||||
CameraOptions camera;
|
||||
camera.center = latLng;
|
||||
if (padding) {
|
||||
camera.padding = padding;
|
||||
}
|
||||
camera.zoom = zoom;
|
||||
easeTo(camera, duration);
|
||||
}
|
||||
@@ -429,8 +436,13 @@ void Transform::scaleBy(double ds, const PrecisionPoint& center, const Duration&
|
||||
setScale(scale, center, duration);
|
||||
}
|
||||
|
||||
void Transform::setZoom(double zoom, const Duration& duration) {
|
||||
setScale(state.zoomScale(zoom), {NAN, NAN}, duration);
|
||||
void Transform::setZoom(double zoom, const PrecisionPoint& anchor, const Duration& duration) {
|
||||
setScale(state.zoomScale(zoom), anchor, duration);
|
||||
}
|
||||
|
||||
void Transform::setZoom(double zoom, const EdgeInsets& padding, const Duration& duration) {
|
||||
const PrecisionPoint center = padding.getCenter(state.width, state.height);
|
||||
setZoom(zoom, center, duration);
|
||||
}
|
||||
|
||||
double Transform::getZoom() const {
|
||||
@@ -452,6 +464,11 @@ void Transform::setScale(double scale, const PrecisionPoint& anchor, const Durat
|
||||
easeTo(camera, duration);
|
||||
}
|
||||
|
||||
void Transform::setScale(double scale, const EdgeInsets& padding, const Duration& duration) {
|
||||
const PrecisionPoint center = padding.getCenter(state.width, state.height);
|
||||
setScale(scale, center, duration);
|
||||
}
|
||||
|
||||
#pragma mark - Angle
|
||||
|
||||
void Transform::rotateBy(const PrecisionPoint& first, const PrecisionPoint& second, const Duration& duration) {
|
||||
@@ -498,6 +515,11 @@ void Transform::setAngle(double angle, const PrecisionPoint& anchor, const Durat
|
||||
easeTo(camera, duration);
|
||||
}
|
||||
|
||||
void Transform::setAngle(double angle, const EdgeInsets& padding, const Duration& duration) {
|
||||
const PrecisionPoint center = padding.getCenter(state.width, state.height);
|
||||
setAngle(angle, center, duration);
|
||||
}
|
||||
|
||||
double Transform::getAngle() const {
|
||||
return state.angle;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user