Skip to content

Commit

Permalink
[gui] add some first easy key-contexts
Browse files Browse the repository at this point in the history
  • Loading branch information
spezifisch committed Oct 13, 2024
1 parent de674c9 commit c80f6c5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
)

require (
github.com/spezifisch/tview-command v0.0.0-20241013193408-213554cd0289
github.com/spezifisch/tview-command v0.0.0-20241013195600-86c4ba9c4c88
github.com/stretchr/testify v1.9.0
github.com/supersonic-app/go-mpv v0.1.0
)
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ github.com/spezifisch/tview-command v0.0.0-20241013173854-23b02704223f h1:6KzEn8
github.com/spezifisch/tview-command v0.0.0-20241013173854-23b02704223f/go.mod h1:BmHPVRuS00KaY6eP3VAoPJVlfN0Fulajx3Dw9CwKfFw=
github.com/spezifisch/tview-command v0.0.0-20241013193408-213554cd0289 h1:tYxRaxvhmXvJpOqxAt3AImUEqHtMFUfrztOSbTqn7ZI=
github.com/spezifisch/tview-command v0.0.0-20241013193408-213554cd0289/go.mod h1:BmHPVRuS00KaY6eP3VAoPJVlfN0Fulajx3Dw9CwKfFw=
github.com/spezifisch/tview-command v0.0.0-20241013195600-86c4ba9c4c88 h1:Ck4VeJ+nT0iSc708iwqjTwhaTNTTFxmNilEXVmze6n8=
github.com/spezifisch/tview-command v0.0.0-20241013195600-86c4ba9c4c88/go.mod h1:BmHPVRuS00KaY6eP3VAoPJVlfN0Fulajx3Dw9CwKfFw=
github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8=
github.com/spf13/afero v1.11.0/go.mod h1:GH9Y3pIexgf1MTIWtNGyogA5MwRIDXGUr+hbWNoBjkY=
github.com/spf13/cast v1.7.0 h1:ntdiHjuueXFgm5nzDRdOS4yfT43P5Fnud6DH50rz/7w=
Expand Down
9 changes: 8 additions & 1 deletion gui.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func InitGui(
}

ui.keyContextStack.Push("Init")
logger.Print("Context: QueuePage pushed to the stack")
logger.Print("Context: Init pushed to the stack")

ui.initEventLoops()

Expand Down Expand Up @@ -213,6 +213,9 @@ func (ui *Ui) Run() error {
// receive events from mpv wrapper
ui.player.RegisterEventConsumer(ui)

// leave init key context
ui.keyContextStack.PopExpect("Init")

// run gui/background event handler
ui.runEventLoops()

Expand All @@ -224,6 +227,7 @@ func (ui *Ui) Run() error {
}

func (ui *Ui) ShowHelp() {
ui.keyContextStack.Push("Help")
activePage := ui.menuWidget.GetActivePage()
ui.helpWidget.RenderHelp(activePage)

Expand All @@ -234,18 +238,21 @@ func (ui *Ui) ShowHelp() {
}

func (ui *Ui) CloseHelp() {
ui.keyContextStack.PopExpect("Help")
ui.helpWidget.visible = false
ui.pages.HidePage(PageHelpBox)
}

func (ui *Ui) ShowSelectPlaylist() {
ui.keyContextStack.Push("SelectPlaylist")
ui.pages.ShowPage(PageSelectPlaylist)
ui.pages.SendToFront(PageSelectPlaylist)
ui.app.SetFocus(ui.selectPlaylistModal)
ui.selectPlaylistWidget.visible = true
}

func (ui *Ui) CloseSelectPlaylist() {
ui.keyContextStack.PopExpect("SelectPlaylist")
ui.pages.HidePage(PageSelectPlaylist)
ui.selectPlaylistWidget.visible = false
}
Expand Down

0 comments on commit c80f6c5

Please sign in to comment.