[gnome-maps/wip/mlundblad/touch-gestures: 2/2] mapView: WIP: implement swipe gesture to bring up the sidebar
- From: Marcus Lundblad <mlundblad src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/mlundblad/touch-gestures: 2/2] mapView: WIP: implement swipe gesture to bring up the sidebar
- Date: Fri, 20 Oct 2017 05:49:46 +0000 (UTC)
commit 16b022358e1c1aa79566499cf534a6e5cdc1af67
Author: Marcus Lundblad <ml update uu se>
Date: Thu Oct 19 23:54:16 2017 +0200
mapView: WIP: implement swipe gesture to bring up the sidebar
src/mapView.js | 17 +++++++++++++++++
1 files changed, 17 insertions(+), 0 deletions(-)
---
diff --git a/src/mapView.js b/src/mapView.js
index 363ae90..bceb3ec 100644
--- a/src/mapView.js
+++ b/src/mapView.js
@@ -24,6 +24,7 @@ const Clutter = imports.gi.Clutter;
const GObject = imports.gi.GObject;
const Geocode = imports.gi.GeocodeGlib;
const Gio = imports.gi.Gio;
+const Gtk = imports.gi.Gtk;
const GtkChamplain = imports.gi.GtkChamplain;
const Lang = imports.lang;
const Mainloop = imports.mainloop;
@@ -160,6 +161,7 @@ var MapView = new Lang.Class({
this._updateUserLocation.bind(this));
this._storeId = 0;
this._connectRouteSignals();
+ this._initGestures();
},
_initScale: function(view) {
@@ -201,6 +203,21 @@ var MapView = new Lang.Class({
return view;
},
+ _initGestures: function() {
+ this._swipeGesture =
+ new Gtk.GestureSwipe({ widget: this, 'touch-only': true });
+ this._panGesture = new Gtk.GesturePan({ widget: this,
+ 'touch-only': true,
+ orientation: Gtk.Orientation.HORIZONTAL });
+ // restrict to horizontal swiping by grouping with a horizontal pan
+ this._swipeGesture.group(this._panGesture);
+ this._swipeGesture.connect('swipe', this._onSwipe);
+ },
+
+ _onSwipe: function(gesture, velocityX, velocityY) {
+ Utils.debug('swipe: ' + velocityX + ', ' + velocityY);
+ },
+
/* create and store a route layer, pass true to get a dashed line */
_createRouteLayer: function(dashed, lineColor, width) {
let red = Color.parseColor(lineColor, 0);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]