boxpointer: add animateDisappear/animateAppear methods
https://bugzilla.gnome.org/show_bug.cgi?id=624900
This commit is contained in:
parent
ccaa3f4ebf
commit
4d18d54d9d
@ -5,6 +5,10 @@ const Lang = imports.lang;
|
|||||||
const St = imports.gi.St;
|
const St = imports.gi.St;
|
||||||
const Shell = imports.gi.Shell;
|
const Shell = imports.gi.Shell;
|
||||||
|
|
||||||
|
const Tweener = imports.ui.tweener;
|
||||||
|
|
||||||
|
const POPUP_ANIMATION_TIME = 0.15;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BoxPointer:
|
* BoxPointer:
|
||||||
* @side: A St.Side type; currently only St.Side.TOP is implemented
|
* @side: A St.Side type; currently only St.Side.TOP is implemented
|
||||||
@ -38,6 +42,80 @@ BoxPointer.prototype = {
|
|||||||
this.bin.raise(this._border);
|
this.bin.raise(this._border);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
animateAppear: function(onComplete) {
|
||||||
|
let x = this.actor.x;
|
||||||
|
let y = this.actor.y;
|
||||||
|
let themeNode = this.actor.get_theme_node();
|
||||||
|
let [found, rise] = themeNode.get_length('-arrow-rise', false);
|
||||||
|
if (!found)
|
||||||
|
rise = 0;
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
Tweener.addTween(this.actor, { opacity: 255,
|
||||||
|
x: x,
|
||||||
|
y: y,
|
||||||
|
transition: "linear",
|
||||||
|
onComplete: onComplete,
|
||||||
|
time: POPUP_ANIMATION_TIME });
|
||||||
|
},
|
||||||
|
|
||||||
|
animateDisappear: function(onComplete) {
|
||||||
|
let x = this.actor.x;
|
||||||
|
let y = this.actor.y;
|
||||||
|
let originalX = this.actor.x;
|
||||||
|
let originalY = this.actor.y;
|
||||||
|
let themeNode = this.actor.get_theme_node();
|
||||||
|
let [found, rise] = themeNode.get_length('-arrow-rise', false);
|
||||||
|
if (!found)
|
||||||
|
rise = 0;
|
||||||
|
|
||||||
|
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,
|
||||||
|
x: x,
|
||||||
|
y: y,
|
||||||
|
transition: "linear",
|
||||||
|
time: POPUP_ANIMATION_TIME,
|
||||||
|
onComplete: Lang.bind(this, function () {
|
||||||
|
this.actor.hide();
|
||||||
|
this.actor.x = originalX;
|
||||||
|
this.actor.y = originalY;
|
||||||
|
if (onComplete)
|
||||||
|
onComplete();
|
||||||
|
})
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
_adjustAllocationForArrow: function(isWidth, alloc) {
|
_adjustAllocationForArrow: function(isWidth, alloc) {
|
||||||
let themeNode = this.actor.get_theme_node();
|
let themeNode = this.actor.get_theme_node();
|
||||||
let found, borderWidth, base, rise;
|
let found, borderWidth, base, rise;
|
||||||
|
@ -16,8 +16,6 @@ const Tweener = imports.ui.tweener;
|
|||||||
const Gettext = imports.gettext.domain('gnome-shell');
|
const Gettext = imports.gettext.domain('gnome-shell');
|
||||||
const _ = Gettext.gettext;
|
const _ = Gettext.gettext;
|
||||||
|
|
||||||
const POPUP_ANIMATION_TIME = 0.1;
|
|
||||||
|
|
||||||
function Switch() {
|
function Switch() {
|
||||||
this._init.apply(this, arguments);
|
this._init.apply(this, arguments);
|
||||||
}
|
}
|
||||||
@ -639,11 +637,8 @@ PopupMenu.prototype = {
|
|||||||
this.actor.y = Math.floor(menuY);
|
this.actor.y = Math.floor(menuY);
|
||||||
|
|
||||||
// Now show it
|
// Now show it
|
||||||
this.actor.opacity = 0;
|
|
||||||
this.actor.reactive = true;
|
this.actor.reactive = true;
|
||||||
Tweener.addTween(this.actor, { opacity: 255,
|
this._boxPointer.animateAppear();
|
||||||
transition: "easeOutQuad",
|
|
||||||
time: POPUP_ANIMATION_TIME });
|
|
||||||
this.isOpen = true;
|
this.isOpen = true;
|
||||||
this.emit('open-state-changed', true);
|
this.emit('open-state-changed', true);
|
||||||
},
|
},
|
||||||
@ -657,11 +652,7 @@ PopupMenu.prototype = {
|
|||||||
if (this._activeMenuItem)
|
if (this._activeMenuItem)
|
||||||
this._activeMenuItem.setActive(false);
|
this._activeMenuItem.setActive(false);
|
||||||
this.actor.reactive = false;
|
this.actor.reactive = false;
|
||||||
Tweener.addTween(this.actor, { opacity: 0,
|
this._boxPointer.animateDisappear();
|
||||||
transition: "easeOutQuad",
|
|
||||||
time: POPUP_ANIMATION_TIME,
|
|
||||||
onComplete: Lang.bind(this, function () { this.actor.hide(); })});
|
|
||||||
|
|
||||||
this.isOpen = false;
|
this.isOpen = false;
|
||||||
this.emit('open-state-changed', false);
|
this.emit('open-state-changed', false);
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user