From 06fa80ef1bee14b942730be4f1dd2f95164032ca Mon Sep 17 00:00:00 2001 From: eeeXun Date: Wed, 8 Feb 2023 18:02:42 +0800 Subject: [PATCH] style(ui): language dropdown should focus prior to translator dropdown --- main.go | 2 +- ui.go | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/main.go b/main.go index 3b909f0..5f846c1 100644 --- a/main.go +++ b/main.go @@ -26,7 +26,7 @@ var ( translatorDropDown = tview.NewDropDown() srcLangDropDown = tview.NewDropDown() dstLangDropDown = tview.NewDropDown() - langCycle = ui.NewUICycle(translatorDropDown, srcLangDropDown, dstLangDropDown) + langCycle = ui.NewUICycle(srcLangDropDown, dstLangDropDown, translatorDropDown) themeDropDown = tview.NewDropDown() transparentDropDown = tview.NewDropDown() hideBelowDropDown = tview.NewDropDown() diff --git a/ui.go b/ui.go index 70af697..09e18eb 100644 --- a/ui.go +++ b/ui.go @@ -173,6 +173,12 @@ func updateNonConfigColor() { SetTitleColor(style.HighLightColor()) } +func updateAllColor() { + updateBackgroundColor() + updateBorderColor() + updateNonConfigColor() +} + // SetSelectedFunc of DropDown need to update when options change func updateLangDropDown() { srcLangDropDown.SetOptions(translator.GetAllLang(), @@ -189,12 +195,6 @@ func updateLangDropDown() { }) } -func updateAllColor() { - updateBackgroundColor() - updateBorderColor() - updateNonConfigColor() -} - // Update language title and option func updateCurrentLang() { srcInput.SetTitle(translator.GetSrcLang()) @@ -295,13 +295,13 @@ func uiInit() { Item{item: attachItems(false, tview.FlexRow, Item{item: attachItems(true, tview.FlexColumn, Item{item: attachItems(false, tview.FlexRow, - Item{item: translatorDropDown, fixedSize: 0, proportion: 1, focus: true}), - fixedSize: 0, proportion: 2, focus: true}), - fixedSize: 1, proportion: 1, focus: true}, + Item{item: translatorDropDown, fixedSize: 0, proportion: 1, focus: false}), + fixedSize: 0, proportion: 2, focus: false}), + fixedSize: 1, proportion: 1, focus: false}, Item{item: attachItems(false, tview.FlexColumn, - Item{item: srcLangDropDown, fixedSize: 0, proportion: 1, focus: false}, + Item{item: srcLangDropDown, fixedSize: 0, proportion: 1, focus: true}, Item{item: dstLangDropDown, fixedSize: 0, proportion: 1, focus: false}), - fixedSize: 0, proportion: 1, focus: false}), + fixedSize: 0, proportion: 1, focus: true}), fixedSize: 2 * langStrMaxLength, proportion: 1, focus: true}), popOutWindowHeight, 1, true). AddItem(attachButton(), 1, 1, false).