[gnome-documents/gnome-3-16] preview: Toggle the controls when the user taps on a touchscreen
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-documents/gnome-3-16] preview: Toggle the controls when the user taps on a touchscreen
- Date: Wed, 25 Feb 2015 19:20:39 +0000 (UTC)
commit c1c2d62640eda9c923e792b95a4a6de457043635
Author: Debarshi Ray <debarshir gnome org>
Date: Wed Feb 25 18:39:40 2015 +0100
preview: Toggle the controls when the user taps on a touchscreen
Tapping on a touchscreen will toggle the visibility of the overlaid
controls without using an auto-hide timeout. The timeout is only used
when interacting with the mouse. Moving the mouse will continue to
reveal the controls and auto-hide them based on a timeout, as before.
To make the mouse and touchscreen interactions work together, the
queueing and unqueing of the timeout has been split out and used
explicitly where they are needed. An additional variable has been
introduced to control the visibility of the controls based on internal
conditions, as opposed to requests from external client code.
https://bugzilla.gnome.org/show_bug.cgi?id=741564
src/preview.js | 37 +++++++++++++++++++++++++++----------
1 files changed, 27 insertions(+), 10 deletions(-)
---
diff --git a/src/preview.js b/src/preview.js
index af096f3..db3d6d9 100644
--- a/src/preview.js
+++ b/src/preview.js
@@ -572,10 +572,10 @@ const PreviewNavControls = new Lang.Class({
this._overlay = overlay;
this._visible = false;
+ this._visibleInternal = false;
this._pageChangedId = 0;
this._autoHideId = 0;
this._motionId = 0;
- this._hover = false;
this.bar_widget = new GdPrivate.NavBar({ document_model: this._model,
margin: _PREVIEW_NAVBAR_MARGIN,
@@ -634,23 +634,28 @@ const PreviewNavControls = new Lang.Class({
this._overlay.connect('motion-notify-event', Lang.bind(this, this._onMotion));
+ this._tapGesture = new Gtk.GestureMultiPress({ propagation_phase: Gtk.PropagationPhase.CAPTURE,
+ touch_only: true,
+ widget: this._previewView.view });
+ this._tapGesture.connect('released', Lang.bind(this, this._onMultiPressReleased));
+ this._tapGesture.connect('stopped', Lang.bind(this, this._onMultiPressStopped));
},
_onEnterNotify: function() {
- this._hover = true;
this._unqueueAutoHide();
return false;
},
_onLeaveNotify: function() {
- this._hover = false;
this._queueAutoHide();
return false;
},
_motionTimeout: function() {
this._motionId = 0;
+ this._visibleInternal = true;
this._updateVisibility();
+ this._queueAutoHide();
return false;
},
@@ -668,6 +673,17 @@ const PreviewNavControls = new Lang.Class({
return false;
},
+ _onMultiPressReleased: function() {
+ this._tapGesture.set_state(Gtk.EventSequenceState.CLAIMED);
+ this._visibleInternal = !this._visibleInternal;
+ this._unqueueAutoHide();
+ this._updateVisibility();
+ },
+
+ _onMultiPressStopped: function() {
+ this._tapGesture.set_state(Gtk.EventSequenceState.DENIED);
+ },
+
_onPrevClicked: function() {
this._previewView.view.previous_page();
},
@@ -677,10 +693,9 @@ const PreviewNavControls = new Lang.Class({
},
_autoHide: function() {
- this._fadeOutButton(this.bar_widget);
- this._fadeOutButton(this.prev_widget);
- this._fadeOutButton(this.next_widget);
this._autoHideId = 0;
+ this._visibleInternal = false;
+ this._updateVisibility();
return false;
},
@@ -698,7 +713,7 @@ const PreviewNavControls = new Lang.Class({
},
_updateVisibility: function() {
- if (!this._model || !this._visible) {
+ if (!this._model || !this._visible || !this._visibleInternal) {
this._fadeOutButton(this.bar_widget);
this._fadeOutButton(this.prev_widget);
this._fadeOutButton(this.next_widget);
@@ -717,9 +732,6 @@ const PreviewNavControls = new Lang.Class({
this._fadeInButton(this.next_widget);
else
this._fadeOutButton(this.next_widget);
-
- if (!this._hover)
- this._queueAutoHide();
},
setModel: function(model) {
@@ -735,6 +747,7 @@ const PreviewNavControls = new Lang.Class({
this._pageChangedId = this._model.connect('page-changed', Lang.bind(this,
this._updateVisibility));
this._updateVisibility();
+ this._queueAutoHide();
},
_fadeInButton: function(widget) {
@@ -758,11 +771,14 @@ const PreviewNavControls = new Lang.Class({
show: function() {
this._visible = true;
+ this._visibleInternal = true;
this._updateVisibility();
+ this._queueAutoHide();
},
hide: function() {
this._visible = false;
+ this._visibleInternal = false;
this._updateVisibility();
},
@@ -770,6 +786,7 @@ const PreviewNavControls = new Lang.Class({
this.bar_widget.destroy();
this.prev_widget.destroy();
this.next_widget.destroy();
+ this._tapGesture = null;
}
});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]