From dc2b61196ab939368edac567dff6d796b5930940 Mon Sep 17 00:00:00 2001 From: aditya-K2 Date: Mon, 17 Apr 2023 23:17:49 +0530 Subject: [PATCH] Implement Rounded Corners --- config/config.go | 2 ++ config/flags.go | 2 ++ ui/app.go | 20 ++++++++++++++++++-- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/config/config.go b/config/config.go index 0976b76..527a23c 100644 --- a/config/config.go +++ b/config/config.go @@ -18,6 +18,7 @@ type ConfigS struct { ExtraImageWidthX float64 `mapstructure:"image_width_extra_x"` ExtraImageWidthY float64 `mapstructure:"image_width_extra_y"` HideImage bool `mapstructure:"hide_image"` + RoundedCorners bool `mapstructure:"rounded_corners"` } func NewConfigS() *ConfigS { @@ -30,6 +31,7 @@ func NewConfigS() *ConfigS { RedrawInterval: 500, Colors: NewColors(), HideImage: false, + RoundedCorners: false, } } diff --git a/config/flags.go b/config/flags.go index 2f1e18f..9a69e9b 100644 --- a/config/flags.go +++ b/config/flags.go @@ -9,5 +9,7 @@ func parseFlags() { "Specify The Directory to check for config.yml file.") flag.BoolVar(&Config.HideImage, "hide-image", Config.HideImage, "Do not display the cover art image.") + flag.BoolVar(&Config.RoundedCorners, "rounded-corners", Config.RoundedCorners, + "Enable Rounded Corners") flag.Parse() } diff --git a/ui/app.go b/ui/app.go index 8ee04f2..9cdf90e 100644 --- a/ui/app.go +++ b/ui/app.go @@ -5,9 +5,9 @@ import ( "github.com/aditya-K2/gspt/config" "github.com/aditya-K2/gspt/spt" + "github.com/aditya-K2/tview" "github.com/aditya-K2/utils" "github.com/gdamore/tcell/v2" - "github.com/aditya-K2/tview" ) var ( @@ -29,6 +29,8 @@ 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() { @@ -59,6 +61,21 @@ 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 + } App := tview.NewApplication() Root := NewRoot() @@ -275,7 +292,6 @@ func NewApplication() *Application { ImgX, ImgY, ImgW, ImgH = Ui.CoverArt.GetRect() } drawCh <- true - }() go func() {