From 6c7ad5dbed878a4b477edd8d92004a9be672a731 Mon Sep 17 00:00:00 2001 From: Chet Haase Date: Tue, 28 Dec 2010 08:40:00 -0800 Subject: [PATCH] Changes to view position update pivot point Change-Id: I8ca8e2c8c016ae5ced32c8f8fbcbcded9fa3a466 --- core/java/android/view/View.java | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 33ea66c51c27b..b3e0f188977c6 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -5445,7 +5445,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility // Figure out if we need to update the pivot point if ((mPrivateFlags & PIVOT_EXPLICITLY_SET) == 0) { - if ((mRight - mLeft) != mPrevWidth && (mBottom - mTop) != mPrevHeight) { + if ((mRight - mLeft) != mPrevWidth || (mBottom - mTop) != mPrevHeight) { mPrevWidth = mRight - mLeft; mPrevHeight = mBottom - mTop; mPivotX = (float) mPrevWidth / 2f; @@ -5827,6 +5827,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility onSizeChanged(width, mBottom - mTop, width, oldHeight); if (!mMatrixIsIdentity) { + if ((mPrivateFlags & PIVOT_EXPLICITLY_SET) == 0) { + // A change in dimension means an auto-centered pivot point changes, too + mMatrixDirty = true; + } mPrivateFlags |= DRAWN; // force another invalidation with the new orientation invalidate(); } @@ -5880,6 +5884,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility onSizeChanged(width, mBottom - mTop, width, oldHeight); if (!mMatrixIsIdentity) { + if ((mPrivateFlags & PIVOT_EXPLICITLY_SET) == 0) { + // A change in dimension means an auto-centered pivot point changes, too + mMatrixDirty = true; + } mPrivateFlags |= DRAWN; // force another invalidation with the new orientation invalidate(); } @@ -5936,6 +5944,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility onSizeChanged(mRight - mLeft, height, oldWidth, height); if (!mMatrixIsIdentity) { + if ((mPrivateFlags & PIVOT_EXPLICITLY_SET) == 0) { + // A change in dimension means an auto-centered pivot point changes, too + mMatrixDirty = true; + } mPrivateFlags |= DRAWN; // force another invalidation with the new orientation invalidate(); } @@ -5989,6 +6001,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility onSizeChanged(mRight - mLeft, height, oldWidth, height); if (!mMatrixIsIdentity) { + if ((mPrivateFlags & PIVOT_EXPLICITLY_SET) == 0) { + // A change in dimension means an auto-centered pivot point changes, too + mMatrixDirty = true; + } mPrivateFlags |= DRAWN; // force another invalidation with the new orientation invalidate(); } @@ -8691,6 +8707,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility int newHeight = bottom - top; if (newWidth != oldWidth || newHeight != oldHeight) { + if ((mPrivateFlags & PIVOT_EXPLICITLY_SET) == 0) { + // A change in dimension means an auto-centered pivot point changes, too + mMatrixDirty = true; + } onSizeChanged(newWidth, newHeight, oldWidth, oldHeight); } @@ -8698,7 +8718,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility // If we are visible, force the DRAWN bit to on so that // this invalidate will go through (at least to our parent). // This is because someone may have invalidated this view - // before this call to setFrame came in, therby clearing + // before this call to setFrame came in, thereby clearing // the DRAWN bit. mPrivateFlags |= DRAWN; invalidate();