Implement Rounded Corners

This commit is contained in:
aditya-K2
2023-04-17 23:17:49 +05:30
parent 85b4aba1ad
commit dc2b61196a
3 changed files with 22 additions and 2 deletions

View File

@@ -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,
}
}

View File

@@ -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()
}

View File

@@ -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() {