« get me outta code hell

Mouse controls over playback info element - 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-12-08 02:59:10 -0400
committerFlorrie <towerofnix@gmail.com>2018-12-08 02:59:10 -0400
commitbbc8a7cf4abb214a07cb49b144af581b2e8335a6 (patch)
treea783d4487488449859b4cad244be2a6d9b4a5929
parent7a4e4aa8afb341ba3e2b949f71b6c2a05f743831 (diff)
Mouse controls over playback info element
Scroll up/down to seek, click to toggle pause.
-rw-r--r--ui.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/ui.js b/ui.js
index 1a64253..775dbcc 100644
--- a/ui.js
+++ b/ui.js
@@ -70,6 +70,10 @@ class AppElement extends FocusElement {
     this.playbackInfoElement = new PlaybackInfoElement()
     this.playbackPane.addChild(this.playbackInfoElement)
 
+    this.playbackInfoElement.on('seek back', () => this.seekBack(5))
+    this.playbackInfoElement.on('seek ahead', () => this.seekAhead(5))
+    this.playbackInfoElement.on('toggle pause', () => this.togglePause())
+
     // Dialogs
 
     this.openPlaylistDialog = new OpenPlaylistDialog()
@@ -1330,6 +1334,16 @@ class PlaybackInfoElement extends DisplayElement {
     centerX(this.downloadLabel)
   }
 
+  clicked(button) {
+    if (button === 'scroll-up') {
+      this.emit('seek back')
+    } else if (button === 'scroll-down') {
+      this.emit('seek ahead')
+    } else if (button === 'left') {
+      this.emit('toggle pause')
+    }
+  }
+
   updateProgress({timeDone, timeLeft, duration, lenSecTotal, curSecTotal}) {
     this.progressBarLabel.text = '-'.repeat(Math.floor(this.w / lenSecTotal * curSecTotal))
     this.progressTextLabel.text = timeDone + ' / ' + duration