dash: Directly tween actors

Dash items are currently animated via the custom "childScale" and
"childOpacity" properties. However since commit efb3025d8c, those
properties actually control the scale-x/scale-y and opacity properties
of the actor itself (not the child), so cut out the intermediate
custom properties in favor of the "real" ones.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/22
This commit is contained in:
Florian Müllner 2018-07-21 07:08:33 +02:00
parent abe012b9fc
commit 8eb88d17fe

View File

@ -32,6 +32,9 @@ class DashItemContainer extends St.Widget {
_init() { _init() {
super._init({ style_class: 'dash-item-container', super._init({ style_class: 'dash-item-container',
pivot_point: new Clutter.Point({ x: .5, y: .5 }), pivot_point: new Clutter.Point({ x: .5, y: .5 }),
scale_x: 0,
scale_y: 0,
opacity: 0,
x_expand: true, x_expand: true,
x_align: Clutter.ActorAlign.CENTER }); x_align: Clutter.ActorAlign.CENTER });
@ -42,10 +45,11 @@ class DashItemContainer extends St.Widget {
this.label_actor = this.label; this.label_actor = this.label;
this.child = null; this.child = null;
this._childScale = 0;
this._childOpacity = 0;
this.animatingOut = false; this.animatingOut = false;
this.connect('notify::scale-x', () => this.queue_relayout());
this.connect('notify::scale-y', () => this.queue_relayout());
this.connect('destroy', () => { this.connect('destroy', () => {
if (this.child != null) if (this.child != null)
this.child.destroy(); this.child.destroy();
@ -127,9 +131,6 @@ class DashItemContainer extends St.Widget {
this.child = actor; this.child = actor;
this.add_actor(this.child); this.add_actor(this.child);
this.set_scale(this._childScale, this._childScale);
this.set_opacity(this._childOpacity);
} }
show(animate) { show(animate) {
@ -138,8 +139,9 @@ class DashItemContainer extends St.Widget {
let time = animate ? DASH_ANIMATION_TIME : 0; let time = animate ? DASH_ANIMATION_TIME : 0;
Tweener.addTween(this, Tweener.addTween(this,
{ childScale: 1.0, { scale_x: 1.0,
childOpacity: 255, scale_y: 1.0,
opacity: 255,
time: time / 1000, time: time / 1000,
transition: 'easeOutQuad' transition: 'easeOutQuad'
}); });
@ -155,37 +157,14 @@ class DashItemContainer extends St.Widget {
this.animatingOut = true; this.animatingOut = true;
Tweener.addTween(this, Tweener.addTween(this,
{ childScale: 0.0, { scale_x: 0,
childOpacity: 0, scale_y: 0,
opacity: 0,
time: DASH_ANIMATION_TIME / 1000, time: DASH_ANIMATION_TIME / 1000,
transition: 'easeOutQuad', transition: 'easeOutQuad',
onComplete: () => { onComplete: () => this.destroy()
this.destroy();
}
}); });
} }
set childScale(scale) {
this._childScale = scale;
this.set_scale(scale, scale);
this.queue_relayout();
}
get childScale() {
return this._childScale;
}
set childOpacity(opacity) {
this._childOpacity = opacity;
this.set_opacity(opacity);
this.queue_redraw();
}
get childOpacity() {
return this._childOpacity;
}
}); });
var ShowAppsIcon = GObject.registerClass( var ShowAppsIcon = GObject.registerClass(
@ -352,8 +331,7 @@ var Dash = class Dash {
this._container.set_offscreen_redirect(Clutter.OffscreenRedirect.ALWAYS); this._container.set_offscreen_redirect(Clutter.OffscreenRedirect.ALWAYS);
this._showAppsIcon = new ShowAppsIcon(); this._showAppsIcon = new ShowAppsIcon();
this._showAppsIcon.childScale = 1; this._showAppsIcon.show(false);
this._showAppsIcon.childOpacity = 255;
this._showAppsIcon.icon.setIconSize(this.iconSize); this._showAppsIcon.icon.setIconSize(this.iconSize);
this._hookUpLabel(this._showAppsIcon); this._hookUpLabel(this._showAppsIcon);