From 662517163b233a3b055a923e8b6b021dc7b60fcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Dzi=C4=99giel?= Date: Sat, 13 Feb 2021 18:20:17 +0100 Subject: [PATCH] Reduce amount of logic in controls unreveal tick --- src/revealers.js | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/revealers.js b/src/revealers.js index 861e8cda..21b60b94 100644 --- a/src/revealers.js +++ b/src/revealers.js @@ -260,10 +260,16 @@ class ClapperControlsRevealer extends Gtk.Revealer const { widget } = this.root.child.player; - if(!this.child_revealed) - this.visible = true; + if(this.child_revealed) { + const [width] = this.root.get_default_size(); + const height = widget.get_height(); + + this.add_tick_callback( + this._onUnrevealTick.bind(this, widget, width, height) + ); + } else - this.add_tick_callback(this._onUnrevealTick.bind(this, widget)); + this.visible = true; widget.height_request = widget.get_height(); this.reveal_child ^= true; @@ -280,18 +286,17 @@ class ClapperControlsRevealer extends Gtk.Revealer } } - _onUnrevealTick(playerWidget) + _onUnrevealTick(playerWidget, width, height) { - const [width, height] = this.root.get_default_size(); + const isRevealed = this.child_revealed; - if(!this.child_revealed) { + if(!isRevealed) { playerWidget.height_request = -1; this.visible = false; } + this.root.set_default_size(width, height); - this.root.set_default_size(width, playerWidget.get_height()); - - return this.child_revealed; + return isRevealed; } });