[FEATURE] Add a hotkey for hiding/displaying the song metadata info column
Opened this issue · 4 comments
I do not know if this can be accomplished with tview; that is, I don't see a way to hide individual GUI elements. The hiding/showing functionality appears to be available for pages, and for modals.
I can think of three work-arounds:
- Dynamically removing (deleting) on hide, and re-creating and re-adding the element on show. I feel uncertain about how tview's layout mechanism will handle this, but I think it'd work. Managing all of the plumbing might be challenging.
- Create two queue pages, one with a song info panel, and one without, and swap between them. I'm sure this could be done with the tview ABI, but have similar concerns as the previous option about the complexity of ensuring that everything is plumbed properly when switches happen.
- Have this not be toggle-able, but configurable. That is, depending on the initialization runtime options, optionally add and plumb the song info. It'd be on by default, but Users could to turn it off on constrained environments.
#3 is the easiest, and would probably be sufficient for most use cases. As I've said before, I imagine there would be fewer people wanting to turn it on and off dynamically; more likely is that they're running in a small VT and don't have space for the song info column, or they're running on restricted memory systems and turning off the song info would prevent any cover art image data from being loaded.
@spezifisch , what do you think?
Yes, 3 sounds good!
PS: What happens if we resize the widget to zero width or height?
Just to pitch in, 1 is actually not that problematic unless the info panel needs to be fully recreated:
Here's a basic patch that toggles the panel on pressing "i". Not fully tested, but handles song switching perfectly fine.
diff --git a/page_queue.go b/page_queue.go
index 500dcea..871b9b0 100644
--- a/page_queue.go
+++ b/page_queue.go
@@ -45,6 +45,7 @@ type QueuePage struct {
queueList *tview.Table
queueData queueData
+ infoFlex *tview.Flex
songInfo *tview.TextView
coverArt *tview.Image
@@ -134,6 +135,12 @@ func (ui *Ui) createQueuePage() *QueuePage {
}
}()
+ case 'i':
+ if queuePage.Root.GetItemCount() == 2 {
+ queuePage.Root.RemoveItem(queuePage.infoFlex)
+ } else {
+ queuePage.Root.AddItem(queuePage.infoFlex, 0, 1, false)
+ }
default:
return event
}
@@ -154,16 +161,16 @@ func (ui *Ui) createQueuePage() *QueuePage {
queuePage.coverArt = tview.NewImage()
queuePage.coverArt.SetImage(STMPS_LOGO)
- infoFlex := tview.NewFlex().SetDirection(tview.FlexRow).
+ queuePage.infoFlex = tview.NewFlex().SetDirection(tview.FlexRow).
AddItem(queuePage.songInfo, 0, 1, false).
AddItem(queuePage.coverArt, 0, 1, false)
- infoFlex.SetBorder(true)
- infoFlex.SetTitle(" song info ")
+ queuePage.infoFlex.SetBorder(true)
+ queuePage.infoFlex.SetTitle(" song info ")
// flex wrapper
queuePage.Root = tview.NewFlex().SetDirection(tview.FlexColumn).
AddItem(queuePage.queueList, 0, 2, true).
- AddItem(infoFlex, 0, 1, false)
+ AddItem(queuePage.infoFlex, 0, 1, false)
// private data
queuePage.queueData = queueData{
tview has a minimum size of 1 for resize, 0 is reserved for flexible items and proportion must be at least 1 if size is set to 0. The infoFlex is already configured that way.
3 would still be worthwhile just for the option to disable cover art processing wholesale.
Thanks; that was easier than I thought. Pushed into branch (off main) feat-50-infotoggle