move to list fork
This commit is contained in:
@@ -28,6 +28,7 @@ require (
|
||||
github.com/danieljoos/wincred v1.1.0 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/disintegration/imaging v1.6.2 // indirect
|
||||
github.com/dweymouth/fyne-advanced-list v0.0.0-20240614152514-d7bef361f680 // indirect
|
||||
github.com/fredbi/uri v1.1.0 // indirect
|
||||
github.com/fsnotify/fsnotify v1.7.0 // indirect
|
||||
github.com/fyne-io/gl-js v0.0.0-20220119005834-d2da28d9ccfe // indirect
|
||||
|
||||
@@ -84,6 +84,10 @@ github.com/deluan/sanitize v0.0.0-20230310221930-6e18967d9fc1 h1:mGvOb3zxl4vCLv+
|
||||
github.com/deluan/sanitize v0.0.0-20230310221930-6e18967d9fc1/go.mod h1:ZNCLJfehvEf34B7BbLKjgpsL9lyW7q938w/GY1XgV4E=
|
||||
github.com/disintegration/imaging v1.6.2 h1:w1LecBlG2Lnp8B3jk5zSuNqd7b4DXhcjwek1ei82L+c=
|
||||
github.com/disintegration/imaging v1.6.2/go.mod h1:44/5580QXChDfwIclfc/PCwrr44amcmDAg8hxG0Ewe4=
|
||||
github.com/dweymouth/fyne-advanced-list v0.0.0-20240614151622-9f11c64def19 h1:AfKaUmPlcXyQRlCH/3tX2A+oIOKLC14Ns3AfIjn4NC4=
|
||||
github.com/dweymouth/fyne-advanced-list v0.0.0-20240614151622-9f11c64def19/go.mod h1:5bICtCEhLzJ4MlRORlUa3L0CadB6xQTNW9DhTXl/UN0=
|
||||
github.com/dweymouth/fyne-advanced-list v0.0.0-20240614152514-d7bef361f680 h1:PDffxh0kv4czCCrFV2uSWDRKnIgpaDZhqohB4mYX9Vg=
|
||||
github.com/dweymouth/fyne-advanced-list v0.0.0-20240614152514-d7bef361f680/go.mod h1:5bICtCEhLzJ4MlRORlUa3L0CadB6xQTNW9DhTXl/UN0=
|
||||
github.com/dweymouth/fyne-lyrics v0.0.0-20240528234907-15eee7ce5e64 h1:RUIrnGY034rDMlcOui/daurwX5b+52KdUKhH9aXaDSg=
|
||||
github.com/dweymouth/fyne-lyrics v0.0.0-20240528234907-15eee7ce5e64/go.mod h1:3YrjFDHMlhCsSZ/OvmJCxWm9QHSgOVWZBxnraZz9Z7c=
|
||||
github.com/dweymouth/fyne/v2 v2.3.0-rc1.0.20240604143614-256525c6a602 h1:k3jFLjmAuPJ5ZFNF57szZp8XrLIb6mIdEEGPkm6EZ7Q=
|
||||
|
||||
@@ -212,7 +212,6 @@ func NewGenreList(sorting widgets.ListHeaderSort) *GenreList {
|
||||
},
|
||||
func(id widget.ListItemID, item fyne.CanvasObject) {
|
||||
row := item.(*GenreListRow)
|
||||
a.list.SetItemForID(id, row)
|
||||
if row.Item != a.genres[id] {
|
||||
row.EnsureUnfocused()
|
||||
row.ListItemID = id
|
||||
|
||||
@@ -354,7 +354,6 @@ func NewPlaylistList(initialSort widgets.ListHeaderSort) *PlaylistList {
|
||||
row := item.(*PlaylistListRow)
|
||||
if row.PlaylistID != a.playlists[id].ID {
|
||||
row.EnsureUnfocused()
|
||||
a.list.SetItemForID(id, row)
|
||||
row.ListItemID = id
|
||||
row.PlaylistID = a.playlists[id].ID
|
||||
row.nameLabel.Text = a.playlists[id].Name
|
||||
|
||||
@@ -279,7 +279,6 @@ func NewRadioList(nowPlayingIDPtr *string) *RadioList {
|
||||
},
|
||||
func(id widget.ListItemID, item fyne.CanvasObject) {
|
||||
row := item.(*RadioListRow)
|
||||
a.list.SetItemForID(id, row)
|
||||
changed := false
|
||||
if row.Item != a.radios[id] {
|
||||
row.EnsureUnfocused()
|
||||
|
||||
@@ -274,7 +274,6 @@ func NewGenreFilterSubsection(onChanged func([]string), initialSelectedGenres []
|
||||
_, selected := g.selectedGenres[genre]
|
||||
g.selectedGenresMutex.RUnlock()
|
||||
row := obj.(*genreListViewRow)
|
||||
g.genreListView.SetItemForID(id, row)
|
||||
row.ListItemID = id
|
||||
row.Content.(*widget.Check).Text = genre
|
||||
row.Content.(*widget.Check).Checked = selected
|
||||
|
||||
+12
-24
@@ -9,16 +9,17 @@ import (
|
||||
"fyne.io/fyne/v2/container"
|
||||
"fyne.io/fyne/v2/theme"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
|
||||
list "github.com/dweymouth/fyne-advanced-list"
|
||||
)
|
||||
|
||||
// FocusList extends List to be disabled so that the focus manager
|
||||
// considers it unfocusable, and adds utilities for handling our
|
||||
// own focus navigation on the rows directly (with FocusListRow
|
||||
type FocusList struct {
|
||||
widget.List
|
||||
list.List
|
||||
|
||||
mutex sync.Mutex
|
||||
itemForIndex map[widget.ListItemID]FocusListRow
|
||||
mutex sync.Mutex
|
||||
}
|
||||
|
||||
type FocusListRow interface {
|
||||
@@ -33,13 +34,12 @@ type FocusListRow interface {
|
||||
|
||||
func NewFocusList(len func() int, create func() fyne.CanvasObject, update func(widget.GridWrapItemID, fyne.CanvasObject)) *FocusList {
|
||||
g := &FocusList{
|
||||
List: widget.List{
|
||||
List: list.List{
|
||||
HideSeparators: true,
|
||||
Length: len,
|
||||
CreateItem: create,
|
||||
UpdateItem: update,
|
||||
},
|
||||
itemForIndex: make(map[int]FocusListRow),
|
||||
}
|
||||
g.ExtendBaseWidget(g)
|
||||
return g
|
||||
@@ -53,21 +53,6 @@ func (g *FocusList) Disable() {}
|
||||
|
||||
func (g *FocusList) Enable() {}
|
||||
|
||||
// MUST be called *before* updating the ListItemID field to the
|
||||
// new ItemID this row will be bound to.
|
||||
func (g *FocusList) SetItemForID(id widget.ListItemID, item FocusListRow) {
|
||||
g.mutex.Lock()
|
||||
if other, ok := g.itemForIndex[id]; ok && other == item {
|
||||
delete(g.itemForIndex, other.ItemID())
|
||||
}
|
||||
g.itemForIndex[id] = item
|
||||
g.mutex.Unlock()
|
||||
}
|
||||
|
||||
func (g *FocusList) ClearItemForIDMap() {
|
||||
g.itemForIndex = make(map[int]FocusListRow)
|
||||
}
|
||||
|
||||
func (g *FocusList) FocusNeighbor(curItem widget.ListItemID, up bool) {
|
||||
focusIdx := curItem + 1
|
||||
if up {
|
||||
@@ -77,10 +62,10 @@ func (g *FocusList) FocusNeighbor(curItem widget.ListItemID, up bool) {
|
||||
g.ScrollTo(focusIdx)
|
||||
}
|
||||
g.mutex.Lock()
|
||||
other, ok := g.itemForIndex[focusIdx]
|
||||
other := g.ItemForID(focusIdx)
|
||||
g.mutex.Unlock()
|
||||
if ok {
|
||||
fyne.CurrentApp().Driver().CanvasForObject(g).Focus(other)
|
||||
if other != nil {
|
||||
fyne.CurrentApp().Driver().CanvasForObject(g).Focus(other.(fyne.Focusable))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,7 +113,10 @@ func (l *FocusListRowBase) SetItemID(id widget.ListItemID) {
|
||||
|
||||
func (l *FocusListRowBase) EnsureUnfocused() {
|
||||
if l.Focused {
|
||||
fyne.CurrentApp().Driver().CanvasForObject(l).Unfocus()
|
||||
c := fyne.CurrentApp().Driver().CanvasForObject(l)
|
||||
if c != nil {
|
||||
c.Unfocus()
|
||||
}
|
||||
}
|
||||
l.Focused = false
|
||||
}
|
||||
|
||||
@@ -96,7 +96,6 @@ func NewPlayQueueList(im *backend.ImageManager, useNonQueueMenu bool) *PlayQueue
|
||||
p.tracksMutex.RUnlock()
|
||||
|
||||
tr := item.(*PlayQueueListRow)
|
||||
p.list.SetItemForID(itemID, tr)
|
||||
if tr.trackID != model.Item.Metadata().ID || tr.ListItemID != itemID {
|
||||
tr.ListItemID = itemID
|
||||
}
|
||||
@@ -109,7 +108,6 @@ func NewPlayQueueList(im *backend.ImageManager, useNonQueueMenu bool) *PlayQueue
|
||||
|
||||
func (p *PlayQueueList) SetTracks(trs []*mediaprovider.Track) {
|
||||
p.tracksMutex.Lock()
|
||||
p.list.ClearItemForIDMap()
|
||||
p.items = util.ToTrackListModels(trs)
|
||||
p.tracksMutex.Unlock()
|
||||
p.Refresh()
|
||||
@@ -117,7 +115,6 @@ func (p *PlayQueueList) SetTracks(trs []*mediaprovider.Track) {
|
||||
|
||||
func (p *PlayQueueList) SetItems(items []mediaprovider.MediaItem) {
|
||||
p.tracksMutex.Lock()
|
||||
p.list.ClearItemForIDMap()
|
||||
p.items = sharedutil.MapSlice(items, func(item mediaprovider.MediaItem) *util.TrackListModel {
|
||||
return &util.TrackListModel{Item: item}
|
||||
})
|
||||
|
||||
@@ -170,7 +170,6 @@ func NewTracklist(tracks []*mediaprovider.Track, im *backend.ImageManager, useCo
|
||||
t.tracksMutex.RUnlock()
|
||||
|
||||
tr := item.(TracklistRow)
|
||||
t.list.SetItemForID(itemID, tr)
|
||||
if tr.TrackID() != model.Item.Metadata().ID || tr.ItemID() != itemID {
|
||||
tr.SetItemID(itemID)
|
||||
}
|
||||
@@ -300,7 +299,6 @@ func (t *Tracklist) Clear() {
|
||||
defer t.tracksMutex.Unlock()
|
||||
t.tracks = nil
|
||||
t.tracksOrigOrder = nil
|
||||
t.list.ClearItemForIDMap()
|
||||
}
|
||||
|
||||
// Sets the tracks in the tracklist. Thread-safe.
|
||||
@@ -312,9 +310,6 @@ func (t *Tracklist) SetTracks(trs []*mediaprovider.Track) {
|
||||
func (t *Tracklist) _setTracks(trs []*mediaprovider.Track) {
|
||||
t.tracksMutex.Lock()
|
||||
defer t.tracksMutex.Unlock()
|
||||
if t.list != nil {
|
||||
t.list.ClearItemForIDMap()
|
||||
}
|
||||
t.tracksOrigOrder = util.ToTrackListModels(trs)
|
||||
t.doSortTracks()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user