From 9d1b2020f3317e4bd80093402c26fcbe70224342 Mon Sep 17 00:00:00 2001 From: aditya-K2 Date: Thu, 13 Apr 2023 09:14:38 +0530 Subject: [PATCH] Added ExtraWidth and AdditionalPadding Variables --- ui/app.go | 2 +- ui/cover.go | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/ui/app.go b/ui/app.go index 3b93022..fff65f2 100644 --- a/ui/app.go +++ b/ui/app.go @@ -149,7 +149,7 @@ func NewApplication() *Application { if draw { go func() { for { - _ImgX, _ImgY, _ImgW, _ImgH := Ui.CoverArt.GetInnerRect() + _ImgX, _ImgY, _ImgW, _ImgH := Ui.CoverArt.GetRect() if start { RefreshProgress() start = false diff --git a/ui/cover.go b/ui/cover.go index 6d9a0fe..173a3f2 100644 --- a/ui/cover.go +++ b/ui/cover.go @@ -6,12 +6,20 @@ import ( "os" "github.com/aditya-K2/utils" + "github.com/gdamore/tcell/v2" "github.com/nfnt/resize" "github.com/rivo/tview" "github.com/zmb3/spotify/v2" "gitlab.com/diamondburned/ueberzug-go" ) +var ( + ax = 5 + ay = 10 + ex = -0.47 + ey = -1.5 +) + type CoverArt struct { *tview.Box image *ueberzug.Image @@ -19,7 +27,7 @@ type CoverArt struct { func newCoverArt() *CoverArt { return &CoverArt{ - tview.NewBox(), + tview.NewBox().SetBorder(true).SetBackgroundColor(tcell.ColorDefault), nil, } } @@ -37,8 +45,8 @@ func getImg(uri string) (image.Image, error) { } fw, fh := utils.GetFontWidth() img = resize.Resize( - uint(float32(ImgW)*(fw+float32(10))), - uint(float32(ImgH)*(fh+float32(10))), + uint(float32(ImgW)*(fw+float32(ex))), + uint(float32(ImgH)*(fh+float32(ey))), img, resize.Bilinear, ) @@ -89,8 +97,8 @@ func (c *CoverArt) RefreshState() { return } im, err := ueberzug.NewImage(uimg, - int(float32(ImgX)*fw), - int(float32(ImgY)*fh)) + int(float32(ImgX)*fw)+ax, + int(float32(ImgY)*fh)+ay) if err != nil { SendNotification(fmt.Sprintf("Error Rendering Image: %s", err.Error())) return