зеркало из https://github.com/mozilla/gecko-dev.git
Move the ScaleGestureDetector.OnScaleGestureListener implementation over to PanZoomController rather than delegating through LayerController.
This commit is contained in:
Родитель
0435d12c95
Коммит
f08223cca2
|
@ -58,7 +58,7 @@ import java.util.ArrayList;
|
|||
* zooming natively by delegating to a panning/zooming controller. Touch events can be dispatched
|
||||
* to a higher-level view.
|
||||
*/
|
||||
public class LayerController implements ScaleGestureDetector.OnScaleGestureListener {
|
||||
public class LayerController {
|
||||
private Layer mRootLayer; /* The root layer. */
|
||||
private LayerView mView; /* The main rendering view. */
|
||||
private Context mContext; /* The current context. */
|
||||
|
@ -98,8 +98,8 @@ public class LayerController implements ScaleGestureDetector.OnScaleGestureListe
|
|||
else
|
||||
mPageSize = new IntSize(LayerController.TILE_WIDTH, LayerController.TILE_HEIGHT);
|
||||
|
||||
mView = new LayerView(context, this);
|
||||
mPanZoomController = new PanZoomController(this);
|
||||
mView = new LayerView(context, this);
|
||||
}
|
||||
|
||||
public void setRoot(Layer layer) { mRootLayer = layer; }
|
||||
|
@ -121,6 +121,8 @@ public class LayerController implements ScaleGestureDetector.OnScaleGestureListe
|
|||
public Bitmap getCheckerboardPattern() { return getDrawable("checkerboard"); }
|
||||
public Bitmap getShadowPattern() { return getDrawable("shadow"); }
|
||||
|
||||
public ScaleGestureDetector.OnScaleGestureListener getScaleGestureListener() { return mPanZoomController; }
|
||||
|
||||
private Bitmap getDrawable(String name) {
|
||||
Resources resources = mContext.getResources();
|
||||
int resourceID = resources.getIdentifier(name, "drawable", mContext.getPackageName());
|
||||
|
@ -256,21 +258,6 @@ public class LayerController implements ScaleGestureDetector.OnScaleGestureListe
|
|||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onScale(ScaleGestureDetector detector) {
|
||||
return mPanZoomController.onScale(detector);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onScaleBegin(ScaleGestureDetector detector) {
|
||||
return mPanZoomController.onScaleBegin(detector);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScaleEnd(ScaleGestureDetector detector) {
|
||||
mPanZoomController.onScaleEnd(detector);
|
||||
}
|
||||
|
||||
/**
|
||||
* Objects that wish to listen for changes in the layer geometry (visible rect or screen size)
|
||||
* should implement this interface and register themselves with addOnGeometryChangeListener().
|
||||
|
|
|
@ -68,7 +68,7 @@ public class LayerView extends GLSurfaceView {
|
|||
mController = controller;
|
||||
mRenderer = new LayerRenderer(this);
|
||||
setRenderer(mRenderer);
|
||||
mScaleGestureDetector = new ScaleGestureDetector(context, controller);
|
||||
mScaleGestureDetector = new ScaleGestureDetector(context, controller.getScaleGestureListener());
|
||||
mInputConnectionHandler = null;
|
||||
|
||||
setFocusable(true);
|
||||
|
|
|
@ -53,7 +53,7 @@ import java.util.TimerTask;
|
|||
* Many ideas are from Joe Hewitt's Scrollability:
|
||||
* https://github.com/joehewitt/scrollability/
|
||||
*/
|
||||
public class PanZoomController {
|
||||
public class PanZoomController implements ScaleGestureDetector.OnScaleGestureListener {
|
||||
private LayerController mController;
|
||||
|
||||
private static final float FRICTION = 0.97f;
|
||||
|
@ -477,6 +477,7 @@ public class PanZoomController {
|
|||
/*
|
||||
* Zooming
|
||||
*/
|
||||
@Override
|
||||
public boolean onScale(ScaleGestureDetector detector) {
|
||||
float newZoom = detector.getCurrentSpan() / mInitialZoomSpan;
|
||||
|
||||
|
@ -491,6 +492,7 @@ public class PanZoomController {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onScaleBegin(ScaleGestureDetector detector) {
|
||||
IntRect initialZoomRect = (IntRect)mController.getVisibleRect().clone();
|
||||
float initialZoom = mController.getZoomFactor();
|
||||
|
@ -501,6 +503,7 @@ public class PanZoomController {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScaleEnd(ScaleGestureDetector detector) {
|
||||
// TODO
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче