[gnome-shell/wip/grab-helper-top-panel: 3/20] popupMenu: Add smooth scrolling support for sliders
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/grab-helper-top-panel: 3/20] popupMenu: Add smooth scrolling support for sliders
- Date: Mon, 26 Nov 2012 21:39:38 +0000 (UTC)
commit 8ebbf442cde36d0ad129ab335c8e4e117ee9b28f
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Sun Nov 4 10:50:11 2012 -0500
popupMenu: Add smooth scrolling support for sliders
Allowing smooth scrolling on the Y axis to accurately adjust the value
of the slider.
https://bugzilla.gnome.org/show_bug.cgi?id=687573
js/ui/popupMenu.js | 17 +++++++++++++----
1 files changed, 13 insertions(+), 4 deletions(-)
---
diff --git a/js/ui/popupMenu.js b/js/ui/popupMenu.js
index a469388..d3180d5 100644
--- a/js/ui/popupMenu.js
+++ b/js/ui/popupMenu.js
@@ -658,14 +658,23 @@ const PopupSliderMenuItem = new Lang.Class({
_onScrollEvent: function (actor, event) {
let direction = event.get_scroll_direction();
+ let delta;
+
+ if (event.is_pointer_emulated())
+ return;
if (direction == Clutter.ScrollDirection.DOWN) {
- this._value = Math.max(0, this._value - SLIDER_SCROLL_STEP);
- }
- else if (direction == Clutter.ScrollDirection.UP) {
- this._value = Math.min(1, this._value + SLIDER_SCROLL_STEP);
+ delta = -SLIDER_SCROLL_STEP;
+ } else if (direction == Clutter.ScrollDirection.UP) {
+ delta = +SLIDER_SCROLL_STEP;
+ } else if (direction == Clutter.ScrollDirection.SMOOTH) {
+ let [dx, dy] = event.get_scroll_delta();
+ // Even though the slider is horizontal, use dy to match
+ // the UP/DOWN above.
+ delta = -dy / 10;
}
+ this._value = Math.min(Math.max(0, this._value + delta), 1);
this._slider.queue_repaint();
this.emit('value-changed', this._value);
},
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]