From bc4b9a77f2408b8bd95ff15109c2bad695679155 Mon Sep 17 00:00:00 2001 From: raziman Date: Sun, 14 Mar 2021 18:20:48 +0800 Subject: [PATCH] fix border background color --- go.mod | 5 +++-- go.sum | 12 +++++++++++ playingbar.go | 3 +++ playlist.go | 1 + popup.go | 9 ++++++-- queue.go | 2 ++ start.go | 2 +- tageditor.go | 58 +++++++++++++++++++++++++++++---------------------- 8 files changed, 62 insertions(+), 30 deletions(-) diff --git a/go.mod b/go.mod index b7c4a2b..e956933 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/asmcos/requests v0.0.0-20210118082303-cb8f46dd3767 github.com/bogem/id3v2 v1.2.0 github.com/faiface/beep v1.0.2 - github.com/gdamore/tcell/v2 v2.1.0 + github.com/gdamore/tcell/v2 v2.2.0 github.com/gobwas/glob v0.2.3 // indirect github.com/gocolly/colly v1.2.0 github.com/hajimehoshi/go-mp3 v0.3.1 // indirect @@ -19,7 +19,7 @@ require ( github.com/logrusorgru/aurora v2.0.3+incompatible // indirect github.com/mattn/anko v0.1.8 github.com/pkg/errors v0.9.1 // indirect - github.com/rivo/tview v0.0.0-20210125085121-dbc1f32bb1d0 + github.com/rivo/tview v0.0.0-20210312174852-ae9464cc3598 github.com/sahilm/fuzzy v0.1.0 github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca // indirect github.com/stretchr/testify v1.7.0 @@ -29,5 +29,6 @@ require ( golang.org/x/exp v0.0.0-20201229011636-eab1b5eb1a03 // indirect golang.org/x/image v0.0.0-20201208152932-35266b937fa6 // indirect golang.org/x/net v0.0.0-20210119194325-5f4716e94777 // indirect + golang.org/x/sys v0.0.0-20210313202042-bd2e13477e9c // indirect google.golang.org/appengine v1.6.7 // indirect ) diff --git a/go.sum b/go.sum index f511928..05baaed 100644 --- a/go.sum +++ b/go.sum @@ -28,6 +28,8 @@ github.com/gdamore/tcell v1.4.0/go.mod h1:vxEiSDZdW3L+Uhjii9c3375IlDmR05bzxY404Z github.com/gdamore/tcell/v2 v2.0.1-0.20201017141208-acf90d56d591/go.mod h1:vSVL/GV5mCSlPC6thFP5kfOFdM9MGZcalipmpTxTgQA= github.com/gdamore/tcell/v2 v2.1.0 h1:UnSmozHgBkQi2PGsFr+rpdXuAPRRucMegpQp3Z3kDro= github.com/gdamore/tcell/v2 v2.1.0/go.mod h1:vSVL/GV5mCSlPC6thFP5kfOFdM9MGZcalipmpTxTgQA= +github.com/gdamore/tcell/v2 v2.2.0 h1:vSyEgKwraXPSOkvCk7IwOSyX+Pv3V2cV9CikJMXg4U4= +github.com/gdamore/tcell/v2 v2.2.0/go.mod h1:cTTuF84Dlj/RqmaCIV5p4w8uG1zWdk0SF6oBpwHp4fU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8= @@ -61,6 +63,8 @@ github.com/logrusorgru/aurora v2.0.3+incompatible/go.mod h1:7rIyQOR62GCctdiQpZ/z github.com/lucasb-eyer/go-colorful v0.0.0-20181028223441-12d3b2882a08/go.mod h1:NXg0ArsFk0Y01623LgUqoqcouGDB+PwCCQlrwrG6xJ4= github.com/lucasb-eyer/go-colorful v1.0.3 h1:QIbQXiugsb+q10B+MI+7DI1oQLdmnep86tWFlaaUAac= github.com/lucasb-eyer/go-colorful v1.0.3/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0= +github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY= +github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0= github.com/mattn/anko v0.1.8 h1:wDGM0Rwgbzhk1h8xE6qAR4n+PO/9clzf3tLGtrwsqJg= github.com/mattn/anko v0.1.8/go.mod h1:C5D2zw4NIv/sB2SrQ3qs5wqPw0wKiA2GZqexy4ctNH0= github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= @@ -75,6 +79,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rivo/tview v0.0.0-20210125085121-dbc1f32bb1d0 h1:WCfp+Jq9Mx156zIf9X6Frd6F19rf7wIRlm54UPxUfcU= github.com/rivo/tview v0.0.0-20210125085121-dbc1f32bb1d0/go.mod h1:1QW7hX7RQzOqyGgx8O64bRPQBrFtPflioPPX5gFPV3A= +github.com/rivo/tview v0.0.0-20210312174852-ae9464cc3598 h1:AbRrGXhagPRDItERv7nauBUUPi7Ma3IGIj9FqkQKW6k= +github.com/rivo/tview v0.0.0-20210312174852-ae9464cc3598/go.mod h1:VzCN9WX13RF88iH2CaGkmdHOlsy1ZZQcTmNwROqC+LI= github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= @@ -137,7 +143,13 @@ golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210113181707-4bcb84eeeb78 h1:nVuTkr9L6Bq62qpUqKo/RnZCFfzDBL0bYo6w9OJUqZY= golang.org/x/sys v0.0.0-20210113181707-4bcb84eeeb78/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210309074719-68d13333faf2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210313202042-bd2e13477e9c h1:coiPEfMv+ThsjULRDygLrJVlNE1gDdL2g65s0LhV2os= +golang.org/x/sys v0.0.0-20210313202042-bd2e13477e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d h1:SZxvLBoTP5yHO3Frd4z4vrF+DBX9vMVanchswa69toE= +golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= diff --git a/playingbar.go b/playingbar.go index 1b33284..3a54f76 100644 --- a/playingbar.go +++ b/playingbar.go @@ -42,8 +42,11 @@ func (p *PlayingBar) help() []string { func newPlayingBar() *PlayingBar { textView := tview.NewTextView().SetTextAlign(tview.AlignCenter) + textView.SetBackgroundColor(gomu.colors.background) + frame := tview.NewFrame(textView).SetBorders(1, 1, 1, 1, 1, 1) frame.SetBorder(true).SetTitle(" Now Playing ") + frame.SetBackgroundColor(gomu.colors.background) p := &PlayingBar{ Frame: frame, diff --git a/playlist.go b/playlist.go index a6dc03c..3e01001 100644 --- a/playlist.go +++ b/playlist.go @@ -113,6 +113,7 @@ func newPlaylist(args Args) *Playlist { SetColor(gomu.colors.accent) tree := tview.NewTreeView().SetRoot(root) + tree.SetBackgroundColor(gomu.colors.background) playlist := &Playlist{ TreeView: tree, diff --git a/popup.go b/popup.go index 1431af8..f962037 100644 --- a/popup.go +++ b/popup.go @@ -411,6 +411,7 @@ func searchPopup(title string, stringsToMatch []string, handler func(selected st list := tview.NewList().ShowSecondaryText(false) list.SetSelectedBackgroundColor(gomu.colors.accent) list.SetHighlightFullLine(true) + list.SetBackgroundColor(gomu.colors.popup) for _, v := range stringsToMatch { list.AddItem(v, v, 0, nil) @@ -501,11 +502,13 @@ func searchPopup(title string, stringsToMatch []string, handler func(selected st AddItem(input, 2, 1, true). AddItem(list, 0, 1, false) - popup.SetBorder(true). + popupBox := tview.NewBox().SetBorder(true). SetBackgroundColor(gomu.colors.popup). SetBorderPadding(1, 1, 2, 2). SetTitle(" " + title + " ") + popup.Box = popupBox + gomu.pages.AddPage("search-input-popup", center(popup, 70, 40), true, true) gomu.popups.push(popup) } @@ -709,12 +712,14 @@ func replPopup() { AddItem(input, 3, 1, true). AddItem(textview, 0, 1, false) - flex. + flexBox := tview.NewBox(). SetBackgroundColor(gomu.colors.popup). SetBorder(true). SetBorderPadding(1, 1, 2, 2). SetTitle(" REPL ") + flex.Box = flexBox + gomu.pages.AddPage(popupId, center(flex, 90, 30), true, true) gomu.popups.push(flex) } diff --git a/queue.go b/queue.go index 30657ee..355dec7 100644 --- a/queue.go +++ b/queue.go @@ -361,6 +361,8 @@ func newQueue() *Queue { list := tview.NewList(). ShowSecondaryText(false) + list.SetBackgroundColor(gomu.colors.background) + queue := &Queue{ List: list, savedQueuePath: cacheQueuePath, diff --git a/start.go b/start.go index 6521742..509840c 100644 --- a/start.go +++ b/start.go @@ -317,7 +317,7 @@ func start(application *tview.Application, args Args) { tview.Borders.TopRightFocus = tview.Borders.TopRight tview.Borders.BottomLeftFocus = tview.Borders.BottomLeft tview.Borders.BottomRightFocus = tview.Borders.BottomRight - tview.Styles.PrimitiveBackgroundColor = gomu.colors.background + tview.Styles.PrimitiveBackgroundColor = gomu.colors.popup gomu.initPanels(application, args) diff --git a/tageditor.go b/tageditor.go index ad66bdf..7e54ef2 100644 --- a/tageditor.go +++ b/tageditor.go @@ -43,21 +43,22 @@ func tagPopup(node *AudioFile) (err error) { leftGrid *tview.Grid = tview.NewGrid() rightFlex *tview.Flex = tview.NewFlex() ) + artistInputField.SetLabel("Artist: "). SetFieldWidth(20). SetText(tag.Artist()). - SetFieldBackgroundColor(gomu.colors.popup). - SetBackgroundColor(gomu.colors.background) + SetFieldBackgroundColor(gomu.colors.popup) + titleInputField.SetLabel("Title: "). SetFieldWidth(20). SetText(tag.Title()). - SetFieldBackgroundColor(gomu.colors.popup). - SetBackgroundColor(gomu.colors.background) + SetFieldBackgroundColor(gomu.colors.popup) + albumInputField.SetLabel("Album: "). SetFieldWidth(20). SetText(tag.Album()). - SetFieldBackgroundColor(gomu.colors.popup). - SetBackgroundColor(gomu.colors.background) + SetFieldBackgroundColor(gomu.colors.popup) + getTagButton.SetSelectedFunc(func() { var titles []string audioFile := node @@ -105,9 +106,13 @@ func tagPopup(node *AudioFile) (err error) { } }) }). + SetBackgroundColorActivated(gomu.colors.popup). + SetLabelColorActivated(gomu.colors.accent). SetBorder(true). - SetBackgroundColor(gomu.colors.background). + SetBackgroundColor(gomu.colors.popup). SetTitleColor(gomu.colors.accent) + + saveTagButton.SetSelectedFunc(func() { tag, err = id3v2.Open(node.path, id3v2.Options{Parse: true}) if err != nil { @@ -124,13 +129,15 @@ func tagPopup(node *AudioFile) (err error) { defaultTimedPopup(" Success ", "Tag update successfully") } }). + SetBackgroundColorActivated(gomu.colors.popup). + SetLabelColorActivated(gomu.colors.accent). SetBorder(true). - SetBackgroundColor(gomu.colors.background). + SetBackgroundColor(gomu.colors.popup). SetTitleColor(gomu.colors.foreground) lyricDropDown.SetOptions(options, nil). SetCurrentOption(0). - SetFieldBackgroundColor(gomu.colors.background). + SetFieldBackgroundColor(gomu.colors.popup). SetFieldTextColor(gomu.colors.accent). SetPrefixTextColor(gomu.colors.accent). SetSelectedFunc(func(text string, _ int) { @@ -182,17 +189,21 @@ func tagPopup(node *AudioFile) (err error) { infoPopup("No lyric embeded.") } }). + SetBackgroundColorActivated(gomu.colors.popup). + SetLabelColorActivated(gomu.colors.accent). SetBorder(true). - SetBackgroundColor(gomu.colors.background). + SetBackgroundColor(gomu.colors.popup). SetTitleColor(gomu.colors.accent) getLyricDropDownOptions := []string{"en", "zh-CN"} getLyricDropDown.SetOptions(getLyricDropDownOptions, nil). SetCurrentOption(0). - SetFieldBackgroundColor(gomu.colors.background). + SetFieldBackgroundColor(gomu.colors.popup). SetFieldTextColor(gomu.colors.accent). SetPrefixTextColor(gomu.colors.accent). - SetLabel("Fetch Lyrics: ") + SetLabel("Fetch Lyrics: "). + SetBackgroundColor(gomu.colors.popup) + lyricDropDown.SetBackgroundColor(gomu.colors.popup) getLyricButton.SetSelectedFunc(func() { @@ -279,9 +290,11 @@ func tagPopup(node *AudioFile) (err error) { gomu.app.Draw() } }). + SetBackgroundColorActivated(gomu.colors.popup). + SetLabelColorActivated(gomu.colors.accent). SetBorder(true). - SetBackgroundColor(gomu.colors.background). - SetTitleColor(gomu.colors.accent) + SetTitleColor(gomu.colors.accent). + SetBackgroundColor(gomu.colors.popup) var lyricText string _, langExt := lyricDropDown.GetCurrentOption() @@ -302,7 +315,6 @@ func tagPopup(node *AudioFile) (err error) { SetScrollable(true). SetWordWrap(true). SetWrap(true). - SetBackgroundColor(gomu.colors.popup). SetBorder(true) leftGrid.SetRows(3, 3, 3, 3, 3, 0, 3, 3, 3, 3, 3). @@ -316,10 +328,13 @@ func tagPopup(node *AudioFile) (err error) { AddItem(deleteLyricButton, 7, 0, 1, 3, 1, 10, true). AddItem(getLyricDropDown, 9, 0, 1, 3, 1, 20, true). AddItem(getLyricButton, 10, 0, 1, 3, 1, 10, true) - leftGrid.SetBorder(true). + + box := tview.NewBox().SetBorder(true). SetTitle(node.name). SetBorderPadding(1, 1, 2, 2) + leftGrid.Box = box + rightFlex.SetDirection(tview.FlexColumn). AddItem(lyricTextView, 0, 1, true) @@ -332,8 +347,7 @@ func tagPopup(node *AudioFile) (err error) { lyricFlex. SetTitle(node.name). - SetBorderPadding(1, 1, 1, 1). - SetBackgroundColor(gomu.colors.popup) + SetBorderPadding(1, 1, 1, 1) inputs := []tview.Primitive{ artistInputField, @@ -348,8 +362,7 @@ func tagPopup(node *AudioFile) (err error) { lyricTextView, } - gomu.pages. - AddPage(popupID, center(lyricFlex, 90, 40), true, true) + gomu.pages.AddPage(popupID, center(lyricFlex, 90, 40), true, true) gomu.popups.push(lyricFlex) lyricFlex.SetInputCapture(func(e *tcell.EventKey) *tcell.EventKey { @@ -369,11 +382,6 @@ func tagPopup(node *AudioFile) (err error) { lyricFlex.cycleFocus(gomu.app, inputs, true) } - switch e.Rune() { - case '1': - case '2': - case '3': - } return e })