From 4dd2658dd04224396c2c13d88ca1209aebfc55a6 Mon Sep 17 00:00:00 2001 From: aditya-K2 Date: Mon, 17 Apr 2023 23:35:36 +0530 Subject: [PATCH] Add Config and command-line parameters for rounded-corners --- config/colors.go | 12 ++++++++++++ ui/app.go | 41 ++++++++++++++++++++--------------------- 2 files changed, 32 insertions(+), 21 deletions(-) diff --git a/config/colors.go b/config/colors.go index 96a3aab..7b36eae 100644 --- a/config/colors.go +++ b/config/colors.go @@ -36,6 +36,8 @@ type Colors struct { PlaylistNav Color `mapstructure:"playlist_nav"` Nav Color `mapstructure:"nav"` ContextMenu Color `mapstructure:"context_menu"` + BorderFocus Color `mapstructure:"border_focus"` + Border Color `mapstructure:"border"` Null Color } @@ -153,6 +155,16 @@ func NewColors() *Colors { Bold: true, Italic: false, }, + BorderFocus: Color{ + Fg: "white", + Bold: false, + Italic: false, + }, + Border: Color{ + Fg: "grey", + Bold: false, + Italic: false, + }, Null: Color{ Fg: "white", Bold: true, diff --git a/ui/app.go b/ui/app.go index 9cdf90e..2bd4975 100644 --- a/ui/app.go +++ b/ui/app.go @@ -29,11 +29,9 @@ var ( NavStyle tcell.Style ContextMenuStyle tcell.Style NotSelectableStyle tcell.Style - FocusBorderStyle tcell.Style = tcell.StyleDefault.Foreground(tcell.ColorRed) - BorderStyle tcell.Style = tcell.StyleDefault.Foreground(tcell.ColorGrey) ) -func onConfigChange() { +func setStyles() { TrackStyle = config.Config.Colors.Track.Style() AlbumStyle = config.Config.Colors.Album.Style() ArtistStyle = config.Config.Colors.Artist.Style() @@ -46,6 +44,23 @@ func onConfigChange() { if Ui != nil { Ui.CoverArt.RefreshState() } + if config.Config.RoundedCorners { + tview.Borders.TopLeft = '╭' + tview.Borders.TopRight = '╮' + tview.Borders.BottomRight = '╯' + tview.Borders.BottomLeft = '╰' + tview.Borders.Vertical = '│' + tview.Borders.Horizontal = '─' + tview.Borders.TopLeftFocus = '╭' + tview.Borders.TopRightFocus = '╮' + tview.Borders.BottomRightFocus = '╯' + tview.Borders.BottomLeftFocus = '╰' + tview.Borders.VerticalFocus = '│' + tview.Borders.HorizontalFocus = '─' + tview.Styles.BorderColorFocus = config.Config.Colors.BorderFocus.Foreground() + tview.Styles.BorderColor = config.Config.Colors.Border.Foreground() + } + } type Application struct { @@ -61,22 +76,7 @@ type Application struct { } func NewApplication() *Application { - if config.Config.RoundedCorners { - tview.Borders.TopLeft = '╭' - tview.Borders.TopRight = '╮' - tview.Borders.BottomRight = '╯' - tview.Borders.BottomLeft = '╰' - tview.Borders.Vertical = '│' - tview.Borders.Horizontal = '─' - tview.Borders.TopLeftFocus = '╭' - tview.Borders.TopRightFocus = '╮' - tview.Borders.BottomRightFocus = '╯' - tview.Borders.BottomLeftFocus = '╰' - tview.Borders.VerticalFocus = '│' - tview.Borders.HorizontalFocus = '─' - tview.Styles.BorderColorFocus = tcell.ColorRed - } - + setStyles() App := tview.NewApplication() Root := NewRoot() pBar := NewProgressBar().SetProgressFunc(progressFunc) @@ -333,8 +333,7 @@ func NewApplication() *Application { } }() - onConfigChange() - config.OnConfigChange = onConfigChange + config.OnConfigChange = setStyles Ui = &Application{ App: App,