From ce62d6288abccaf875d57755c52e1ac6a4dee574 Mon Sep 17 00:00:00 2001 From: Dennis Date: Tue, 27 Aug 2013 21:01:40 -0400 Subject: [PATCH] Bug 845747 - Add the pref "ui.scrolling.negate_wheel_scrollY" to mobile.js so that "scrollY" can be negated in JavaPanZoomController.java to allow a mouse scroll wheel to scroll the screen in the direction of choice depending on the true/false state of "mNegateWheelScrollY". r=kats --- mobile/android/app/mobile.js | 2 ++ .../base/gfx/JavaPanZoomController.java | 29 ++++++++++++++----- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/mobile/android/app/mobile.js b/mobile/android/app/mobile.js index 441586cfdf98..cd68d80a70aa 100644 --- a/mobile/android/app/mobile.js +++ b/mobile/android/app/mobile.js @@ -655,6 +655,8 @@ pref("ui.scrolling.overscroll_snap_limit", -1); pref("ui.scrolling.min_scrollable_distance", -1); // The axis lock mode for panning behaviour - set between standard, free and sticky pref("ui.scrolling.axis_lock_mode", "standard"); +// Negate scrollY, true will make the mouse scroll wheel move the screen the same direction as with most desktops or laptops. +pref("ui.scrolling.negate_wheel_scrollY", true); // Enable accessibility mode if platform accessibility is enabled. diff --git a/mobile/android/base/gfx/JavaPanZoomController.java b/mobile/android/base/gfx/JavaPanZoomController.java index ce410258323a..25ed3fb08d54 100644 --- a/mobile/android/base/gfx/JavaPanZoomController.java +++ b/mobile/android/base/gfx/JavaPanZoomController.java @@ -131,6 +131,8 @@ class JavaPanZoomController private AxisLockMode mMode; /* A medium-length tap/press is happening */ private boolean mMediumPress; + /* Used to change the scrollY direction */ + private boolean mNegateWheelScrollY; public JavaPanZoomController(PanZoomTarget target, View view, EventDispatcher eventDispatcher) { mTarget = target; @@ -150,14 +152,23 @@ class JavaPanZoomController mMode = AxisLockMode.STANDARD; - PrefsHelper.getPref("ui.scrolling.axis_lock_mode", new PrefsHelper.PrefHandlerBase() { + String[] prefs = { "ui.scrolling.axis_lock_mode", "ui.scrolling.negate_wheel_scrollY" }; + mNegateWheelScrollY = false; + PrefsHelper.getPrefs(prefs, new PrefsHelper.PrefHandlerBase() { @Override public void prefValue(String pref, String value) { - if (value.equals("standard")) { - mMode = AxisLockMode.STANDARD; - } else if (value.equals("free")) { - mMode = AxisLockMode.FREE; - } else { - mMode = AxisLockMode.STICKY; + if (pref.equals("ui.scrolling.axis_lock_mode")) { + if (value.equals("standard")) { + mMode = AxisLockMode.STANDARD; + } else if (value.equals("free")) { + mMode = AxisLockMode.FREE; + } else { + mMode = AxisLockMode.STICKY; + } + } + } + @Override public void prefValue(String pref, boolean value) { + if (pref.equals("ui.scrolling.negate_wheel_scrollY")) { + mNegateWheelScrollY = value; } } @@ -555,7 +566,9 @@ class JavaPanZoomController if (mState == PanZoomState.NOTHING || mState == PanZoomState.FLING) { float scrollX = event.getAxisValue(MotionEvent.AXIS_HSCROLL); float scrollY = event.getAxisValue(MotionEvent.AXIS_VSCROLL); - + if (mNegateWheelScrollY) { + scrollY *= -1.0; + } scrollBy(scrollX * MAX_SCROLL, scrollY * MAX_SCROLL); bounce(); return true;