pull in patched hyperlink bug fix from Fyne, start removing CustomHyperlink
This commit is contained in:
@@ -47,4 +47,4 @@ require (
|
|||||||
honnef.co/go/js/dom v0.0.0-20210725211120-f030747120f2 // indirect
|
honnef.co/go/js/dom v0.0.0-20210725211120-f030747120f2 // indirect
|
||||||
)
|
)
|
||||||
|
|
||||||
replace fyne.io/fyne/v2 v2.3.5 => github.com/dweymouth/fyne/v2 v2.3.0-rc1.0.20230505012127-ca61c153b2a5
|
replace fyne.io/fyne/v2 v2.3.5 => github.com/dweymouth/fyne/v2 v2.3.0-rc1.0.20231019154213-5f32d36c2968
|
||||||
|
|||||||
@@ -74,8 +74,8 @@ github.com/danieljoos/wincred v1.1.0/go.mod h1:XYlo+eRTsVA9aHGp7NGjFkPla4m+DCL7h
|
|||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/dweymouth/fyne/v2 v2.3.0-rc1.0.20230505012127-ca61c153b2a5 h1:uXbHzg9HfefA7OVHu9gahobCP5B43df3L1MwU0GbdRs=
|
github.com/dweymouth/fyne/v2 v2.3.0-rc1.0.20231019154213-5f32d36c2968 h1:RYHUvyoVXfXprkVU06XkzupfldcZ9vlhslxFYi00YCY=
|
||||||
github.com/dweymouth/fyne/v2 v2.3.0-rc1.0.20230505012127-ca61c153b2a5/go.mod h1:X2+NrR+62mvAiAt2fwKT7035zQsE77KVV1NlvWo4vW8=
|
github.com/dweymouth/fyne/v2 v2.3.0-rc1.0.20231019154213-5f32d36c2968/go.mod h1:X2+NrR+62mvAiAt2fwKT7035zQsE77KVV1NlvWo4vW8=
|
||||||
github.com/dweymouth/go-mpv v0.0.0-20230406003141-7f1858e503ee h1:ZGyJ6wp7CAfT31BugypcF/TPKEy2RrGR9JFq1JOjOpY=
|
github.com/dweymouth/go-mpv v0.0.0-20230406003141-7f1858e503ee h1:ZGyJ6wp7CAfT31BugypcF/TPKEy2RrGR9JFq1JOjOpY=
|
||||||
github.com/dweymouth/go-mpv v0.0.0-20230406003141-7f1858e503ee/go.mod h1:Ov0ieN90M7i+0k3OxhA/g1dozGs+UcPHDsMKqPgRDk0=
|
github.com/dweymouth/go-mpv v0.0.0-20230406003141-7f1858e503ee/go.mod h1:Ov0ieN90M7i+0k3OxhA/g1dozGs+UcPHDsMKqPgRDk0=
|
||||||
github.com/dweymouth/go-subsonic v0.0.0-20231013011542-14b66c5a1fff h1:71TfIg5TMXMi9rGQYFhW8Gvs/GmBGK9O2gSmgzYXl4I=
|
github.com/dweymouth/go-subsonic v0.0.0-20231013011542-14b66c5a1fff h1:71TfIg5TMXMi9rGQYFhW8Gvs/GmBGK9O2gSmgzYXl4I=
|
||||||
|
|||||||
@@ -175,8 +175,8 @@ type AlbumPageHeader struct {
|
|||||||
|
|
||||||
cover *widgets.TappableImage
|
cover *widgets.TappableImage
|
||||||
titleLabel *widget.RichText
|
titleLabel *widget.RichText
|
||||||
artistLabel *widgets.CustomHyperlink
|
artistLabel *widget.Hyperlink
|
||||||
genreLabel *widgets.CustomHyperlink
|
genreLabel *widget.Hyperlink
|
||||||
miscLabel *widget.Label
|
miscLabel *widget.Label
|
||||||
|
|
||||||
toggleFavButton *widgets.FavoriteButton
|
toggleFavButton *widgets.FavoriteButton
|
||||||
@@ -200,11 +200,13 @@ func NewAlbumPageHeader(page *AlbumPage) *AlbumPageHeader {
|
|||||||
a.titleLabel.Segments[0].(*widget.TextSegment).Style = widget.RichTextStyle{
|
a.titleLabel.Segments[0].(*widget.TextSegment).Style = widget.RichTextStyle{
|
||||||
SizeName: theme.SizeNameHeadingText,
|
SizeName: theme.SizeNameHeadingText,
|
||||||
}
|
}
|
||||||
a.artistLabel = widgets.NewCustomHyperlink()
|
a.artistLabel = widget.NewHyperlink("", nil)
|
||||||
|
a.artistLabel.Wrapping = fyne.TextTruncate
|
||||||
a.artistLabel.OnTapped = func() {
|
a.artistLabel.OnTapped = func() {
|
||||||
a.page.contr.NavigateTo(controller.ArtistRoute(a.artistID))
|
a.page.contr.NavigateTo(controller.ArtistRoute(a.artistID))
|
||||||
}
|
}
|
||||||
a.genreLabel = widgets.NewCustomHyperlink()
|
a.genreLabel = widget.NewHyperlink("", nil)
|
||||||
|
a.genreLabel.Wrapping = fyne.TextTruncate
|
||||||
a.genreLabel.OnTapped = func() {
|
a.genreLabel.OnTapped = func() {
|
||||||
a.page.contr.NavigateTo(controller.GenreRoute(a.genre))
|
a.page.contr.NavigateTo(controller.GenreRoute(a.genre))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -366,10 +366,9 @@ func (a *ArtistPageHeader) UpdateInfo(info *mediaprovider.ArtistInfo) {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
if len(a.similarArtists.Objects) <= i+1 {
|
if len(a.similarArtists.Objects) <= i+1 {
|
||||||
a.similarArtists.Add(widgets.NewCustomHyperlink())
|
a.similarArtists.Add(widget.NewHyperlink("", nil))
|
||||||
}
|
}
|
||||||
h := a.similarArtists.Objects[i+1].(*widgets.CustomHyperlink)
|
h := a.similarArtists.Objects[i+1].(*widget.Hyperlink)
|
||||||
h.NoTruncate = true
|
|
||||||
h.SetText(art.Name)
|
h.SetText(art.Name)
|
||||||
h.OnTapped = func(id string) func() {
|
h.OnTapped = func(id string) func() {
|
||||||
return func() { a.artistPage.contr.NavigateTo(controller.ArtistRoute(id)) }
|
return func() { a.artistPage.contr.NavigateTo(controller.ArtistRoute(id)) }
|
||||||
|
|||||||
@@ -1,133 +0,0 @@
|
|||||||
package widgets
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fyne.io/fyne/v2"
|
|
||||||
"fyne.io/fyne/v2/container"
|
|
||||||
"fyne.io/fyne/v2/layout"
|
|
||||||
"fyne.io/fyne/v2/theme"
|
|
||||||
"fyne.io/fyne/v2/widget"
|
|
||||||
)
|
|
||||||
|
|
||||||
type hyperlinkWrapper struct {
|
|
||||||
widget.Hyperlink
|
|
||||||
|
|
||||||
textWidthCached float32
|
|
||||||
MaxWidth float32
|
|
||||||
}
|
|
||||||
|
|
||||||
func newHyperlinkWrapper() *hyperlinkWrapper {
|
|
||||||
h := &hyperlinkWrapper{
|
|
||||||
Hyperlink: widget.Hyperlink{
|
|
||||||
Text: "",
|
|
||||||
Wrapping: fyne.TextTruncate,
|
|
||||||
},
|
|
||||||
textWidthCached: -1,
|
|
||||||
}
|
|
||||||
h.ExtendBaseWidget(h)
|
|
||||||
return h
|
|
||||||
}
|
|
||||||
|
|
||||||
func (h *hyperlinkWrapper) MinSize() fyne.Size {
|
|
||||||
if h.textWidthCached < 0 {
|
|
||||||
s := fyne.MeasureText(h.Text, theme.TextSize(), h.TextStyle)
|
|
||||||
// the 2.7 factor is a bit of a magic number but it works ¯\_(ツ)_/¯
|
|
||||||
h.textWidthCached = s.Width + theme.Padding()*2.7
|
|
||||||
}
|
|
||||||
return fyne.NewSize(fyne.Min(h.MaxWidth, h.textWidthCached), h.Hyperlink.MinSize().Height)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (h *hyperlinkWrapper) SetText(text string) {
|
|
||||||
h.Text = text
|
|
||||||
h.textWidthCached = -1
|
|
||||||
}
|
|
||||||
|
|
||||||
func (h *hyperlinkWrapper) TypedKey(e *fyne.KeyEvent) {
|
|
||||||
if e.Name == fyne.KeySpace {
|
|
||||||
if h.OnTapped != nil {
|
|
||||||
h.OnTapped()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type CustomHyperlink struct {
|
|
||||||
widget.BaseWidget
|
|
||||||
h *hyperlinkWrapper
|
|
||||||
l *widget.Label
|
|
||||||
|
|
||||||
OnTapped func()
|
|
||||||
NoTruncate bool
|
|
||||||
Disabled bool
|
|
||||||
|
|
||||||
lastDisabled bool
|
|
||||||
container *fyne.Container
|
|
||||||
fullTextWidth float32
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewCustomHyperlink() *CustomHyperlink {
|
|
||||||
c := &CustomHyperlink{
|
|
||||||
h: newHyperlinkWrapper(),
|
|
||||||
l: widget.NewLabel(""),
|
|
||||||
container: container.NewMax(),
|
|
||||||
}
|
|
||||||
c.h.OnTapped = func() {
|
|
||||||
if c.OnTapped != nil {
|
|
||||||
c.OnTapped()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
c.fullTextWidth = c.l.MinSize().Width
|
|
||||||
c.ExtendBaseWidget(c)
|
|
||||||
c.updateContainer(c.Disabled)
|
|
||||||
return c
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *CustomHyperlink) SetText(text string) {
|
|
||||||
lastWrapping := c.l.Wrapping
|
|
||||||
c.l.Wrapping = fyne.TextWrapOff
|
|
||||||
c.l.SetText(text)
|
|
||||||
c.fullTextWidth = c.l.MinSize().Width
|
|
||||||
c.h.SetText(text)
|
|
||||||
c.l.Wrapping = lastWrapping
|
|
||||||
c.Refresh()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *CustomHyperlink) SetTextStyle(style fyne.TextStyle) {
|
|
||||||
c.h.TextStyle = style
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *CustomHyperlink) Resize(size fyne.Size) {
|
|
||||||
c.h.MaxWidth = size.Width
|
|
||||||
c.BaseWidget.Resize(size)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *CustomHyperlink) Refresh() {
|
|
||||||
if c.NoTruncate {
|
|
||||||
c.l.Wrapping = fyne.TextWrapOff
|
|
||||||
} else {
|
|
||||||
c.l.Wrapping = fyne.TextTruncate
|
|
||||||
}
|
|
||||||
if c.lastDisabled != c.Disabled {
|
|
||||||
c.updateContainer(c.Disabled)
|
|
||||||
c.lastDisabled = c.Disabled
|
|
||||||
}
|
|
||||||
c.container.Refresh()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *CustomHyperlink) MinSize() fyne.Size {
|
|
||||||
if c.NoTruncate {
|
|
||||||
return fyne.NewSize(c.fullTextWidth, c.l.MinSize().Height)
|
|
||||||
}
|
|
||||||
return fyne.NewSize(0, c.l.MinSize().Height)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *CustomHyperlink) CreateRenderer() fyne.WidgetRenderer {
|
|
||||||
return widget.NewSimpleRenderer(c.container)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *CustomHyperlink) updateContainer(linkDisabled bool) {
|
|
||||||
c.container.RemoveAll()
|
|
||||||
if linkDisabled {
|
|
||||||
c.container.Add(c.l)
|
|
||||||
} else {
|
|
||||||
c.container.Add(container.NewHBox(c.h, layout.NewSpacer()))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
package widgets
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fyne.io/fyne/v2"
|
||||||
|
"fyne.io/fyne/v2/container"
|
||||||
|
"fyne.io/fyne/v2/widget"
|
||||||
|
)
|
||||||
|
|
||||||
|
type DisableableHyperlink struct {
|
||||||
|
widget.BaseWidget
|
||||||
|
h *widget.Hyperlink
|
||||||
|
l *widget.Label
|
||||||
|
|
||||||
|
OnTapped func()
|
||||||
|
NoTruncate bool
|
||||||
|
Disabled bool
|
||||||
|
|
||||||
|
lastDisabled bool
|
||||||
|
container *fyne.Container
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewDisableableHyperlink() *DisableableHyperlink {
|
||||||
|
c := &DisableableHyperlink{
|
||||||
|
h: widget.NewHyperlink("", nil),
|
||||||
|
l: widget.NewLabel(""),
|
||||||
|
container: container.NewMax(),
|
||||||
|
}
|
||||||
|
c.h.OnTapped = func() {
|
||||||
|
if c.OnTapped != nil {
|
||||||
|
c.OnTapped()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
c.ExtendBaseWidget(c)
|
||||||
|
c.updateContainer(c.Disabled)
|
||||||
|
return c
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *DisableableHyperlink) SetText(text string) {
|
||||||
|
lastWrapping := c.l.Wrapping
|
||||||
|
c.l.Wrapping = fyne.TextWrapOff
|
||||||
|
c.l.SetText(text)
|
||||||
|
c.h.SetText(text)
|
||||||
|
c.l.Wrapping = lastWrapping
|
||||||
|
c.Refresh()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *DisableableHyperlink) Refresh() {
|
||||||
|
if c.NoTruncate {
|
||||||
|
c.h.Wrapping = fyne.TextWrapOff
|
||||||
|
c.l.Wrapping = fyne.TextWrapOff
|
||||||
|
} else {
|
||||||
|
c.h.Wrapping = fyne.TextTruncate
|
||||||
|
c.l.Wrapping = fyne.TextTruncate
|
||||||
|
}
|
||||||
|
if c.lastDisabled != c.Disabled {
|
||||||
|
c.updateContainer(c.Disabled)
|
||||||
|
c.lastDisabled = c.Disabled
|
||||||
|
}
|
||||||
|
c.container.Refresh()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *DisableableHyperlink) CreateRenderer() fyne.WidgetRenderer {
|
||||||
|
return widget.NewSimpleRenderer(c.container)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *DisableableHyperlink) updateContainer(linkDisabled bool) {
|
||||||
|
c.container.RemoveAll()
|
||||||
|
if linkDisabled {
|
||||||
|
c.container.Add(c.l)
|
||||||
|
} else {
|
||||||
|
c.container.Add(c.h)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -134,8 +134,8 @@ type GridViewItem struct {
|
|||||||
|
|
||||||
itemID string
|
itemID string
|
||||||
secondaryID string
|
secondaryID string
|
||||||
primaryText *CustomHyperlink
|
primaryText *widget.Hyperlink
|
||||||
secondaryText *CustomHyperlink
|
secondaryText *DisableableHyperlink
|
||||||
container *fyne.Container
|
container *fyne.Container
|
||||||
|
|
||||||
// updated by GridView
|
// updated by GridView
|
||||||
@@ -150,11 +150,12 @@ type GridViewItem struct {
|
|||||||
|
|
||||||
func NewGridViewItem(placeholderResource fyne.Resource) *GridViewItem {
|
func NewGridViewItem(placeholderResource fyne.Resource) *GridViewItem {
|
||||||
g := &GridViewItem{
|
g := &GridViewItem{
|
||||||
primaryText: NewCustomHyperlink(),
|
primaryText: widget.NewHyperlink("", nil),
|
||||||
secondaryText: NewCustomHyperlink(),
|
secondaryText: NewDisableableHyperlink(),
|
||||||
Cover: newCoverImage(placeholderResource),
|
Cover: newCoverImage(placeholderResource),
|
||||||
}
|
}
|
||||||
g.primaryText.SetTextStyle(fyne.TextStyle{Bold: true})
|
g.primaryText.TextStyle.Bold = true
|
||||||
|
g.primaryText.Wrapping = fyne.TextTruncate
|
||||||
g.ExtendBaseWidget(g)
|
g.ExtendBaseWidget(g)
|
||||||
g.Cover.OnPlay = func() {
|
g.Cover.OnPlay = func() {
|
||||||
if g.OnPlay != nil {
|
if g.OnPlay != nil {
|
||||||
|
|||||||
@@ -17,9 +17,9 @@ import (
|
|||||||
type NowPlayingCard struct {
|
type NowPlayingCard struct {
|
||||||
widget.BaseWidget
|
widget.BaseWidget
|
||||||
|
|
||||||
trackName *CustomHyperlink
|
trackName *widget.Hyperlink
|
||||||
artistName *CustomHyperlink
|
artistName *DisableableHyperlink
|
||||||
albumName *CustomHyperlink
|
albumName *widget.Hyperlink
|
||||||
cover *TappableImage
|
cover *TappableImage
|
||||||
menu *widget.PopUpMenu
|
menu *widget.PopUpMenu
|
||||||
|
|
||||||
@@ -33,9 +33,9 @@ type NowPlayingCard struct {
|
|||||||
|
|
||||||
func NewNowPlayingCard() *NowPlayingCard {
|
func NewNowPlayingCard() *NowPlayingCard {
|
||||||
n := &NowPlayingCard{
|
n := &NowPlayingCard{
|
||||||
trackName: NewCustomHyperlink(),
|
trackName: widget.NewHyperlink("", nil),
|
||||||
artistName: NewCustomHyperlink(),
|
artistName: NewDisableableHyperlink(),
|
||||||
albumName: NewCustomHyperlink(),
|
albumName: widget.NewHyperlink("", nil),
|
||||||
}
|
}
|
||||||
n.ExtendBaseWidget(n)
|
n.ExtendBaseWidget(n)
|
||||||
n.cover = NewTappableImage(n.onShowCoverImage)
|
n.cover = NewTappableImage(n.onShowCoverImage)
|
||||||
@@ -43,7 +43,9 @@ func NewNowPlayingCard() *NowPlayingCard {
|
|||||||
n.trackName.Hidden = true
|
n.trackName.Hidden = true
|
||||||
n.artistName.Hidden = true
|
n.artistName.Hidden = true
|
||||||
n.albumName.Hidden = true
|
n.albumName.Hidden = true
|
||||||
n.trackName.SetTextStyle(fyne.TextStyle{Bold: true})
|
n.albumName.Wrapping = fyne.TextTruncate
|
||||||
|
n.trackName.Wrapping = fyne.TextTruncate
|
||||||
|
n.trackName.TextStyle.Bold = true
|
||||||
n.cover.SetMinSize(fyne.NewSize(85, 85))
|
n.cover.SetMinSize(fyne.NewSize(85, 85))
|
||||||
n.cover.FillMode = canvas.ImageFillContain
|
n.cover.FillMode = canvas.ImageFillContain
|
||||||
|
|
||||||
|
|||||||
@@ -676,8 +676,8 @@ type TrackRow struct {
|
|||||||
|
|
||||||
num *widget.RichText
|
num *widget.RichText
|
||||||
name *widget.RichText
|
name *widget.RichText
|
||||||
artist *CustomHyperlink
|
artist *DisableableHyperlink
|
||||||
album *CustomHyperlink
|
album *widget.Hyperlink
|
||||||
dur *widget.RichText
|
dur *widget.RichText
|
||||||
year *widget.RichText
|
year *widget.RichText
|
||||||
favorite *fyne.Container
|
favorite *fyne.Container
|
||||||
@@ -697,9 +697,10 @@ func NewTrackRow(tracklist *Tracklist, playingIcon fyne.CanvasObject) *TrackRow
|
|||||||
t.ExtendBaseWidget(t)
|
t.ExtendBaseWidget(t)
|
||||||
t.num = newTrailingAlignRichText()
|
t.num = newTrailingAlignRichText()
|
||||||
t.name = newTruncatingRichText()
|
t.name = newTruncatingRichText()
|
||||||
t.artist = NewCustomHyperlink()
|
t.artist = NewDisableableHyperlink()
|
||||||
t.artist.OnTapped = func() { tracklist.onArtistTapped(t.artistID) }
|
t.artist.OnTapped = func() { tracklist.onArtistTapped(t.artistID) }
|
||||||
t.album = NewCustomHyperlink()
|
t.album = widget.NewHyperlink("", nil)
|
||||||
|
t.album.Wrapping = fyne.TextTruncate
|
||||||
t.album.OnTapped = func() { tracklist.onAlbumTapped(t.albumID) }
|
t.album.OnTapped = func() { tracklist.onAlbumTapped(t.albumID) }
|
||||||
t.dur = newTrailingAlignRichText()
|
t.dur = newTrailingAlignRichText()
|
||||||
t.year = newTrailingAlignRichText()
|
t.year = newTrailingAlignRichText()
|
||||||
|
|||||||
Reference in New Issue
Block a user