diff options
author | Tor Lillqvist <tml@iki.fi> | 2013-03-03 22:23:54 +0200 |
---|---|---|
committer | Tor Lillqvist <tml@iki.fi> | 2013-03-03 22:29:54 +0200 |
commit | 6339bf132518130d4093869f9913df5b103bf5d3 (patch) | |
tree | 75ed66aafc51fecce3ce1e201ab252940b3601e0 /android | |
parent | 5facce3c212387054d2da05672445556f5bca14d (diff) |
Android "desktop" app: More hacking on scaling
Added a new "mode" for the CommandWheelData, COMMAND_WHEEL_ZOOM_SCALE, where
the "delta" is the scale percentage to multiply the curent zoom factor
with. Implement in Writer and Calc.
But actually, I am more and more startng to think that live scaling of the
document view during the pinch/spread gesture will never perform fast
enough. Need to go back to the (simple) trick to just scale the BitmapView,
and do the actual LO re-zoom only when the gesture finishes. But in order for
that to look nicer, need to get rid of the LO UI element clutter around the
document, scrollbars, buttons etc. Plus of course need to make sure the LO
zooming happens around the gesture center position.
Change-Id: I20dfcb4c2a97aacbf7e5b6ea5c24816b237fe687
Diffstat (limited to 'android')
-rw-r--r-- | android/experimental/desktop/src/org/libreoffice/experimental/desktop/Desktop.java | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/android/experimental/desktop/src/org/libreoffice/experimental/desktop/Desktop.java b/android/experimental/desktop/src/org/libreoffice/experimental/desktop/Desktop.java index d01c323d8f16..baa36dc37c48 100644 --- a/android/experimental/desktop/src/org/libreoffice/experimental/desktop/Desktop.java +++ b/android/experimental/desktop/src/org/libreoffice/experimental/desktop/Desktop.java @@ -166,7 +166,7 @@ public class Desktop boolean scalingInProgress; GestureDetector gestureDetector; ScaleGestureDetector scaleDetector; - float scale = 1; + long lastGestureEventTime; public BitmapView() { @@ -201,27 +201,31 @@ public class Desktop new ScaleGestureDetector.SimpleOnScaleGestureListener() { @Override public boolean onScaleBegin(ScaleGestureDetector detector) { - Log.i(TAG, "onScaleBegin: pivot=(" + detector.getFocusX() + ", " + detector.getFocusY() + ")"); scalingInProgress = true; + lastGestureEventTime = System.currentTimeMillis(); return true; } @Override public boolean onScale(ScaleGestureDetector detector) { - float s = detector.getScaleFactor(); - if (s > 0.95 && s < 1.05) + long now = System.currentTimeMillis(); + if (now - lastGestureEventTime < 100) return false; - scale *= s; - Log.i(TAG, "onScale: " + s + " => " + scale); + float scale = detector.getScaleFactor(); + if (scale > 0.95 && scale < 1.05) + return false; + Log.i(TAG, "onScale: " + scale); + lastGestureEventTime = now; Desktop.zoom(scale, (int) detector.getFocusX(), (int) detector.getFocusY()); return true; } @Override public void onScaleEnd(ScaleGestureDetector detector) { + float scale = detector.getScaleFactor(); Log.i(TAG, "onScaleEnd: " + scale); - Desktop.zoom(scale, (int) detector.getFocusX(), (int) detector.getFocusY()); - scale = 1; + if (!(scale > 0.95 && scale < 1.05)) + Desktop.zoom(scale, (int) detector.getFocusX(), (int) detector.getFocusY()); scalingInProgress = false; } }); |