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:
parent
7d0eeef90a
commit
1694148bdb
@ -42,7 +42,7 @@ BoxPointer.prototype = {
|
||||
this.bin.raise(this._border);
|
||||
},
|
||||
|
||||
animateAppear: function(onComplete) {
|
||||
show: function(animate, onComplete) {
|
||||
let x = this.actor.x;
|
||||
let y = this.actor.y;
|
||||
let themeNode = this.actor.get_theme_node();
|
||||
@ -51,19 +51,21 @@ BoxPointer.prototype = {
|
||||
this.actor.opacity = 0;
|
||||
this.actor.show();
|
||||
|
||||
switch (this._arrowSide) {
|
||||
case St.Side.TOP:
|
||||
this.actor.y -= rise;
|
||||
break;
|
||||
case St.Side.BOTTOM:
|
||||
this.actor.y += rise;
|
||||
break;
|
||||
case St.Side.LEFT:
|
||||
this.actor.x -= rise;
|
||||
break;
|
||||
case St.Side.RIGHT:
|
||||
this.actor.x += rise;
|
||||
break;
|
||||
if (animate) {
|
||||
switch (this._arrowSide) {
|
||||
case St.Side.TOP:
|
||||
this.actor.y -= rise;
|
||||
break;
|
||||
case St.Side.BOTTOM:
|
||||
this.actor.y += rise;
|
||||
break;
|
||||
case St.Side.LEFT:
|
||||
this.actor.x -= rise;
|
||||
break;
|
||||
case St.Side.RIGHT:
|
||||
this.actor.x += rise;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Tweener.addTween(this.actor, { opacity: 255,
|
||||
@ -74,7 +76,7 @@ BoxPointer.prototype = {
|
||||
time: POPUP_ANIMATION_TIME });
|
||||
},
|
||||
|
||||
animateDisappear: function(onComplete) {
|
||||
hide: function(animate, onComplete) {
|
||||
let x = this.actor.x;
|
||||
let y = this.actor.y;
|
||||
let originalX = this.actor.x;
|
||||
@ -82,19 +84,21 @@ BoxPointer.prototype = {
|
||||
let themeNode = this.actor.get_theme_node();
|
||||
let rise = themeNode.get_length('-arrow-rise');
|
||||
|
||||
switch (this._arrowSide) {
|
||||
case St.Side.TOP:
|
||||
y += rise;
|
||||
break;
|
||||
case St.Side.BOTTOM:
|
||||
y -= rise;
|
||||
break;
|
||||
case St.Side.LEFT:
|
||||
x += rise;
|
||||
break;
|
||||
case St.Side.RIGHT:
|
||||
x -= rise;
|
||||
break;
|
||||
if (animate) {
|
||||
switch (this._arrowSide) {
|
||||
case St.Side.TOP:
|
||||
y += rise;
|
||||
break;
|
||||
case St.Side.BOTTOM:
|
||||
y -= rise;
|
||||
break;
|
||||
case St.Side.LEFT:
|
||||
x += rise;
|
||||
break;
|
||||
case St.Side.RIGHT:
|
||||
x -= rise;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Tweener.addTween(this.actor, { opacity: 0,
|
||||
|
@ -1676,7 +1676,7 @@ MessageTray.prototype = {
|
||||
this._adjustNotificationBoxPointerPosition();
|
||||
|
||||
this._summaryNotificationState = State.SHOWING;
|
||||
this._summaryNotificationBoxPointer.animateAppear(Lang.bind(this, function() {
|
||||
this._summaryNotificationBoxPointer.show(true, Lang.bind(this, function() {
|
||||
this._summaryNotificationState = State.SHOWN;
|
||||
}));
|
||||
},
|
||||
@ -1715,7 +1715,7 @@ MessageTray.prototype = {
|
||||
|
||||
this._summaryNotification.ungrabFocus();
|
||||
this._summaryNotificationState = State.HIDING;
|
||||
this._summaryNotificationBoxPointer.animateDisappear(Lang.bind(this, this._hideSummaryNotificationCompleted));
|
||||
this._summaryNotificationBoxPointer.hide(true, Lang.bind(this, this._hideSummaryNotificationCompleted));
|
||||
},
|
||||
|
||||
_hideSummaryNotificationCompleted: function() {
|
||||
|
@ -642,7 +642,7 @@ PopupMenuBase.prototype = {
|
||||
this.box.insert_actor(menuItem.menu.actor, position + 1);
|
||||
menuItem._subMenuActivateId = menuItem.menu.connect('activate', Lang.bind(this, function() {
|
||||
this.emit('activate');
|
||||
this.close();
|
||||
this.close(true);
|
||||
}));
|
||||
menuItem._subMenuActiveChangeId = menuItem.menu.connect('active-changed', Lang.bind(this, function(submenu, submenuItem) {
|
||||
if (this._activeMenuItem && this._activeMenuItem != submenuItem)
|
||||
@ -652,7 +652,7 @@ PopupMenuBase.prototype = {
|
||||
}));
|
||||
menuItem._closingId = this.connect('open-state-changed', function(self, open) {
|
||||
if (!open)
|
||||
menuItem.menu.immediateClose();
|
||||
menuItem.menu.close(false);
|
||||
});
|
||||
}
|
||||
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) {
|
||||
this.emit('activate', menuItem);
|
||||
this.close();
|
||||
this.close(true);
|
||||
}));
|
||||
menuItem.connect('destroy', Lang.bind(this, function(emitter) {
|
||||
menuItem.disconnect(menuItem._activateId);
|
||||
@ -735,9 +735,9 @@ PopupMenuBase.prototype = {
|
||||
|
||||
toggle: function() {
|
||||
if (this.isOpen)
|
||||
this.close();
|
||||
this.close(true);
|
||||
else
|
||||
this.open();
|
||||
this.open(true);
|
||||
},
|
||||
|
||||
destroy: function() {
|
||||
@ -802,26 +802,26 @@ PopupMenu.prototype = {
|
||||
this._boxPointer.setArrowOrigin(origin);
|
||||
},
|
||||
|
||||
open: function() {
|
||||
open: function(animate) {
|
||||
if (this.isOpen)
|
||||
return;
|
||||
|
||||
this.isOpen = true;
|
||||
|
||||
this._boxPointer.setPosition(this.sourceActor, this._gap, this._alignment);
|
||||
this._boxPointer.animateAppear();
|
||||
this._boxPointer.show(animate);
|
||||
|
||||
this.emit('open-state-changed', true);
|
||||
},
|
||||
|
||||
close: function() {
|
||||
close: function(animate) {
|
||||
if (!this.isOpen)
|
||||
return;
|
||||
|
||||
if (this._activeMenuItem)
|
||||
this._activeMenuItem.setActive(false);
|
||||
|
||||
this._boxPointer.animateDisappear();
|
||||
this._boxPointer.hide(animate);
|
||||
|
||||
this.isOpen = false;
|
||||
this.emit('open-state-changed', false);
|
||||
@ -848,12 +848,15 @@ PopupSubMenu.prototype = {
|
||||
this.actor.hide();
|
||||
},
|
||||
|
||||
open: function() {
|
||||
open: function(animate) {
|
||||
if (this.isOpen)
|
||||
return;
|
||||
|
||||
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);
|
||||
this.actor.height = 0;
|
||||
this.actor.show();
|
||||
@ -874,7 +877,7 @@ PopupSubMenu.prototype = {
|
||||
});
|
||||
},
|
||||
|
||||
close: function() {
|
||||
close: function(animate) {
|
||||
if (!this.isOpen)
|
||||
return;
|
||||
|
||||
@ -883,44 +886,38 @@ PopupSubMenu.prototype = {
|
||||
if (this._activeMenuItem)
|
||||
this._activeMenuItem.setActive(false);
|
||||
|
||||
this.actor._arrow_rotation = this._arrow.rotation_angle_z;
|
||||
Tweener.addTween(this.actor,
|
||||
{ _arrow_rotation: 0,
|
||||
height: 0,
|
||||
time: 0.25,
|
||||
onCompleteScope: this,
|
||||
onComplete: function() {
|
||||
this.actor.hide();
|
||||
this.actor.set_height(-1);
|
||||
if (animate) {
|
||||
this.actor._arrow_rotation = this._arrow.rotation_angle_z;
|
||||
Tweener.addTween(this.actor,
|
||||
{ _arrow_rotation: 0,
|
||||
height: 0,
|
||||
time: 0.25,
|
||||
onCompleteScope: this,
|
||||
onComplete: function() {
|
||||
this.actor.hide();
|
||||
this.actor.set_height(-1);
|
||||
|
||||
this.emit('open-state-changed', false);
|
||||
},
|
||||
onUpdateScope: this,
|
||||
onUpdate: function() {
|
||||
this._arrow.rotation_angle_z = this.actor._arrow_rotation;
|
||||
}
|
||||
});
|
||||
},
|
||||
this.emit('open-state-changed', false);
|
||||
},
|
||||
onUpdateScope: this,
|
||||
onUpdate: function() {
|
||||
this._arrow.rotation_angle_z = this.actor._arrow_rotation;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this._arrow.rotation_angle_z = 0;
|
||||
this.actor.hide();
|
||||
|
||||
immediateClose: function() {
|
||||
if (!this.isOpen)
|
||||
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);
|
||||
this.isOpen = false;
|
||||
this.emit('open-state-changed', false);
|
||||
}
|
||||
},
|
||||
|
||||
_onKeyPressEvent: function(actor, event) {
|
||||
// Move focus back to parent menu if the user types Left.
|
||||
|
||||
if (this.isOpen && event.get_key_symbol() == Clutter.KEY_Left) {
|
||||
this.close();
|
||||
this.close(true);
|
||||
this.sourceActor._delegate.setActive(true);
|
||||
return true;
|
||||
}
|
||||
@ -964,7 +961,7 @@ PopupSubMenuMenuItem.prototype = {
|
||||
|
||||
_onKeyPressEvent: function(actor, event) {
|
||||
if (event.get_key_symbol() == Clutter.KEY_Right) {
|
||||
this.menu.open();
|
||||
this.menu.open(true);
|
||||
this.menu.activateFirst();
|
||||
return true;
|
||||
}
|
||||
@ -972,7 +969,7 @@ PopupSubMenuMenuItem.prototype = {
|
||||
},
|
||||
|
||||
activate: function(event) {
|
||||
this.menu.open();
|
||||
this.menu.open(true);
|
||||
},
|
||||
|
||||
_onButtonReleaseEvent: function(actor) {
|
||||
@ -1118,9 +1115,10 @@ PopupMenuManager.prototype = {
|
||||
// before closing it to keep that from happening
|
||||
let oldMenu = this._activeMenu;
|
||||
this._activeMenu = null;
|
||||
oldMenu.close();
|
||||
}
|
||||
newMenu.open();
|
||||
oldMenu.close(false);
|
||||
newMenu.open(false);
|
||||
} else
|
||||
newMenu.open(true);
|
||||
},
|
||||
|
||||
_onMenuSourceEnter: function(menu) {
|
||||
@ -1152,7 +1150,7 @@ PopupMenuManager.prototype = {
|
||||
return;
|
||||
if (focus._delegate && this._findMenu(focus._delegate.menu) != -1)
|
||||
return;
|
||||
menu.close();
|
||||
menu.close(true);
|
||||
}));
|
||||
},
|
||||
|
||||
@ -1240,6 +1238,6 @@ PopupMenuManager.prototype = {
|
||||
|
||||
_closeMenu: function() {
|
||||
if (this._activeMenu != null)
|
||||
this._activeMenu.close();
|
||||
this._activeMenu.close(true);
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user