« get me outta code hell

Clean up playback info box - mtui - Music Text User Interface - user-friendly command line music player
about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFlorrie <towerofnix@gmail.com>2018-07-24 13:54:08 -0300
committerFlorrie <towerofnix@gmail.com>2018-07-24 13:54:10 -0300
commitd65ac1af611e9e9042bf1cbe3272540c66db5431 (patch)
tree8faa5bd93273c7ba7cb2d5d327564f2b920384e9
parent7c72ecabc4a7fd255fb786e9cf858b2aafc045bc (diff)
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..)".
-rw-r--r--ui.js9
1 files 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()
   }