diff options
Diffstat (limited to 'ui.js')
-rw-r--r-- | ui.js | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/ui.js b/ui.js index c2c3e67..4f73fe0 100644 --- a/ui.js +++ b/ui.js @@ -134,11 +134,16 @@ telc.isSelect = input.isSelect telc.isBackspace = input.isBackspace class AppElement extends FocusElement { - constructor(backend) { + constructor(backend, config = {}) { super() this.backend = backend + this.config = Object.assign({ + menubarColor: 4, // blue + stopPlayingUponQuit: true + }, config) + this.backend.on('playing', (track, oldTrack) => { if (track) { this.playbackInfoElement.updateTrack(track) @@ -160,6 +165,10 @@ class AppElement extends FocusElement { this.metadataStatusLabel.text = `Processing metadata - ${remaining} to go.` }) + this.backend.on('queue updated', () => { + this.queueListingElement.buildItems() + }) + // TODO: Move edit mode stuff to the backend! this.undoManager = new UndoManager() this.markGrouplike = {name: 'Marked', items: []} @@ -171,6 +180,8 @@ class AppElement extends FocusElement { this.menubar = new Menubar(this.menu) this.addChild(this.menubar) + this.menubar.color = this.config.menubarColor + this.paneLeft = new Pane() this.addChild(this.paneLeft) @@ -571,7 +582,10 @@ class AppElement extends FocusElement { } async shutdown() { - await this.backend.stopPlaying() + if (this.config.stopPlayingUponQuit) { + await this.backend.stopPlaying() + } + this.emit('quitRequested') } @@ -708,12 +722,10 @@ class AppElement extends FocusElement { shuffleQueue() { this.backend.shuffleQueue() - this.queueListingElement.buildItems() } clearQueue() { this.backend.clearQueue() - this.queueListingElement.buildItems() this.queueListingElement.selectNone() this.updateQueueLengthLabel() @@ -756,7 +768,6 @@ class AppElement extends FocusElement { this.backend.queue(item, afterItem, { movePlayingTrack: order === 'normal' }) - this.queueListingElement.buildItems() if (isTrack(passedItem)) { this.queueListingElement.selectAndShow(passedItem) @@ -765,7 +776,6 @@ class AppElement extends FocusElement { this.backend.distributeQueue(item, { how: where.slice('distribute-'.length) }) - this.queueListingElement.buildItems() } this.updateQueueLengthLabel() @@ -1965,12 +1975,16 @@ class PlaybackInfoElement extends DisplayElement { } updateTrack(track) { - this.currentTrack = track - this.trackNameLabel.text = track.name - this.progressBarLabel.text = '' - this.progressTextLabel.text = '(Starting..)' - this.timeData = {} - this.fixLayout() + if (track) { + this.currentTrack = track + this.trackNameLabel.text = track.name + this.progressBarLabel.text = '' + this.progressTextLabel.text = '(Starting..)' + this.timeData = {} + this.fixLayout() + } else { + this.clearInfo() + } } clearInfo() { |