diff --git a/js/ui/boxpointer.js b/js/ui/boxpointer.js index d09c8bf77..c83c31e42 100644 --- a/js/ui/boxpointer.js +++ b/js/ui/boxpointer.js @@ -9,6 +9,13 @@ const Shell = imports.gi.Shell; const Main = imports.ui.main; const Tweener = imports.ui.tweener; +const PopupAnimation = { + NONE: 0, + SLIDE: 1 << 0, + FADE: 1 << 1, + FULL: ~0, +}; + const POPUP_ANIMATION_TIME = 0.15; /** @@ -69,11 +76,16 @@ const BoxPointer = new Lang.Class({ show: function(animate, onComplete) { let themeNode = this.actor.get_theme_node(); let rise = themeNode.get_length('-arrow-rise'); + let animationTime = (animate & PopupAnimation.FULL) ? POPUP_ANIMATION_TIME : 0; + + if (animate & PopupAnimation.FADE) + this.opacity = 0; + else + this.opacity = 255; - this.opacity = 0; this.actor.show(); - if (animate) { + if (animate & PopupAnimation.SLIDE) { switch (this._arrowSide) { case St.Side.TOP: this.yOffset = -rise; @@ -99,7 +111,7 @@ const BoxPointer = new Lang.Class({ if (onComplete) onComplete(); }), - time: POPUP_ANIMATION_TIME }); + time: animationTime }); }, hide: function(animate, onComplete) { @@ -107,8 +119,10 @@ const BoxPointer = new Lang.Class({ let yOffset = 0; let themeNode = this.actor.get_theme_node(); let rise = themeNode.get_length('-arrow-rise'); + let fade = (animate & PopupAnimation.FADE); + let animationTime = (animate & PopupAnimation.FULL) ? POPUP_ANIMATION_TIME : 0; - if (animate) { + if (animate & PopupAnimation.SLIDE) { switch (this._arrowSide) { case St.Side.TOP: yOffset = rise; @@ -127,13 +141,14 @@ const BoxPointer = new Lang.Class({ this._muteInput(); - Tweener.addTween(this, { opacity: 0, + Tweener.addTween(this, { opacity: fade ? 0 : 255, xOffset: xOffset, yOffset: yOffset, transition: 'linear', - time: POPUP_ANIMATION_TIME, + time: animationTime, onComplete: Lang.bind(this, function () { this.actor.hide(); + this.opacity = 0; this.xOffset = 0; this.yOffset = 0; if (onComplete) diff --git a/js/ui/keyboard.js b/js/ui/keyboard.js index a5cd19983..645e41ef4 100644 --- a/js/ui/keyboard.js +++ b/js/ui/keyboard.js @@ -175,7 +175,7 @@ const Key = new Lang.Class({ this.actor.fake_release(); this._boxPointer.actor.raise_top(); this._boxPointer.setPosition(this.actor, 0.5); - this._boxPointer.show(true); + this._boxPointer.show(BoxPointer.PopupAnimation.FULL); this.actor.set_hover(false); if (!this._grabbed) { Main.pushModal(this.actor); @@ -186,7 +186,7 @@ const Key = new Lang.Class({ } else { if (this._grabbed) this._ungrab(); - this._boxPointer.hide(true); + this._boxPointer.hide(BoxPointer.PopupAnimation.FULL); } } }); diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js index 51d4be35e..03b9b086d 100644 --- a/js/ui/messageTray.js +++ b/js/ui/messageTray.js @@ -2477,7 +2477,7 @@ const MessageTray = new Lang.Class({ this._summaryBoxPointerState = State.SHOWING; this._clickedSummaryItem.actor.add_style_pseudo_class('selected'); - this._summaryBoxPointer.show(true, Lang.bind(this, function() { + this._summaryBoxPointer.show(BoxPointer.PopupAnimation.FULL, Lang.bind(this, function() { this._summaryBoxPointerState = State.SHOWN; })); }, @@ -2531,7 +2531,7 @@ const MessageTray = new Lang.Class({ this._summaryBoxPointer.actor.hide(); this._hideSummaryBoxPointerCompleted(); } else { - this._summaryBoxPointer.hide(true, Lang.bind(this, this._hideSummaryBoxPointerCompleted)); + this._summaryBoxPointer.hide(BoxPointer.PopupAnimation.FULL, Lang.bind(this, this._hideSummaryBoxPointerCompleted)); } }, diff --git a/js/ui/popupMenu.js b/js/ui/popupMenu.js index 873e3395b..54447caaa 100644 --- a/js/ui/popupMenu.js +++ b/js/ui/popupMenu.js @@ -942,7 +942,7 @@ const PopupMenuBase = new Lang.Class({ _connectSubMenuSignals: function(object, menu) { object._subMenuActivateId = menu.connect('activate', Lang.bind(this, function() { this.emit('activate'); - this.close(true); + this.close(BoxPointer.PopupAnimation.FULL); })); object._subMenuActiveChangeId = menu.connect('active-changed', Lang.bind(this, function(submenu, submenuItem) { if (this._activeMenuItem && this._activeMenuItem != submenuItem) @@ -977,7 +977,7 @@ const PopupMenuBase = new Lang.Class({ })); menuItem._activateId = menuItem.connect('activate', Lang.bind(this, function (menuItem, event) { this.emit('activate', menuItem); - this.close(true); + this.close(BoxPointer.PopupAnimation.FULL); })); // the weird name is to avoid a conflict with some random property // the menuItem may have, called destroyId @@ -1050,7 +1050,7 @@ const PopupMenuBase = new Lang.Class({ menuItem._closingId = this.connect('open-state-changed', function(self, open) { if (!open) - menuItem.close(false); + menuItem.close(BoxPointer.PopupAnimation.FADE); }); menuItem.connect('destroy', Lang.bind(this, function() { menuItem.disconnect(menuItem._subMenuActivateId); @@ -1067,7 +1067,7 @@ const PopupMenuBase = new Lang.Class({ this._connectItemSignals(menuItem); menuItem._closingId = this.connect('open-state-changed', function(self, open) { if (!open) - menuItem.menu.close(false); + menuItem.menu.close(BoxPointer.PopupAnimation.FADE); }); } else if (menuItem instanceof PopupSeparatorMenuItem) { this._connectItemSignals(menuItem); @@ -1154,9 +1154,9 @@ const PopupMenuBase = new Lang.Class({ toggle: function() { if (this.isOpen) - this.close(true); + this.close(BoxPointer.PopupAnimation.FULL); else - this.open(true); + this.open(BoxPointer.PopupAnimation.FULL); }, destroy: function() { @@ -1217,7 +1217,7 @@ const PopupMenu = new Lang.Class({ _onKeyPressEvent: function(actor, event) { if (event.get_key_symbol() == Clutter.Escape) { - this.close(true); + this.close(BoxPointer.PopupAnimation.FULL); return true; } @@ -1419,7 +1419,7 @@ const PopupSubMenu = new Lang.Class({ // Move focus back to parent menu if the user types Left. if (this.isOpen && event.get_key_symbol() == Clutter.KEY_Left) { - this.close(true); + this.close(BoxPointer.PopupAnimation.FULL); this.sourceActor._delegate.setActive(true); return true; } @@ -1501,7 +1501,7 @@ const PopupSubMenuMenuItem = new Lang.Class({ let symbol = event.get_key_symbol(); if (symbol == Clutter.KEY_Right) { - this.menu.open(true); + this.menu.open(BoxPointer.PopupAnimation.FULL); this.menu.actor.navigate_focus(null, Gtk.DirectionType.DOWN, false); return true; } else if (symbol == Clutter.KEY_Left && this.menu.isOpen) { @@ -1513,7 +1513,7 @@ const PopupSubMenuMenuItem = new Lang.Class({ }, activate: function(event) { - this.menu.open(true); + this.menu.open(BoxPointer.PopupAnimation.FULL); }, _onButtonReleaseEvent: function(actor) { @@ -1540,7 +1540,7 @@ const PopupComboMenu = new Lang.Class({ _onKeyPressEvent: function(actor, event) { if (event.get_key_symbol() == Clutter.Escape) { - this.close(true); + this.close(BoxPointer.PopupAnimation.FULL); return true; } @@ -2194,11 +2194,11 @@ const PopupMenuManager = new Lang.Class({ let oldMenu = this._activeMenu; this._activeMenu = null; for (let i = this._menuStack.length - 1; i >= 0; i--) - this._menuStack[i].close(false); - oldMenu.close(false); - newMenu.open(false); + this._menuStack[i].close(BoxPointer.PopupAnimation.FADE); + oldMenu.close(BoxPointer.PopupAnimation.FADE); + newMenu.open(BoxPointer.PopupAnimation.FADE); } else - newMenu.open(true); + newMenu.open(BoxPointer.PopupAnimation.FULL); }, _onMenuSourceEnter: function(menu) { @@ -2313,6 +2313,6 @@ const PopupMenuManager = new Lang.Class({ _closeMenu: function() { if (this._activeMenu != null) - this._activeMenu.close(true); + this._activeMenu.close(BoxPointer.PopupAnimation.FULL); } });