Skip to content

Commit 4f0fe5d

Browse files
committed
use rounded image corners (TODO: allow disabling this)
1 parent 973e819 commit 4f0fe5d

File tree

14 files changed

+30
-12
lines changed

14 files changed

+30
-12
lines changed

ui/bottompanel.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111

1212
"fyne.io/fyne/v2"
1313
"fyne.io/fyne/v2/container"
14+
"fyne.io/fyne/v2/theme"
1415
"fyne.io/fyne/v2/widget"
1516
)
1617

@@ -47,6 +48,7 @@ func NewBottomPanel(pm *backend.PlaybackManager, im *backend.ImageManager, contr
4748
pm.OnStopped(util.FyneDoFunc(func() { bp.Controls.SetPlaying(false) }))
4849

4950
bp.NowPlaying = widgets.NewNowPlayingCard()
51+
bp.NowPlaying.ImageCornerRadius = theme.InputRadiusSize()
5052
bp.NowPlaying.OnCoverTapped = func() {
5153
contr.NavigateTo(controller.NowPlayingRoute())
5254
}

ui/browsing/albumpage.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ func NewAlbumPageHeader(page *AlbumPage) *AlbumPageHeader {
231231
a.ExtendBaseWidget(a)
232232
a.cover = widgets.NewImagePlaceholder(myTheme.AlbumIcon, 225)
233233
a.cover.OnTapped = func(*fyne.PointEvent) { go a.showPopUpCover() }
234+
a.cover.CornerRadius = theme.InputRadiusSize()
234235

235236
a.titleLabel = widget.NewRichTextWithText("")
236237
a.titleLabel.Truncation = fyne.TextTruncateEllipsis

ui/browsing/artistpage.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,7 @@ func NewArtistPageHeader(page *ArtistPage) *ArtistPageHeader {
503503
}
504504
a.artistImage = widgets.NewImagePlaceholder(myTheme.ArtistIcon, 225)
505505
a.artistImage.OnTapped = func(*fyne.PointEvent) { a.showPopUpCover() }
506+
a.artistImage.CornerRadius = theme.InputRadiusSize()
506507
a.favoriteBtn = widgets.NewFavoriteButton(func() { go a.toggleFavorited() })
507508
a.playBtn = widget.NewButtonWithIcon(lang.L("Play Discography"), theme.MediaPlayIcon(), func() {
508509
go a.artistPage.pm.PlayArtistDiscography(a.artistID, false /*shuffle*/)

ui/browsing/nowplayingpage.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ func NewNowPlayingPage(
108108
pm.OnStopped(doFmtStatus)
109109

110110
a.card = widgets.NewLargeNowPlayingCard()
111+
a.card.ImageCornerRadius = theme.InputRadiusSize()
111112
a.card.OnAlbumNameTapped = func() {
112113
contr.NavigateTo(controller.AlbumRoute(a.nowPlaying.Metadata().AlbumID))
113114
}

ui/browsing/playlistpage.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ func NewPlaylistPageHeader(page *PlaylistPage) *PlaylistPageHeader {
328328

329329
a.image = widgets.NewImagePlaceholder(myTheme.PlaylistIcon, 225)
330330
a.image.OnTapped = func(*fyne.PointEvent) { go a.showPopUpCover() }
331+
a.image.CornerRadius = theme.InputRadiusSize()
331332
a.titleLabel = util.NewTruncatingRichText()
332333
a.titleLabel.Segments[0].(*widget.TextSegment).Style = widget.RichTextStyle{
333334
SizeName: theme.SizeNameHeadingText,

ui/theme/themedrectangle.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ type ThemedRectangle struct {
1515

1616
rect *canvas.Rectangle
1717

18-
ColorName fyne.ThemeColorName
19-
Translucent bool
20-
BorderWidth float32
21-
BorderColorName fyne.ThemeColorName
22-
CornerRadiusName fyne.ThemeSizeName
18+
ColorName fyne.ThemeColorName
19+
Translucent bool
20+
BorderWidth float32
21+
BorderColorName fyne.ThemeColorName
22+
CornerRadius float32
2323
}
2424

2525
func NewThemedRectangle(colorName fyne.ThemeColorName) *ThemedRectangle {
@@ -43,9 +43,7 @@ func (t *ThemedRectangle) Refresh() {
4343
t.rect.FillColor = fc
4444
t.rect.StrokeWidth = t.BorderWidth
4545
t.rect.StrokeColor = theme.Color(t.BorderColorName, settings.ThemeVariant())
46-
if t.CornerRadiusName != "" {
47-
t.rect.CornerRadius = theme.Size(t.CornerRadiusName)
48-
}
46+
t.rect.CornerRadius = t.CornerRadius
4947
t.BaseWidget.Refresh()
5048
}
5149

ui/util/util.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ func AddHeaderBackground(obj fyne.CanvasObject) *fyne.Container {
346346

347347
func AddHeaderBackgroundWithColorName(obj fyne.CanvasObject, colorName fyne.ThemeColorName) *fyne.Container {
348348
bgrnd := myTheme.NewThemedRectangle(colorName)
349-
bgrnd.CornerRadiusName = theme.SizeNameInputRadius
349+
bgrnd.CornerRadius = theme.InputRadiusSize()
350350
return container.NewStack(bgrnd,
351351
container.New(&layout.CustomPaddedLayout{LeftPadding: 10, RightPadding: 10, TopPadding: 10, BottomPadding: 10},
352352
obj))

ui/widgets/gridview.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ func (g *GridView) createGridWrap() {
304304

305305
func (g *GridView) createNewItemCard() fyne.CanvasObject {
306306
card := NewGridViewItem(g.Placeholder)
307+
card.Cover.Im.CornerRadius = theme.InputRadiusSize()
307308
card.SetSize(backend.AppInstance().Config.GridView.CardSize)
308309
card.ItemIndex = -1
309310
card.ImgLoader = util.NewThumbnailLoader(g.imageFetcher, card.Cover.SetImage)

ui/widgets/imageplaceholder.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
type ImagePlaceholder struct {
1818
ScaleMode canvas.ImageScale
1919
PlaceholderIcon fyne.Resource
20+
CornerRadius float32
2021

2122
widget.BaseWidget
2223
content *fyne.Container
@@ -109,6 +110,8 @@ func (i *ImagePlaceholder) Refresh() {
109110
i.imageDisp.Hidden = !i.HaveImage()
110111
i.imageDisp.ScaleMode = i.ScaleMode
111112
i.iconImage.ScaleMode = i.ScaleMode
113+
i.imageDisp.CornerRadius = i.CornerRadius
114+
i.border.CornerRadius = i.CornerRadius
112115
i.BaseWidget.Refresh()
113116
}
114117

ui/widgets/largenowplayingcard.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ import (
1919
type LargeNowPlayingCard struct {
2020
CaptionedImage
2121

22-
DisableRating bool
22+
DisableRating bool
23+
ImageCornerRadius float32
2324

2425
isRadio bool
2526
trackName *widget.RichText
@@ -163,5 +164,6 @@ func (n *LargeNowPlayingCard) Refresh() {
163164
} else {
164165
n.rating.Enable()
165166
}
167+
n.cover.CornerRadius = n.ImageCornerRadius
166168
n.BaseWidget.Refresh()
167169
}

0 commit comments

Comments
 (0)