From 097c21d14045dfd433d13f85a8843580db38ed84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Fri, 9 Jun 2023 20:12:15 +0200 Subject: [PATCH] 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: --- js/ui/animation.js | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/js/ui/animation.js b/js/ui/animation.js index 0a784413a..b70f8767b 100644 --- a/js/ui/animation.js +++ b/js/ui/animation.js @@ -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(); }