summaryrefslogtreecommitdiffstats
path: root/src/com/android/gallery3d/ui/PositionController.java
diff options
context:
space:
mode:
authorChih-Chung Chang <chihchung@google.com>2012-03-21 19:01:30 +0800
committerChih-Chung Chang <chihchung@google.com>2012-03-26 19:25:49 +0800
commit95860d26aef15e6a87cbbc81b15bd92eff309475 (patch)
tree87def982f0cf2ab28fd767be841326af3bd781a7 /src/com/android/gallery3d/ui/PositionController.java
parent0499bbe3ba2110ff964018042307a0a7441e3f19 (diff)
downloadandroid_packages_apps_Snap-95860d26aef15e6a87cbbc81b15bd92eff309475.tar.gz
android_packages_apps_Snap-95860d26aef15e6a87cbbc81b15bd92eff309475.tar.bz2
android_packages_apps_Snap-95860d26aef15e6a87cbbc81b15bd92eff309475.zip
Patch 2 for master.
Change-Id: I8b7c9fd326c4f247a1f2129b1d64388a223d79e0
Diffstat (limited to 'src/com/android/gallery3d/ui/PositionController.java')
-rw-r--r--src/com/android/gallery3d/ui/PositionController.java27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/com/android/gallery3d/ui/PositionController.java b/src/com/android/gallery3d/ui/PositionController.java
index 09fbc1706..625505f49 100644
--- a/src/com/android/gallery3d/ui/PositionController.java
+++ b/src/com/android/gallery3d/ui/PositionController.java
@@ -59,6 +59,9 @@ class PositionController {
private static final float SCALE_LIMIT = 4;
private static final int sHorizontalSlack = GalleryUtils.dpToPixel(12);
+ private static final float SCALE_MIN_EXTRA = 0.6f;
+ private static final float SCALE_MAX_EXTRA = 1.4f;
+
private PhotoView mViewer;
private EdgeView mEdgeView;
private int mImageW, mImageH;
@@ -78,6 +81,7 @@ class PositionController {
// The minimum and maximum scale we allow.
private float mScaleMin, mScaleMax = SCALE_LIMIT;
+ private boolean mExtraScalingRange = false;
// This is used by the fling animation
private FlingScroller mScroller;
@@ -269,7 +273,8 @@ class PositionController {
(focusY - mViewH / 2f) / mCurrentScale);
}
- public void scaleBy(float s, float focusX, float focusY) {
+ // Returns true if the result scale is outside the stable range.
+ public boolean scaleBy(float s, float focusX, float focusY) {
// We want to keep the focus point (on the bitmap) the same as when
// we begin the scale guesture, that is,
@@ -281,6 +286,7 @@ class PositionController {
int y = Math.round(mFocusBitmapY - (focusY - mViewH / 2f) / s);
startAnimation(x, y, s, ANIM_KIND_SCALE);
+ return (s < mScaleMin || s > mScaleMax);
}
public void endScale() {
@@ -288,6 +294,13 @@ class PositionController {
startSnapbackIfNeeded();
}
+ public void setExtraScalingRange(boolean enabled) {
+ mExtraScalingRange = enabled;
+ if (!enabled) {
+ startSnapbackIfNeeded();
+ }
+ }
+
public float getCurrentScale() {
return mCurrentScale;
}
@@ -419,7 +432,8 @@ class PositionController {
mToX = targetX;
mToY = targetY;
- mToScale = Utils.clamp(scale, 0.6f * mScaleMin, 1.4f * mScaleMax);
+ mToScale = Utils.clamp(scale, SCALE_MIN_EXTRA * mScaleMin,
+ SCALE_MAX_EXTRA * mScaleMax);
// If the scaled height is smaller than the view height,
// force it to be in the center.
@@ -561,9 +575,14 @@ class PositionController {
boolean needAnimation = false;
float scale = mCurrentScale;
- if (mCurrentScale < mScaleMin || mCurrentScale > mScaleMax) {
+ float scaleMin = mExtraScalingRange ?
+ mScaleMin * SCALE_MIN_EXTRA : mScaleMin;
+ float scaleMax = mExtraScalingRange ?
+ mScaleMax * SCALE_MAX_EXTRA : mScaleMax;
+
+ if (mCurrentScale < scaleMin || mCurrentScale > scaleMax) {
needAnimation = true;
- scale = Utils.clamp(mCurrentScale, mScaleMin, mScaleMax);
+ scale = Utils.clamp(mCurrentScale, scaleMin, scaleMax);
}
calculateStableBound(scale, sHorizontalSlack);