popupMenu: don't animate menus when switching from one to another

Don't do the "slide" effect when moving from one menu to another; only
do it when opening the first menu, or closing a menu without opening
another one.

https://bugzilla.gnome.org/show_bug.cgi?id=634755
This commit is contained in:
Dan Winship 2010-11-18 16:18:54 -05:00
parent 7d0eeef90a
commit 1694148bdb
3 changed files with 80 additions and 78 deletions

View File

@ -42,7 +42,7 @@ BoxPointer.prototype = {
this.bin.raise(this._border); this.bin.raise(this._border);
}, },
animateAppear: function(onComplete) { show: function(animate, onComplete) {
let x = this.actor.x; let x = this.actor.x;
let y = this.actor.y; let y = this.actor.y;
let themeNode = this.actor.get_theme_node(); let themeNode = this.actor.get_theme_node();
@ -51,19 +51,21 @@ BoxPointer.prototype = {
this.actor.opacity = 0; this.actor.opacity = 0;
this.actor.show(); this.actor.show();
switch (this._arrowSide) { if (animate) {
case St.Side.TOP: switch (this._arrowSide) {
this.actor.y -= rise; case St.Side.TOP:
break; this.actor.y -= rise;
case St.Side.BOTTOM: break;
this.actor.y += rise; case St.Side.BOTTOM:
break; this.actor.y += rise;
case St.Side.LEFT: break;
this.actor.x -= rise; case St.Side.LEFT:
break; this.actor.x -= rise;
case St.Side.RIGHT: break;
this.actor.x += rise; case St.Side.RIGHT:
break; this.actor.x += rise;
break;
}
} }
Tweener.addTween(this.actor, { opacity: 255, Tweener.addTween(this.actor, { opacity: 255,
@ -74,7 +76,7 @@ BoxPointer.prototype = {
time: POPUP_ANIMATION_TIME }); time: POPUP_ANIMATION_TIME });
}, },
animateDisappear: function(onComplete) { hide: function(animate, onComplete) {
let x = this.actor.x; let x = this.actor.x;
let y = this.actor.y; let y = this.actor.y;
let originalX = this.actor.x; let originalX = this.actor.x;
@ -82,19 +84,21 @@ BoxPointer.prototype = {
let themeNode = this.actor.get_theme_node(); let themeNode = this.actor.get_theme_node();
let rise = themeNode.get_length('-arrow-rise'); let rise = themeNode.get_length('-arrow-rise');
switch (this._arrowSide) { if (animate) {
case St.Side.TOP: switch (this._arrowSide) {
y += rise; case St.Side.TOP:
break; y += rise;
case St.Side.BOTTOM: break;
y -= rise; case St.Side.BOTTOM:
break; y -= rise;
case St.Side.LEFT: break;
x += rise; case St.Side.LEFT:
break; x += rise;
case St.Side.RIGHT: break;
x -= rise; case St.Side.RIGHT:
break; x -= rise;
break;
}
} }
Tweener.addTween(this.actor, { opacity: 0, Tweener.addTween(this.actor, { opacity: 0,

View File

@ -1676,7 +1676,7 @@ MessageTray.prototype = {
this._adjustNotificationBoxPointerPosition(); this._adjustNotificationBoxPointerPosition();
this._summaryNotificationState = State.SHOWING; this._summaryNotificationState = State.SHOWING;
this._summaryNotificationBoxPointer.animateAppear(Lang.bind(this, function() { this._summaryNotificationBoxPointer.show(true, Lang.bind(this, function() {
this._summaryNotificationState = State.SHOWN; this._summaryNotificationState = State.SHOWN;
})); }));
}, },
@ -1715,7 +1715,7 @@ MessageTray.prototype = {
this._summaryNotification.ungrabFocus(); this._summaryNotification.ungrabFocus();
this._summaryNotificationState = State.HIDING; this._summaryNotificationState = State.HIDING;
this._summaryNotificationBoxPointer.animateDisappear(Lang.bind(this, this._hideSummaryNotificationCompleted)); this._summaryNotificationBoxPointer.hide(true, Lang.bind(this, this._hideSummaryNotificationCompleted));
}, },
_hideSummaryNotificationCompleted: function() { _hideSummaryNotificationCompleted: function() {

View File

@ -642,7 +642,7 @@ PopupMenuBase.prototype = {
this.box.insert_actor(menuItem.menu.actor, position + 1); this.box.insert_actor(menuItem.menu.actor, position + 1);
menuItem._subMenuActivateId = menuItem.menu.connect('activate', Lang.bind(this, function() { menuItem._subMenuActivateId = menuItem.menu.connect('activate', Lang.bind(this, function() {
this.emit('activate'); this.emit('activate');
this.close(); this.close(true);
})); }));
menuItem._subMenuActiveChangeId = menuItem.menu.connect('active-changed', Lang.bind(this, function(submenu, submenuItem) { menuItem._subMenuActiveChangeId = menuItem.menu.connect('active-changed', Lang.bind(this, function(submenu, submenuItem) {
if (this._activeMenuItem && this._activeMenuItem != submenuItem) if (this._activeMenuItem && this._activeMenuItem != submenuItem)
@ -652,7 +652,7 @@ PopupMenuBase.prototype = {
})); }));
menuItem._closingId = this.connect('open-state-changed', function(self, open) { menuItem._closingId = this.connect('open-state-changed', function(self, open) {
if (!open) if (!open)
menuItem.menu.immediateClose(); menuItem.menu.close(false);
}); });
} }
menuItem._activeChangeId = menuItem.connect('active-changed', Lang.bind(this, function (menuItem, active) { menuItem._activeChangeId = menuItem.connect('active-changed', Lang.bind(this, function (menuItem, active) {
@ -668,7 +668,7 @@ PopupMenuBase.prototype = {
})); }));
menuItem._activateId = menuItem.connect('activate', Lang.bind(this, function (menuItem, event) { menuItem._activateId = menuItem.connect('activate', Lang.bind(this, function (menuItem, event) {
this.emit('activate', menuItem); this.emit('activate', menuItem);
this.close(); this.close(true);
})); }));
menuItem.connect('destroy', Lang.bind(this, function(emitter) { menuItem.connect('destroy', Lang.bind(this, function(emitter) {
menuItem.disconnect(menuItem._activateId); menuItem.disconnect(menuItem._activateId);
@ -735,9 +735,9 @@ PopupMenuBase.prototype = {
toggle: function() { toggle: function() {
if (this.isOpen) if (this.isOpen)
this.close(); this.close(true);
else else
this.open(); this.open(true);
}, },
destroy: function() { destroy: function() {
@ -802,26 +802,26 @@ PopupMenu.prototype = {
this._boxPointer.setArrowOrigin(origin); this._boxPointer.setArrowOrigin(origin);
}, },
open: function() { open: function(animate) {
if (this.isOpen) if (this.isOpen)
return; return;
this.isOpen = true; this.isOpen = true;
this._boxPointer.setPosition(this.sourceActor, this._gap, this._alignment); this._boxPointer.setPosition(this.sourceActor, this._gap, this._alignment);
this._boxPointer.animateAppear(); this._boxPointer.show(animate);
this.emit('open-state-changed', true); this.emit('open-state-changed', true);
}, },
close: function() { close: function(animate) {
if (!this.isOpen) if (!this.isOpen)
return; return;
if (this._activeMenuItem) if (this._activeMenuItem)
this._activeMenuItem.setActive(false); this._activeMenuItem.setActive(false);
this._boxPointer.animateDisappear(); this._boxPointer.hide(animate);
this.isOpen = false; this.isOpen = false;
this.emit('open-state-changed', false); this.emit('open-state-changed', false);
@ -848,12 +848,15 @@ PopupSubMenu.prototype = {
this.actor.hide(); this.actor.hide();
}, },
open: function() { open: function(animate) {
if (this.isOpen) if (this.isOpen)
return; return;
this.isOpen = true; this.isOpen = true;
// we don't implement the !animate case because that doesn't
// currently get used...
let [naturalHeight, minHeight] = this.actor.get_preferred_height(-1); let [naturalHeight, minHeight] = this.actor.get_preferred_height(-1);
this.actor.height = 0; this.actor.height = 0;
this.actor.show(); this.actor.show();
@ -874,7 +877,7 @@ PopupSubMenu.prototype = {
}); });
}, },
close: function() { close: function(animate) {
if (!this.isOpen) if (!this.isOpen)
return; return;
@ -883,44 +886,38 @@ PopupSubMenu.prototype = {
if (this._activeMenuItem) if (this._activeMenuItem)
this._activeMenuItem.setActive(false); this._activeMenuItem.setActive(false);
this.actor._arrow_rotation = this._arrow.rotation_angle_z; if (animate) {
Tweener.addTween(this.actor, this.actor._arrow_rotation = this._arrow.rotation_angle_z;
{ _arrow_rotation: 0, Tweener.addTween(this.actor,
height: 0, { _arrow_rotation: 0,
time: 0.25, height: 0,
onCompleteScope: this, time: 0.25,
onComplete: function() { onCompleteScope: this,
this.actor.hide(); onComplete: function() {
this.actor.set_height(-1); this.actor.hide();
this.actor.set_height(-1);
this.emit('open-state-changed', false); this.emit('open-state-changed', false);
}, },
onUpdateScope: this, onUpdateScope: this,
onUpdate: function() { onUpdate: function() {
this._arrow.rotation_angle_z = this.actor._arrow_rotation; this._arrow.rotation_angle_z = this.actor._arrow_rotation;
} }
}); });
}, } else {
this._arrow.rotation_angle_z = 0;
this.actor.hide();
immediateClose: function() { this.isOpen = false;
if (!this.isOpen) this.emit('open-state-changed', false);
return; }
if (this._activeMenuItem)
this._activeMenuItem.setActive(false);
this._arrow.rotation_angle_z = 0;
this.actor.hide();
this.isOpen = false;
this.emit('open-state-changed', false);
}, },
_onKeyPressEvent: function(actor, event) { _onKeyPressEvent: function(actor, event) {
// Move focus back to parent menu if the user types Left. // Move focus back to parent menu if the user types Left.
if (this.isOpen && event.get_key_symbol() == Clutter.KEY_Left) { if (this.isOpen && event.get_key_symbol() == Clutter.KEY_Left) {
this.close(); this.close(true);
this.sourceActor._delegate.setActive(true); this.sourceActor._delegate.setActive(true);
return true; return true;
} }
@ -964,7 +961,7 @@ PopupSubMenuMenuItem.prototype = {
_onKeyPressEvent: function(actor, event) { _onKeyPressEvent: function(actor, event) {
if (event.get_key_symbol() == Clutter.KEY_Right) { if (event.get_key_symbol() == Clutter.KEY_Right) {
this.menu.open(); this.menu.open(true);
this.menu.activateFirst(); this.menu.activateFirst();
return true; return true;
} }
@ -972,7 +969,7 @@ PopupSubMenuMenuItem.prototype = {
}, },
activate: function(event) { activate: function(event) {
this.menu.open(); this.menu.open(true);
}, },
_onButtonReleaseEvent: function(actor) { _onButtonReleaseEvent: function(actor) {
@ -1118,9 +1115,10 @@ PopupMenuManager.prototype = {
// before closing it to keep that from happening // before closing it to keep that from happening
let oldMenu = this._activeMenu; let oldMenu = this._activeMenu;
this._activeMenu = null; this._activeMenu = null;
oldMenu.close(); oldMenu.close(false);
} newMenu.open(false);
newMenu.open(); } else
newMenu.open(true);
}, },
_onMenuSourceEnter: function(menu) { _onMenuSourceEnter: function(menu) {
@ -1152,7 +1150,7 @@ PopupMenuManager.prototype = {
return; return;
if (focus._delegate && this._findMenu(focus._delegate.menu) != -1) if (focus._delegate && this._findMenu(focus._delegate.menu) != -1)
return; return;
menu.close(); menu.close(true);
})); }));
}, },
@ -1240,6 +1238,6 @@ PopupMenuManager.prototype = {
_closeMenu: function() { _closeMenu: function() {
if (this._activeMenu != null) if (this._activeMenu != null)
this._activeMenu.close(); this._activeMenu.close(true);
} }
}; };