Bug 777075 - Trim the PanZoomState interface by moving some LayerController functions into PanZoomController. r=mbrubeck
This commit is contained in:
@@ -537,6 +537,16 @@ public class PanZoomController
|
||||
updatePosition();
|
||||
}
|
||||
|
||||
private void scrollBy(PointF point) {
|
||||
ViewportMetrics viewportMetrics = new ViewportMetrics(getMetrics());
|
||||
PointF origin = viewportMetrics.getOrigin();
|
||||
origin.offset(point.x, point.y);
|
||||
viewportMetrics.setOrigin(origin);
|
||||
|
||||
mTarget.setViewportMetrics(viewportMetrics);
|
||||
mTarget.notifyLayerClientOfGeometryChange();
|
||||
}
|
||||
|
||||
private void fling() {
|
||||
updatePosition();
|
||||
|
||||
@@ -627,7 +637,7 @@ public class PanZoomController
|
||||
}
|
||||
if (! mSubscroller.scrollBy(displacement)) {
|
||||
synchronized (mTarget.getLock()) {
|
||||
mTarget.scrollBy(displacement);
|
||||
scrollBy(displacement);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -939,10 +949,10 @@ public class PanZoomController
|
||||
newZoomFactor = maxZoomFactor + excessZoom;
|
||||
}
|
||||
|
||||
mTarget.scrollBy(new PointF(mLastZoomFocus.x - detector.getFocusX(),
|
||||
scrollBy(new PointF(mLastZoomFocus.x - detector.getFocusX(),
|
||||
mLastZoomFocus.y - detector.getFocusY()));
|
||||
PointF focus = new PointF(detector.getFocusX(), detector.getFocusY());
|
||||
mTarget.scaleWithFocus(newZoomFactor, focus);
|
||||
scaleWithFocus(newZoomFactor, focus);
|
||||
}
|
||||
|
||||
mLastZoomFocus.set(detector.getFocusX(), detector.getFocusY());
|
||||
@@ -963,6 +973,17 @@ public class PanZoomController
|
||||
mTarget.notifyLayerClientOfGeometryChange();
|
||||
}
|
||||
|
||||
/**
|
||||
* Scales the viewport, keeping the given focus point in the same place before and after the
|
||||
* scale operation. You must hold the monitor while calling this.
|
||||
*/
|
||||
private void scaleWithFocus(float zoomFactor, PointF focus) {
|
||||
ViewportMetrics viewportMetrics = new ViewportMetrics(getMetrics());
|
||||
viewportMetrics.scaleTo(zoomFactor, focus);
|
||||
mTarget.setViewportMetrics(viewportMetrics);
|
||||
mTarget.notifyLayerClientOfGeometryChange();
|
||||
}
|
||||
|
||||
public boolean getRedrawHint() {
|
||||
switch (mState) {
|
||||
case PINCHING:
|
||||
|
||||
Reference in New Issue
Block a user