boxpointer: Change 'animate' parameter on show/hide to a bitmask
This allows us to have more control of the animation. https://bugzilla.gnome.org/show_bug.cgi?id=678337
This commit is contained in:
parent
8d017ceaf1
commit
cf6f149888
@ -9,6 +9,13 @@ const Shell = imports.gi.Shell;
|
|||||||
const Main = imports.ui.main;
|
const Main = imports.ui.main;
|
||||||
const Tweener = imports.ui.tweener;
|
const Tweener = imports.ui.tweener;
|
||||||
|
|
||||||
|
const PopupAnimation = {
|
||||||
|
NONE: 0,
|
||||||
|
SLIDE: 1 << 0,
|
||||||
|
FADE: 1 << 1,
|
||||||
|
FULL: ~0,
|
||||||
|
};
|
||||||
|
|
||||||
const POPUP_ANIMATION_TIME = 0.15;
|
const POPUP_ANIMATION_TIME = 0.15;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -69,11 +76,16 @@ const BoxPointer = new Lang.Class({
|
|||||||
show: function(animate, onComplete) {
|
show: function(animate, onComplete) {
|
||||||
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');
|
||||||
|
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();
|
this.actor.show();
|
||||||
|
|
||||||
if (animate) {
|
if (animate & PopupAnimation.SLIDE) {
|
||||||
switch (this._arrowSide) {
|
switch (this._arrowSide) {
|
||||||
case St.Side.TOP:
|
case St.Side.TOP:
|
||||||
this.yOffset = -rise;
|
this.yOffset = -rise;
|
||||||
@ -99,7 +111,7 @@ const BoxPointer = new Lang.Class({
|
|||||||
if (onComplete)
|
if (onComplete)
|
||||||
onComplete();
|
onComplete();
|
||||||
}),
|
}),
|
||||||
time: POPUP_ANIMATION_TIME });
|
time: animationTime });
|
||||||
},
|
},
|
||||||
|
|
||||||
hide: function(animate, onComplete) {
|
hide: function(animate, onComplete) {
|
||||||
@ -107,8 +119,10 @@ const BoxPointer = new Lang.Class({
|
|||||||
let yOffset = 0;
|
let yOffset = 0;
|
||||||
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');
|
||||||
|
let fade = (animate & PopupAnimation.FADE);
|
||||||
|
let animationTime = (animate & PopupAnimation.FULL) ? POPUP_ANIMATION_TIME : 0;
|
||||||
|
|
||||||
if (animate) {
|
if (animate & PopupAnimation.SLIDE) {
|
||||||
switch (this._arrowSide) {
|
switch (this._arrowSide) {
|
||||||
case St.Side.TOP:
|
case St.Side.TOP:
|
||||||
yOffset = rise;
|
yOffset = rise;
|
||||||
@ -127,13 +141,14 @@ const BoxPointer = new Lang.Class({
|
|||||||
|
|
||||||
this._muteInput();
|
this._muteInput();
|
||||||
|
|
||||||
Tweener.addTween(this, { opacity: 0,
|
Tweener.addTween(this, { opacity: fade ? 0 : 255,
|
||||||
xOffset: xOffset,
|
xOffset: xOffset,
|
||||||
yOffset: yOffset,
|
yOffset: yOffset,
|
||||||
transition: 'linear',
|
transition: 'linear',
|
||||||
time: POPUP_ANIMATION_TIME,
|
time: animationTime,
|
||||||
onComplete: Lang.bind(this, function () {
|
onComplete: Lang.bind(this, function () {
|
||||||
this.actor.hide();
|
this.actor.hide();
|
||||||
|
this.opacity = 0;
|
||||||
this.xOffset = 0;
|
this.xOffset = 0;
|
||||||
this.yOffset = 0;
|
this.yOffset = 0;
|
||||||
if (onComplete)
|
if (onComplete)
|
||||||
|
@ -175,7 +175,7 @@ const Key = new Lang.Class({
|
|||||||
this.actor.fake_release();
|
this.actor.fake_release();
|
||||||
this._boxPointer.actor.raise_top();
|
this._boxPointer.actor.raise_top();
|
||||||
this._boxPointer.setPosition(this.actor, 0.5);
|
this._boxPointer.setPosition(this.actor, 0.5);
|
||||||
this._boxPointer.show(true);
|
this._boxPointer.show(BoxPointer.PopupAnimation.FULL);
|
||||||
this.actor.set_hover(false);
|
this.actor.set_hover(false);
|
||||||
if (!this._grabbed) {
|
if (!this._grabbed) {
|
||||||
Main.pushModal(this.actor);
|
Main.pushModal(this.actor);
|
||||||
@ -186,7 +186,7 @@ const Key = new Lang.Class({
|
|||||||
} else {
|
} else {
|
||||||
if (this._grabbed)
|
if (this._grabbed)
|
||||||
this._ungrab();
|
this._ungrab();
|
||||||
this._boxPointer.hide(true);
|
this._boxPointer.hide(BoxPointer.PopupAnimation.FULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -2477,7 +2477,7 @@ const MessageTray = new Lang.Class({
|
|||||||
|
|
||||||
this._summaryBoxPointerState = State.SHOWING;
|
this._summaryBoxPointerState = State.SHOWING;
|
||||||
this._clickedSummaryItem.actor.add_style_pseudo_class('selected');
|
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;
|
this._summaryBoxPointerState = State.SHOWN;
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
@ -2531,7 +2531,7 @@ const MessageTray = new Lang.Class({
|
|||||||
this._summaryBoxPointer.actor.hide();
|
this._summaryBoxPointer.actor.hide();
|
||||||
this._hideSummaryBoxPointerCompleted();
|
this._hideSummaryBoxPointerCompleted();
|
||||||
} else {
|
} else {
|
||||||
this._summaryBoxPointer.hide(true, Lang.bind(this, this._hideSummaryBoxPointerCompleted));
|
this._summaryBoxPointer.hide(BoxPointer.PopupAnimation.FULL, Lang.bind(this, this._hideSummaryBoxPointerCompleted));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -942,7 +942,7 @@ const PopupMenuBase = new Lang.Class({
|
|||||||
_connectSubMenuSignals: function(object, menu) {
|
_connectSubMenuSignals: function(object, menu) {
|
||||||
object._subMenuActivateId = menu.connect('activate', Lang.bind(this, function() {
|
object._subMenuActivateId = menu.connect('activate', Lang.bind(this, function() {
|
||||||
this.emit('activate');
|
this.emit('activate');
|
||||||
this.close(true);
|
this.close(BoxPointer.PopupAnimation.FULL);
|
||||||
}));
|
}));
|
||||||
object._subMenuActiveChangeId = menu.connect('active-changed', Lang.bind(this, function(submenu, submenuItem) {
|
object._subMenuActiveChangeId = menu.connect('active-changed', Lang.bind(this, function(submenu, submenuItem) {
|
||||||
if (this._activeMenuItem && this._activeMenuItem != 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) {
|
menuItem._activateId = menuItem.connect('activate', Lang.bind(this, function (menuItem, event) {
|
||||||
this.emit('activate', menuItem);
|
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 weird name is to avoid a conflict with some random property
|
||||||
// the menuItem may have, called destroyId
|
// the menuItem may have, called destroyId
|
||||||
@ -1050,7 +1050,7 @@ const PopupMenuBase = new Lang.Class({
|
|||||||
menuItem._closingId = this.connect('open-state-changed',
|
menuItem._closingId = this.connect('open-state-changed',
|
||||||
function(self, open) {
|
function(self, open) {
|
||||||
if (!open)
|
if (!open)
|
||||||
menuItem.close(false);
|
menuItem.close(BoxPointer.PopupAnimation.FADE);
|
||||||
});
|
});
|
||||||
menuItem.connect('destroy', Lang.bind(this, function() {
|
menuItem.connect('destroy', Lang.bind(this, function() {
|
||||||
menuItem.disconnect(menuItem._subMenuActivateId);
|
menuItem.disconnect(menuItem._subMenuActivateId);
|
||||||
@ -1067,7 +1067,7 @@ const PopupMenuBase = new Lang.Class({
|
|||||||
this._connectItemSignals(menuItem);
|
this._connectItemSignals(menuItem);
|
||||||
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.close(false);
|
menuItem.menu.close(BoxPointer.PopupAnimation.FADE);
|
||||||
});
|
});
|
||||||
} else if (menuItem instanceof PopupSeparatorMenuItem) {
|
} else if (menuItem instanceof PopupSeparatorMenuItem) {
|
||||||
this._connectItemSignals(menuItem);
|
this._connectItemSignals(menuItem);
|
||||||
@ -1154,9 +1154,9 @@ const PopupMenuBase = new Lang.Class({
|
|||||||
|
|
||||||
toggle: function() {
|
toggle: function() {
|
||||||
if (this.isOpen)
|
if (this.isOpen)
|
||||||
this.close(true);
|
this.close(BoxPointer.PopupAnimation.FULL);
|
||||||
else
|
else
|
||||||
this.open(true);
|
this.open(BoxPointer.PopupAnimation.FULL);
|
||||||
},
|
},
|
||||||
|
|
||||||
destroy: function() {
|
destroy: function() {
|
||||||
@ -1217,7 +1217,7 @@ const PopupMenu = new Lang.Class({
|
|||||||
|
|
||||||
_onKeyPressEvent: function(actor, event) {
|
_onKeyPressEvent: function(actor, event) {
|
||||||
if (event.get_key_symbol() == Clutter.Escape) {
|
if (event.get_key_symbol() == Clutter.Escape) {
|
||||||
this.close(true);
|
this.close(BoxPointer.PopupAnimation.FULL);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1419,7 +1419,7 @@ const PopupSubMenu = new Lang.Class({
|
|||||||
// 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(true);
|
this.close(BoxPointer.PopupAnimation.FULL);
|
||||||
this.sourceActor._delegate.setActive(true);
|
this.sourceActor._delegate.setActive(true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1501,7 +1501,7 @@ const PopupSubMenuMenuItem = new Lang.Class({
|
|||||||
let symbol = event.get_key_symbol();
|
let symbol = event.get_key_symbol();
|
||||||
|
|
||||||
if (symbol == Clutter.KEY_Right) {
|
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);
|
this.menu.actor.navigate_focus(null, Gtk.DirectionType.DOWN, false);
|
||||||
return true;
|
return true;
|
||||||
} else if (symbol == Clutter.KEY_Left && this.menu.isOpen) {
|
} else if (symbol == Clutter.KEY_Left && this.menu.isOpen) {
|
||||||
@ -1513,7 +1513,7 @@ const PopupSubMenuMenuItem = new Lang.Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
activate: function(event) {
|
activate: function(event) {
|
||||||
this.menu.open(true);
|
this.menu.open(BoxPointer.PopupAnimation.FULL);
|
||||||
},
|
},
|
||||||
|
|
||||||
_onButtonReleaseEvent: function(actor) {
|
_onButtonReleaseEvent: function(actor) {
|
||||||
@ -1540,7 +1540,7 @@ const PopupComboMenu = new Lang.Class({
|
|||||||
|
|
||||||
_onKeyPressEvent: function(actor, event) {
|
_onKeyPressEvent: function(actor, event) {
|
||||||
if (event.get_key_symbol() == Clutter.Escape) {
|
if (event.get_key_symbol() == Clutter.Escape) {
|
||||||
this.close(true);
|
this.close(BoxPointer.PopupAnimation.FULL);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2194,11 +2194,11 @@ const PopupMenuManager = new Lang.Class({
|
|||||||
let oldMenu = this._activeMenu;
|
let oldMenu = this._activeMenu;
|
||||||
this._activeMenu = null;
|
this._activeMenu = null;
|
||||||
for (let i = this._menuStack.length - 1; i >= 0; i--)
|
for (let i = this._menuStack.length - 1; i >= 0; i--)
|
||||||
this._menuStack[i].close(false);
|
this._menuStack[i].close(BoxPointer.PopupAnimation.FADE);
|
||||||
oldMenu.close(false);
|
oldMenu.close(BoxPointer.PopupAnimation.FADE);
|
||||||
newMenu.open(false);
|
newMenu.open(BoxPointer.PopupAnimation.FADE);
|
||||||
} else
|
} else
|
||||||
newMenu.open(true);
|
newMenu.open(BoxPointer.PopupAnimation.FULL);
|
||||||
},
|
},
|
||||||
|
|
||||||
_onMenuSourceEnter: function(menu) {
|
_onMenuSourceEnter: function(menu) {
|
||||||
@ -2313,6 +2313,6 @@ const PopupMenuManager = new Lang.Class({
|
|||||||
|
|
||||||
_closeMenu: function() {
|
_closeMenu: function() {
|
||||||
if (this._activeMenu != null)
|
if (this._activeMenu != null)
|
||||||
this._activeMenu.close(true);
|
this._activeMenu.close(BoxPointer.PopupAnimation.FULL);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user