From b02f54a3a61c980421daea0f3cea2bf08bf2ce5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Dzi=C4=99giel?= Date: Thu, 15 Apr 2021 15:27:21 +0200 Subject: [PATCH] Do not show mobile controls transition on launch Start app with the correct controls layout instead of showing the "hide elapsed time" transition when started on mobile width. It is annoying. We cannot detect surface width during app widgets assembly, so update the controls revealers state on first surface update after window is mapped and only if running on mobile width. Otherwise do not do anything like before which will result in showing fully revealed controls (default). --- src/controls.js | 4 +++- src/revealers.js | 15 ++++++++++++++- src/widget.js | 6 ++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/controls.js b/src/controls.js index 81a5d6e3..1e58baec 100644 --- a/src/controls.js +++ b/src/controls.js @@ -18,6 +18,8 @@ class ClapperControls extends Gtk.Box can_focus: false, }); + this.minFullViewWidth = 560; + this.currentPosition = 0; this.currentDuration = 0; this.isPositionDragging = false; @@ -473,7 +475,7 @@ class ClapperControls extends Gtk.Box _onPlayerResize(width, height) { - const isMobile = (width < 560); + const isMobile = (width < this.minFullViewWidth); if(this.isMobile === isMobile) return; diff --git a/src/revealers.js b/src/revealers.js index 1746be39..75d2f6d4 100644 --- a/src/revealers.js +++ b/src/revealers.js @@ -370,6 +370,18 @@ class ClapperButtonsRevealer extends Gtk.Revealer this.get_child().append(widget); } + revealInstantly(isReveal) + { + if(this.child_revealed === isReveal) + return; + + const initialDuration = this.transition_duration; + + this.transition_duration = 0; + this.reveal_child = isReveal; + this.transition_duration = initialDuration; + } + _setRotateClass(icon, isAdd) { const cssClass = 'halfrotate'; @@ -388,7 +400,8 @@ class ClapperButtonsRevealer extends Gtk.Revealer _onRevealChild(button) { - this._setRotateClass(button.child, true); + if(this.reveal_child !== this.child_revealed) + this._setRotateClass(button.child, true); } _onChildRevealed(button) diff --git a/src/widget.js b/src/widget.js index fbace202..6f1fe549 100644 --- a/src/widget.js +++ b/src/widget.js @@ -541,6 +541,12 @@ class ClapperWidget extends Gtk.Grid if(width === this.layoutWidth) return; + /* Launch without showing revealers transitions on mobile width */ + if(!this.layoutWidth && width < this.controls.minFullViewWidth) { + for(let revealer of this.controls.revealersArr) + revealer.revealInstantly(false); + } + this.layoutWidth = width; if(this.isFullscreenMode)