mirror of
https://github.com/eeeXun/GTT.git
synced 2025-05-16 15:50:52 -07:00
refactor: write show Popout into function
This commit is contained in:
parent
24cadc4072
commit
7883e0026e
54
ui.go
54
ui.go
@ -233,6 +233,26 @@ func attachItems(center bool, direction int, items ...Item) *tview.Flex {
|
|||||||
return container
|
return container
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func showLangPopout() {
|
||||||
|
mainPage.HidePage("stylePopOut")
|
||||||
|
mainPage.HidePage("keyMapPopOut")
|
||||||
|
mainPage.ShowPage("langPopOut")
|
||||||
|
app.SetFocus(langCycle.GetCurrentUI())
|
||||||
|
}
|
||||||
|
|
||||||
|
func showStylePopout() {
|
||||||
|
mainPage.HidePage("langPopOut")
|
||||||
|
mainPage.HidePage("keyMapPopOut")
|
||||||
|
mainPage.ShowPage("stylePopOut")
|
||||||
|
app.SetFocus(styleCycle.GetCurrentUI())
|
||||||
|
}
|
||||||
|
|
||||||
|
func showKeyMapPopout() {
|
||||||
|
mainPage.HidePage("langPopOut")
|
||||||
|
mainPage.HidePage("stylePopOut")
|
||||||
|
mainPage.ShowPage("keyMapPopOut")
|
||||||
|
}
|
||||||
|
|
||||||
func uiInit() {
|
func uiInit() {
|
||||||
// input/output
|
// input/output
|
||||||
srcInput.SetBorder(true)
|
srcInput.SetBorder(true)
|
||||||
@ -402,23 +422,9 @@ func uiInit() {
|
|||||||
mainPage.HidePage("keyMapPopOut")
|
mainPage.HidePage("keyMapPopOut")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
langButton.SetSelectedFunc(func() {
|
langButton.SetSelectedFunc(showLangPopout)
|
||||||
mainPage.HidePage("stylePopOut")
|
styleButton.SetSelectedFunc(showStylePopout)
|
||||||
mainPage.HidePage("keyMapPopOut")
|
keyMapButton.SetSelectedFunc(showKeyMapPopout)
|
||||||
mainPage.ShowPage("langPopOut")
|
|
||||||
app.SetFocus(langCycle.GetCurrentUI())
|
|
||||||
})
|
|
||||||
styleButton.SetSelectedFunc(func() {
|
|
||||||
mainPage.HidePage("langPopOut")
|
|
||||||
mainPage.HidePage("keyMapPopOut")
|
|
||||||
mainPage.ShowPage("stylePopOut")
|
|
||||||
app.SetFocus(styleCycle.GetCurrentUI())
|
|
||||||
})
|
|
||||||
keyMapButton.SetSelectedFunc(func() {
|
|
||||||
mainPage.HidePage("langPopOut")
|
|
||||||
mainPage.HidePage("stylePopOut")
|
|
||||||
mainPage.ShowPage("keyMapPopOut")
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func mainPageHandler(event *tcell.EventKey) *tcell.EventKey {
|
func mainPageHandler(event *tcell.EventKey) *tcell.EventKey {
|
||||||
@ -537,19 +543,11 @@ func popOutHandler(event *tcell.EventKey) *tcell.EventKey {
|
|||||||
|
|
||||||
switch ch {
|
switch ch {
|
||||||
case '1':
|
case '1':
|
||||||
mainPage.HidePage("stylePopOut")
|
showLangPopout()
|
||||||
mainPage.HidePage("keyMapPopOut")
|
|
||||||
mainPage.ShowPage("langPopOut")
|
|
||||||
app.SetFocus(langCycle.GetCurrentUI())
|
|
||||||
case '2':
|
case '2':
|
||||||
mainPage.HidePage("langPopOut")
|
showStylePopout()
|
||||||
mainPage.HidePage("keyMapPopOut")
|
|
||||||
mainPage.ShowPage("stylePopOut")
|
|
||||||
app.SetFocus(styleCycle.GetCurrentUI())
|
|
||||||
case '3':
|
case '3':
|
||||||
mainPage.HidePage("langPopOut")
|
showKeyMapPopout()
|
||||||
mainPage.HidePage("stylePopOut")
|
|
||||||
mainPage.ShowPage("keyMapPopOut")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return event
|
return event
|
||||||
|
Loading…
x
Reference in New Issue
Block a user