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.
This commit is contained in:
Cosimo Cecchi 2012-12-04 00:16:28 -05:00
parent 3768e85673
commit 6c4daaaa71
2 changed files with 52 additions and 30 deletions

View File

@ -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({ const Overview = new Lang.Class({
Name: 'Overview', Name: 'Overview',
@ -268,29 +275,33 @@ const Overview = new Lang.Class({
y_fill: true }); y_fill: true });
this._overview.add_actor(this._messageTrayGhost); this._overview.add_actor(this._messageTrayGhost);
this._viewSelector.connect('page-changed', Lang.bind(this, this._viewSelector.connect('after-page-change', Lang.bind(this,
function() { function() {
this._setSideControlsVisibility(false); this._setSideControlsVisibility(ControlsChange.AFTER_PAGE);
}));
this._viewSelector.connect('before-page-change', Lang.bind(this,
function() {
this._setSideControlsVisibility(ControlsChange.BEFORE_PAGE);
})); }));
this.connect('item-drag-begin', Lang.bind(this, this.connect('item-drag-begin', Lang.bind(this,
function() { function() {
this._setSideControlsVisibility(true); this._setSideControlsVisibility(ControlsChange.DND_START);
})); }));
this.connect('item-drag-cancelled', Lang.bind(this, this.connect('item-drag-cancelled', Lang.bind(this,
function() { function() {
this._setSideControlsVisibility(false); this._setSideControlsVisibility(ControlsChange.DND_END);
})); }));
this.connect('item-drag-end', Lang.bind(this, this.connect('item-drag-end', Lang.bind(this,
function() { function() {
this._setSideControlsVisibility(false); this._setSideControlsVisibility(ControlsChange.DND_END);
})); }));
Main.layoutManager.connect('monitors-changed', Lang.bind(this, this._relayout)); Main.layoutManager.connect('monitors-changed', Lang.bind(this, this._relayout));
this._relayout(); this._relayout();
}, },
_setSideControlsVisibility: function(inDrag) { _setSideControlsVisibility: function(changeType) {
// Ignore the case when we're leaving the overview, since // Ignore the case when we're leaving the overview, since
// actors will be made visible again when entering the overview // actors will be made visible again when entering the overview
// next time, and animating them while doing so is just // 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 appsActive = this._viewSelector.getAppsActive();
let searchActive = this._viewSelector.getSearchActive(); let searchActive = this._viewSelector.getSearchActive();
let dashVisible = !searchActive || (changeType == ControlsChange.DND_START);
let dashVisible = !searchActive || inDrag; let thumbnailsVisible = (!searchActive && !appsActive) || (changeType == ControlsChange.DND_START);
let thumbnailsVisible = (!searchActive && !appsActive) || inDrag;
let trayVisible = !searchActive; let trayVisible = !searchActive;
let trayGhostVisible = trayVisible || dashVisible; let trayGhostVisible = trayVisible || dashVisible;
if (dashVisible) { if ((changeType == ControlsChange.BEFORE_PAGE) ||
(changeType == ControlsChange.DND_START)) {
if (dashVisible)
this._dash.show(); 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 (thumbnailsVisible) if (thumbnailsVisible)
this._thumbnailsBox.show(); 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 (changeType == ControlsChange.BEFORE_PAGE ||
changeType == ControlsChange.DND_START) {
if (trayGhostVisible)
this._messageTrayGhost.show();
if (trayVisible) if (trayVisible)
Main.messageTray.show(); Main.messageTray.show();
else else
Main.messageTray.hide(); Main.messageTray.hide();
} else if (changeType == ControlsChange.AFTER_PAGE ||
changeType == ControlsChange.DND_END) {
if (!trayGhostVisible)
this._messageTrayGhost.hide();
}
}, },
addSearchProvider: function(provider) { addSearchProvider: function(provider) {

View File

@ -204,16 +204,20 @@ const ViewSelector = new Lang.Class({
function() { function() {
this._activePage.hide(); this._activePage.hide();
this._activePage = page; this._activePage = page;
this.emit('page-changed');
}) })
}); });
} }
this.emit('before-page-change');
page.show(); page.show();
Tweener.addTween(page, Tweener.addTween(page,
{ opacity: 255, { opacity: 255,
time: 0.1, time: 0.1,
transition: 'easeOutQuad' transition: 'easeOutQuad',
onComplete: Lang.bind(this,
function() {
this.emit('after-page-change');
})
}); });
}, },