summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2011-02-28 15:13:46 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-02-28 15:13:46 -0800
commit494e600f5cc6598be80e3861730532f608432b41 (patch)
tree9074f63e523c25855dd3ac7c87aa4a8e64c198c0 /src
parentf7640c8bba304ba99c99afcd7393893eccc9a0d9 (diff)
parent185d71647c8859cae7a375773b31c03f2f22ade1 (diff)
downloadandroid_packages_apps_Trebuchet-494e600f5cc6598be80e3861730532f608432b41.tar.gz
android_packages_apps_Trebuchet-494e600f5cc6598be80e3861730532f608432b41.tar.bz2
android_packages_apps_Trebuchet-494e600f5cc6598be80e3861730532f608432b41.zip
Merge "Adding simple mouse-scrolling to launcher."
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher2/PagedView.java31
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();