From 771d789e42a908a8b8e086c5a97bbf180538894e Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Tue, 15 Sep 2020 16:53:59 -0300 Subject: show child when opening group from path element --- todo.txt | 1 + ui.js | 15 ++++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/todo.txt b/todo.txt index b210799..18ed0c9 100644 --- a/todo.txt +++ b/todo.txt @@ -538,6 +538,7 @@ TODO: Selecting a group from the path listing at the bottom of listings should For example: selecting X in W/X/Y/Z would open the directory X and select item Y; selecting Z would open the directory Z and select the track (or group) which the path element is active on in the first place. + (Done!) TODO: UI to change the directory from which mtui reads music by default! diff --git a/ui.js b/ui.js index ae3cf32..85cefcd 100644 --- a/ui.js +++ b/ui.js @@ -737,7 +737,7 @@ class AppElement extends FocusElement { // Sets up event listeners that are common to ordinary grouplike listings // (made by newGrouplikeListing) as well as the queue grouplike listing. - grouplikeListing.pathElement.on('select', item => this.reveal(item)) + grouplikeListing.pathElement.on('select', (item, child) => this.reveal(item, child)) grouplikeListing.on('menu', (item, el) => this.showMenuForItemElement(el, grouplikeListing)) /* grouplikeListing.on('select', item => this.editNotesFile(item, false)) @@ -758,7 +758,7 @@ class AppElement extends FocusElement { return menu } - reveal(item) { + reveal(item, child) { if (!this.tabberPane.visible) { return } @@ -769,6 +769,9 @@ class AppElement extends FocusElement { const parent = item[parentSymbol] if (isGroup(item)) { tabberListing.loadGrouplike(item) + if (child) { + tabberListing.selectAndShow(child) + } } else if (parent) { if (tabberListing.grouplike !== parent) { tabberListing.loadGrouplike(parent) @@ -3080,10 +3083,12 @@ class PathElement extends ListScrollForm { const itemPath = getItemPath(item) const parentPath = itemPath.slice(0, -1) - for (const pathItem of parentPath) { - const isFirst = pathItem === parentPath[0] + for (let i = 0; i < parentPath.length; i++) { + const pathItem = parentPath[i] + const nextItem = itemPath[i + 1] + const isFirst = (i === 0) const element = new PathItemElement(pathItem, isFirst) - element.on('select', () => this.emit('select', pathItem)) + element.on('select', () => this.emit('select', pathItem, nextItem)) element.fixLayout() this.addInput(element) } -- cgit 1.3.0-6-gf8a5