animations: Stop syncing size manually

The returned slice actors are now set up to fill their parent,
accounting for any difference between loaded- and displayed size,
so we can stop syncing the size manually.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2798>
This commit is contained in:
Florian Müllner 2023-06-09 20:12:15 +02:00 committed by Marge Bot
parent ebbcc31fbd
commit 097c21d140

View File

@ -40,10 +40,6 @@ class Animation extends St.Bin {
this._frame = 0;
this._loadFile(file, width, height);
// If the parent changes, we need to re-sync the animation
// size
this.connect('parent-set', () => this._syncAnimationSize());
}
play() {
@ -81,11 +77,12 @@ class Animation extends St.Bin {
let scaleFactor = St.ThemeContext.get_for_stage(global.stage).scale_factor;
this._animations = textureCache.load_sliced_image(file, width, height,
scaleFactor, resourceScale,
() => this._syncAnimationSize());
() => this._loadFinished());
this._animations.set({
x_align: Clutter.ActorAlign.CENTER,
y_align: Clutter.ActorAlign.CENTER,
});
this.set_child(this._animations);
if (wasPlaying)
@ -109,19 +106,10 @@ class Animation extends St.Bin {
return GLib.SOURCE_CONTINUE;
}
_syncAnimationSize() {
_loadFinished() {
this._isLoaded = this._animations.get_n_children() > 0;
// this.get_size() can't be called without a parent
if (!this._isLoaded || !this.get_parent())
return;
let [width, height] = this.get_size();
for (let i = 0; i < this._animations.get_n_children(); ++i)
this._animations.get_child_at_index(i).set_size(width, height);
if (this._isPlaying)
if (this._isLoaded && this._isPlaying)
this.play();
}