diff options
author | Winson Chung <winsonc@google.com> | 2011-02-28 13:47:29 -0800 |
---|---|---|
committer | Winson Chung <winsonc@google.com> | 2011-02-28 15:13:23 -0800 |
commit | 185d71647c8859cae7a375773b31c03f2f22ade1 (patch) | |
tree | 7af65fa18b4305273700968b03388bf703396be4 /src/com/android/launcher2/PagedView.java | |
parent | 60b753b4cfa709efa55e05cdcd62a993330f3684 (diff) | |
download | android_packages_apps_Trebuchet-185d71647c8859cae7a375773b31c03f2f22ade1.tar.gz android_packages_apps_Trebuchet-185d71647c8859cae7a375773b31c03f2f22ade1.tar.bz2 android_packages_apps_Trebuchet-185d71647c8859cae7a375773b31c03f2f22ade1.zip |
Adding simple mouse-scrolling to launcher.
Change-Id: I7bd568bd56f272494137f45c07e2377f14e8faaf
Diffstat (limited to 'src/com/android/launcher2/PagedView.java')
-rw-r--r-- | src/com/android/launcher2/PagedView.java | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java index c2fcd9f21..26ea4a812 100644 --- a/src/com/android/launcher2/PagedView.java +++ b/src/com/android/launcher2/PagedView.java @@ -30,6 +30,8 @@ import android.os.Parcel; import android.os.Parcelable; import android.util.AttributeSet; import android.view.ActionMode; +import android.view.InputDevice; +import android.view.KeyEvent; import android.view.MotionEvent; import android.view.VelocityTracker; import android.view.View; @@ -1077,6 +1079,35 @@ public abstract class PagedView extends ViewGroup { return true; } + @Override + public boolean onGenericMotionEvent(MotionEvent event) { + if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0) { + switch (event.getAction()) { + case MotionEvent.ACTION_SCROLL: { + // Handle mouse (or ext. device) by shifting the page depending on the scroll + final float vscroll; + final float hscroll; + if ((event.getMetaState() & KeyEvent.META_SHIFT_ON) != 0) { + vscroll = 0; + hscroll = event.getAxisValue(MotionEvent.AXIS_VSCROLL); + } else { + vscroll = -event.getAxisValue(MotionEvent.AXIS_VSCROLL); + hscroll = event.getAxisValue(MotionEvent.AXIS_HSCROLL); + } + if (hscroll != 0 || vscroll != 0) { + if (hscroll > 0 || vscroll > 0) { + scrollRight(); + } else { + scrollLeft(); + } + return true; + } + } + } + } + return super.onGenericMotionEvent(event); + } + private void acquireVelocityTrackerAndAddMovement(MotionEvent ev) { if (mVelocityTracker == null) { mVelocityTracker = VelocityTracker.obtain(); |