From d65ac1af611e9e9042bf1cbe3272540c66db5431 Mon Sep 17 00:00:00 2001 From: Florrie Date: Tue, 24 Jul 2018 13:54:08 -0300 Subject: Clean up playback info box * Text is now centered properly, right away. Previously the "From:" label wasn't getting centered correctly (until the second time fixLayout was called). * When a new track is started, the progress bar is cleared immediately, and the "0:30 / 1:30" label is replaced with "(Starting..)". --- ui.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ui.js b/ui.js index b030358..3df7272 100644 --- a/ui.js +++ b/ui.js @@ -1054,9 +1054,6 @@ class PlaybackInfoElement extends DisplayElement { fixLayout() { const centerX = el => el.x = Math.round((this.w - el.w) / 2) - centerX(this.progressTextLabel) - centerX(this.trackNameLabel) - centerX(this.downloadLabel) this.trackNameLabel.y = 0 this.progressBarLabel.y = 1 @@ -1071,6 +1068,10 @@ class PlaybackInfoElement extends DisplayElement { } this.downloadLabel.text = `(From: ${dlText})` } + + centerX(this.progressTextLabel) + centerX(this.trackNameLabel) + centerX(this.downloadLabel) } updateProgress({timeDone, timeLeft, duration, lenSecTotal, curSecTotal}) { @@ -1082,6 +1083,8 @@ class PlaybackInfoElement extends DisplayElement { updateTrack(track) { this.currentTrack = track this.trackNameLabel.text = track.name + this.progressBarLabel.text = '' + this.progressTextLabel.text = '(Starting..)' this.fixLayout() } -- cgit 1.3.0-6-gf8a5