[gnome-shell/wip/re-search-v2: 29/29] overview: streamline sides state change
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/re-search-v2: 29/29] overview: streamline sides state change
- Date: Tue, 4 Dec 2012 18:40:46 +0000 (UTC)
commit 2cbd8e2ba8b78142454d4ac73ee1734b3e9ee38e
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Tue Dec 4 00:16:28 2012 -0500
overview: streamline sides state change
Instead of dirty tricks like connecting to "notify::visible" on the dash
after we hide it, split the page-change signal into
before/after-page-change, and turn setSideControlsVisibility() into a
better state machine.
js/ui/overview.js | 74 ++++++++++++++++++++++++++++++------------------
js/ui/viewSelector.js | 8 ++++-
2 files changed, 52 insertions(+), 30 deletions(-)
---
diff --git a/js/ui/overview.js b/js/ui/overview.js
index 4be363c..8187028 100644
--- a/js/ui/overview.js
+++ b/js/ui/overview.js
@@ -98,6 +98,13 @@ const ShellInfo = new Lang.Class({
}
});
+const ControlsChange = {
+ BEFORE_PAGE: 1,
+ AFTER_PAGE: 2,
+ DND_START: 3,
+ DND_END: 4
+};
+
const Overview = new Lang.Class({
Name: 'Overview',
@@ -268,29 +275,33 @@ const Overview = new Lang.Class({
y_fill: true });
this._overview.add_actor(this._messageTrayGhost);
- this._viewSelector.connect('page-changed', Lang.bind(this,
+ this._viewSelector.connect('after-page-change', Lang.bind(this,
+ function() {
+ this._setSideControlsVisibility(ControlsChange.AFTER_PAGE);
+ }));
+ this._viewSelector.connect('before-page-change', Lang.bind(this,
function() {
- this._setSideControlsVisibility(false);
+ this._setSideControlsVisibility(ControlsChange.BEFORE_PAGE);
}));
this.connect('item-drag-begin', Lang.bind(this,
function() {
- this._setSideControlsVisibility(true);
+ this._setSideControlsVisibility(ControlsChange.DND_START);
}));
this.connect('item-drag-cancelled', Lang.bind(this,
function() {
- this._setSideControlsVisibility(false);
+ this._setSideControlsVisibility(ControlsChange.DND_END);
}));
this.connect('item-drag-end', Lang.bind(this,
function() {
- this._setSideControlsVisibility(false);
+ this._setSideControlsVisibility(ControlsChange.DND_END);
}));
Main.layoutManager.connect('monitors-changed', Lang.bind(this, this._relayout));
this._relayout();
},
- _setSideControlsVisibility: function(inDrag) {
+ _setSideControlsVisibility: function(changeType) {
// Ignore the case when we're leaving the overview, since
// actors will be made visible again when entering the overview
// next time, and animating them while doing so is just
@@ -300,34 +311,41 @@ const Overview = new Lang.Class({
let appsActive = this._viewSelector.getAppsActive();
let searchActive = this._viewSelector.getSearchActive();
-
- let dashVisible = !searchActive || inDrag;
- let thumbnailsVisible = (!searchActive && !appsActive) || inDrag;
+ let dashVisible = !searchActive || (changeType == ControlsChange.DND_START);
+ let thumbnailsVisible = (!searchActive && !appsActive) || (changeType == ControlsChange.DND_START);
let trayVisible = !searchActive;
let trayGhostVisible = trayVisible || dashVisible;
- if (dashVisible) {
- this._dash.show();
- this._messageTrayGhost.visible = trayGhostVisible;
- } else {
- let visibleId = this._dash.actor.connect('notify::visible', Lang.bind(this,
- function() {
- this._dash.actor.disconnect(visibleId);
- if (!trayVisible && !this._dash.actor.visible)
- this._messageTrayGhost.hide();
- }));
- this._dash.hide();
+ if ((changeType == ControlsChange.BEFORE_PAGE) ||
+ (changeType == ControlsChange.DND_START)) {
+ if (dashVisible)
+ this._dash.show();
+ if (thumbnailsVisible)
+ this._thumbnailsBox.show();
}
- if (thumbnailsVisible)
- this._thumbnailsBox.show();
- else
- this._thumbnailsBox.hide();
+ if ((changeType == ControlsChange.BEFORE_PAGE) ||
+ (changeType == ControlsChange.DND_END)) {
+ if (!dashVisible) {
+ this._dash.hide();
+ }
+ if (!thumbnailsVisible)
+ this._thumbnailsBox.hide();
+ }
- if (trayVisible)
- Main.messageTray.show();
- else
- Main.messageTray.hide();
+ if (changeType == ControlsChange.BEFORE_PAGE ||
+ changeType == ControlsChange.DND_START) {
+ if (trayGhostVisible)
+ this._messageTrayGhost.show();
+ if (trayVisible)
+ Main.messageTray.show();
+ else
+ Main.messageTray.hide();
+ } else if (changeType == ControlsChange.AFTER_PAGE ||
+ changeType == ControlsChange.DND_END) {
+ if (!trayGhostVisible)
+ this._messageTrayGhost.hide();
+ }
},
addSearchProvider: function(provider) {
diff --git a/js/ui/viewSelector.js b/js/ui/viewSelector.js
index 121a0d0..4b4df1d 100644
--- a/js/ui/viewSelector.js
+++ b/js/ui/viewSelector.js
@@ -204,16 +204,20 @@ const ViewSelector = new Lang.Class({
function() {
this._activePage.hide();
this._activePage = page;
- this.emit('page-changed');
})
});
}
+ this.emit('before-page-change');
page.show();
Tweener.addTween(page,
{ opacity: 255,
time: 0.1,
- transition: 'easeOutQuad'
+ transition: 'easeOutQuad',
+ onComplete: Lang.bind(this,
+ function() {
+ this.emit('after-page-change');
+ })
});
},
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]