-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEATURE] Add a hotkey for hiding/displaying the song metadata info column #50
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:
#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) |
Depends on #46 being merged.
The text was updated successfully, but these errors were encountered: