Lightbox: have animation times passed as parameters to show() and hide()

This way it is possible to use the same lightbox with different
times.

https://bugzilla.gnome.org/show_bug.cgi?id=699112
This commit is contained in:
Giovanni Campagna 2013-05-12 17:39:44 +02:00
parent 32613ba544
commit 6b8339e9b4
2 changed files with 13 additions and 15 deletions

View File

@ -42,15 +42,11 @@ const Lightbox = new Lang.Class({
params = Params.parse(params, { inhibitEvents: false,
width: null,
height: null,
fadeInTime: null,
fadeOutTime: null,
fadeFactor: DEFAULT_FADE_FACTOR
fadeFactor: DEFAULT_FADE_FACTOR,
});
this._container = container;
this._children = container.get_children();
this._fadeInTime = params.fadeInTime;
this._fadeOutTime = params.fadeOutTime;
this._fadeFactor = params.fadeFactor;
this.actor = new St.Bin({ x: 0,
y: 0,
@ -101,14 +97,16 @@ const Lightbox = new Lang.Class({
}
},
show: function() {
show: function(fadeInTime) {
fadeInTime = fadeInTime || 0;
Tweener.removeTweens(this.actor);
if (this._fadeInTime) {
if (fadeInTime != 0) {
this.shown = false;
this.actor.opacity = 0;
Tweener.addTween(this.actor,
{ opacity: 255 * this._fadeFactor,
time: this._fadeInTime,
time: fadeInTime,
transition: 'easeOutQuad',
onComplete: Lang.bind(this, function() {
this.shown = true;
@ -123,13 +121,15 @@ const Lightbox = new Lang.Class({
this.actor.show();
},
hide: function() {
hide: function(fadeOutTime) {
fadeOutTime = fadeOutTime || 0;
this.shown = false;
Tweener.removeTweens(this.actor);
if (this._fadeOutTime) {
if (fadeOutTime != 0) {
Tweener.addTween(this.actor,
{ opacity: 0,
time: this._fadeOutTime,
time: fadeOutTime,
transition: 'easeOutQuad',
onComplete: Lang.bind(this, function() {
this.actor.hide();

View File

@ -1730,8 +1730,6 @@ const MessageTray = new Lang.Class({
for (let i = 0; i < lightboxContainers.length; i++)
this._lightboxes.push(new Lightbox.Lightbox(lightboxContainers[i],
{ inhibitEvents: true,
fadeInTime: ANIMATION_TIME,
fadeOutTime: ANIMATION_TIME,
fadeFactor: 0.2
}));
@ -2339,7 +2337,7 @@ const MessageTray = new Lang.Class({
});
for (let i = 0; i < this._lightboxes.length; i++)
this._lightboxes[i].show();
this._lightboxes[i].show(ANIMATION_TIME);
return true;
},
@ -2395,7 +2393,7 @@ const MessageTray = new Lang.Class({
// This is a no-op in that case.
this._grabHelper.ungrab({ actor: this.actor });
for (let i = 0; i < this._lightboxes.length; i++)
this._lightboxes[i].hide();
this._lightboxes[i].hide(ANIMATION_TIME);
},
_hideDesktopClone: function() {