v/GTT
1
0
mirror of https://github.com/eeeXun/GTT.git synced 2025-05-21 01:50:36 -07:00

update UI window

This commit is contained in:
eeeXun 2023-01-10 21:20:11 +08:00
parent 0749f6fc84
commit 3f4013eb54
2 changed files with 32 additions and 2 deletions

View File

@ -16,6 +16,8 @@ var (
app = tview.NewApplication() app = tview.NewApplication()
srcInput = tview.NewTextArea() srcInput = tview.NewTextArea()
dstOutput = tview.NewTextView() dstOutput = tview.NewTextView()
definitionOutput = tview.NewTextArea()
translateOutput = tview.NewTextArea()
srcLangDropDown = tview.NewDropDown() srcLangDropDown = tview.NewDropDown()
dstLangDropDown = tview.NewDropDown() dstLangDropDown = tview.NewDropDown()
langCycle = ui.NewUICycle(srcLangDropDown, dstLangDropDown) langCycle = ui.NewUICycle(srcLangDropDown, dstLangDropDown)

32
ui.go
View File

@ -48,6 +48,14 @@ func updateBackgroundColor() {
Background(style.BackgroundColor()). Background(style.BackgroundColor()).
Foreground(style.ForegroundColor())) Foreground(style.ForegroundColor()))
dstOutput.SetBackgroundColor(style.BackgroundColor()) dstOutput.SetBackgroundColor(style.BackgroundColor())
definitionOutput.SetBackgroundColor(style.BackgroundColor())
definitionOutput.SetTextStyle(tcell.StyleDefault.
Background(style.BackgroundColor()).
Foreground(style.ForegroundColor()))
translateOutput.SetBackgroundColor(style.BackgroundColor())
translateOutput.SetTextStyle(tcell.StyleDefault.
Background(style.BackgroundColor()).
Foreground(style.ForegroundColor()))
// dropdown // dropdown
srcLangDropDown.SetBackgroundColor(style.BackgroundColor()) srcLangDropDown.SetBackgroundColor(style.BackgroundColor())
@ -103,6 +111,10 @@ func updateBorderColor() {
SetTitleColor(style.SrcBorderColor()) SetTitleColor(style.SrcBorderColor())
dstOutput.SetBorderColor(style.DstBorderColor()). dstOutput.SetBorderColor(style.DstBorderColor()).
SetTitleColor(style.DstBorderColor()) SetTitleColor(style.DstBorderColor())
definitionOutput.SetBorderColor(style.SrcBorderColor()).
SetTitleColor(style.SrcBorderColor())
translateOutput.SetBorderColor(style.DstBorderColor()).
SetTitleColor(style.DstBorderColor())
// dropdown // dropdown
srcLangDropDown.SetBorderColor(style.SrcBorderColor()). srcLangDropDown.SetBorderColor(style.SrcBorderColor()).
@ -121,6 +133,12 @@ func updateNonConfigColor() {
Background(style.SelectedColor()). Background(style.SelectedColor()).
Foreground(style.ForegroundColor())) Foreground(style.ForegroundColor()))
dstOutput.SetTextColor(style.ForegroundColor()) dstOutput.SetTextColor(style.ForegroundColor())
definitionOutput.SetSelectedStyle(tcell.StyleDefault.
Background(style.SelectedColor()).
Foreground(style.ForegroundColor()))
translateOutput.SetSelectedStyle(tcell.StyleDefault.
Background(style.SelectedColor()).
Foreground(style.ForegroundColor()))
// dropdown // dropdown
srcLangDropDown.SetFieldBackgroundColor(style.SelectedColor()). srcLangDropDown.SetFieldBackgroundColor(style.SelectedColor()).
@ -200,6 +218,10 @@ func uiInit() {
// input/output // input/output
srcInput.SetBorder(true) srcInput.SetBorder(true)
dstOutput.SetBorder(true) dstOutput.SetBorder(true)
definitionOutput.SetBorder(true).
SetTitle("Definition")
translateOutput.SetBorder(true).
SetTitle("Translation")
// dropdown // dropdown
srcLangDropDown.SetBorder(true) srcLangDropDown.SetBorder(true)
@ -232,8 +254,14 @@ func uiInit() {
// window // window
translateWindow.SetDirection(tview.FlexColumn). translateWindow.SetDirection(tview.FlexColumn).
AddItem(srcInput, 0, 1, true). AddItem(tview.NewFlex().SetDirection(tview.FlexRow).
AddItem(dstOutput, 0, 1, false) AddItem(srcInput, 0, 1, true).
AddItem(definitionOutput, 0, 1, false),
0, 1, true).
AddItem(tview.NewFlex().SetDirection(tview.FlexRow).
AddItem(dstOutput, 0, 1, false).
AddItem(translateOutput, 0, 1, false),
0, 1, false)
langWindow.SetDirection(tview.FlexRow). langWindow.SetDirection(tview.FlexRow).
AddItem(nil, 0, 1, false). AddItem(nil, 0, 1, false).
AddItem(tview.NewFlex().SetDirection(tview.FlexColumn). AddItem(tview.NewFlex().SetDirection(tview.FlexColumn).