summaryrefslogtreecommitdiffstats
path: root/src/com/android/gallery3d/ui/PositionController.java
diff options
context:
space:
mode:
authorChih-Chung Chang <chihchung@google.com>2012-01-05 12:00:53 +0800
committerChih-Chung Chang <chihchung@google.com>2012-01-12 11:47:14 +0800
commite9ca81a2fed768af4493c6aba897fa5cfc4523fb (patch)
tree53bbbb11e9cbd52c7694382a72c9e6cddfbe9806 /src/com/android/gallery3d/ui/PositionController.java
parent68d7a1a42ed46f1077405a289e20696b7c358b46 (diff)
downloadandroid_packages_apps_Snap-e9ca81a2fed768af4493c6aba897fa5cfc4523fb.tar.gz
android_packages_apps_Snap-e9ca81a2fed768af4493c6aba897fa5cfc4523fb.tar.bz2
android_packages_apps_Snap-e9ca81a2fed768af4493c6aba897fa5cfc4523fb.zip
Patch.
Change-Id: I62fd65461e8989a1d5cf6bc353dfc4b61a2108c8
Diffstat (limited to 'src/com/android/gallery3d/ui/PositionController.java')
-rw-r--r--src/com/android/gallery3d/ui/PositionController.java13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/com/android/gallery3d/ui/PositionController.java b/src/com/android/gallery3d/ui/PositionController.java
index abffbc58f..b4dac973f 100644
--- a/src/com/android/gallery3d/ui/PositionController.java
+++ b/src/com/android/gallery3d/ui/PositionController.java
@@ -21,6 +21,7 @@ import com.android.gallery3d.app.GalleryActivity;
import com.android.gallery3d.common.Utils;
import com.android.gallery3d.data.Path;
import com.android.gallery3d.ui.PositionRepository.Position;
+import com.android.gallery3d.util.GalleryUtils;
import android.content.Context;
import android.graphics.Bitmap;
@@ -61,6 +62,7 @@ class PositionController {
// We try to scale up the image to fill the screen. But in order not to
// scale too much for small icons, we limit the max up-scaling factor here.
private static final float SCALE_LIMIT = 4;
+ private static final int sHorizontalSlack = GalleryUtils.dpToPixel(12);
private PhotoView mViewer;
private EdgeView mEdgeView;
@@ -543,7 +545,7 @@ class PositionController {
scale = Utils.clamp(mCurrentScale, mScaleMin, mScaleMax);
}
- calculateStableBound(scale);
+ calculateStableBound(scale, sHorizontalSlack);
int x = Utils.clamp(mCurrentX, mBoundLeft, mBoundRight);
int y = Utils.clamp(mCurrentY, mBoundTop, mBoundBottom);
@@ -570,10 +572,17 @@ class PositionController {
//
// The results are stored in mBound{Left/Right/Top/Bottom}.
//
+ // An extra parameter "horizontalSlack" (which has the value of 0 usually)
+ // is used to extend the stable region by some pixels on each side
+ // horizontally.
private void calculateStableBound(float scale) {
+ calculateStableBound(scale, 0f);
+ }
+
+ private void calculateStableBound(float scale, float horizontalSlack) {
// The number of pixels between the center of the view
// and the edge when the edge is aligned.
- mBoundLeft = (int) Math.ceil(mViewW / (2 * scale));
+ mBoundLeft = (int) Math.ceil((mViewW - horizontalSlack) / (2 * scale));
mBoundRight = mImageW - mBoundLeft;
mBoundTop = (int) Math.ceil(mViewH / (2 * scale));
mBoundBottom = mImageH - mBoundTop;