add keyboard scrolling to list views
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.4.4 => github.com/dweymouth/fyne/v2 v2.3.0-rc1.0.20240214155216-5dbf9d4fbd58
|
replace fyne.io/fyne/v2 v2.4.4 => github.com/dweymouth/fyne/v2 v2.3.0-rc1.0.20240218203813-b7a35021b57b
|
||||||
|
|||||||
@@ -69,8 +69,8 @@ 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/deluan/sanitize v0.0.0-20230310221930-6e18967d9fc1 h1:mGvOb3zxl4vCLv+dbf7JA6CAaM2UH/AGP1KX4DsJmTI=
|
github.com/deluan/sanitize v0.0.0-20230310221930-6e18967d9fc1 h1:mGvOb3zxl4vCLv+dbf7JA6CAaM2UH/AGP1KX4DsJmTI=
|
||||||
github.com/deluan/sanitize v0.0.0-20230310221930-6e18967d9fc1/go.mod h1:ZNCLJfehvEf34B7BbLKjgpsL9lyW7q938w/GY1XgV4E=
|
github.com/deluan/sanitize v0.0.0-20230310221930-6e18967d9fc1/go.mod h1:ZNCLJfehvEf34B7BbLKjgpsL9lyW7q938w/GY1XgV4E=
|
||||||
github.com/dweymouth/fyne/v2 v2.3.0-rc1.0.20240214155216-5dbf9d4fbd58 h1:0E0PTW6VUEwrw9WK3PTjzhF9dkuVh14J7JIPzsqNMFE=
|
github.com/dweymouth/fyne/v2 v2.3.0-rc1.0.20240218203813-b7a35021b57b h1:OTAeOqbaclUzdfx5iZY3lZrABgCI8sAOWedfW6Uasgs=
|
||||||
github.com/dweymouth/fyne/v2 v2.3.0-rc1.0.20240214155216-5dbf9d4fbd58/go.mod h1:VyrxAOZ3NRZRWBvNIJbfqoKOG4DdbewoPk7ozqJKNPY=
|
github.com/dweymouth/fyne/v2 v2.3.0-rc1.0.20240218203813-b7a35021b57b/go.mod h1:VyrxAOZ3NRZRWBvNIJbfqoKOG4DdbewoPk7ozqJKNPY=
|
||||||
github.com/dweymouth/go-jellyfin v0.0.0-20231116161116-e800860bdacc h1:wJy4U12Ys5Jgt08dgh5AW4suRZgKTwI1PUEmDu8aOmY=
|
github.com/dweymouth/go-jellyfin v0.0.0-20231116161116-e800860bdacc h1:wJy4U12Ys5Jgt08dgh5AW4suRZgKTwI1PUEmDu8aOmY=
|
||||||
github.com/dweymouth/go-jellyfin v0.0.0-20231116161116-e800860bdacc/go.mod h1:BMwS4vdjEYf1gmjPGSKCzWP/I6YlI6fkefJ9nsjBjaU=
|
github.com/dweymouth/go-jellyfin v0.0.0-20231116161116-e800860bdacc/go.mod h1:BMwS4vdjEYf1gmjPGSKCzWP/I6YlI6fkefJ9nsjBjaU=
|
||||||
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=
|
||||||
|
|||||||
@@ -145,6 +145,12 @@ func (a *AlbumPage) SelectAll() {
|
|||||||
a.tracklist.SelectAll()
|
a.tracklist.SelectAll()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ Scrollable = (*AlbumPage)(nil)
|
||||||
|
|
||||||
|
func (a *AlbumPage) Scroll(scrollAmt float32) {
|
||||||
|
a.tracklist.Scroll(scrollAmt)
|
||||||
|
}
|
||||||
|
|
||||||
// should be called asynchronously
|
// should be called asynchronously
|
||||||
func (a *AlbumPage) load() {
|
func (a *AlbumPage) load() {
|
||||||
album, err := a.mp.GetAlbum(a.albumID)
|
album, err := a.mp.GetAlbum(a.albumID)
|
||||||
|
|||||||
@@ -157,19 +157,24 @@ func (a *FavoritesPage) Scroll(amount float32) {
|
|||||||
case 1: // artists
|
case 1: // artists
|
||||||
grid = a.artistGrid
|
grid = a.artistGrid
|
||||||
default:
|
default:
|
||||||
|
if tr := a.tracklistOrNil(); tr != nil {
|
||||||
|
tr.Scroll(amount)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if grid != nil {
|
||||||
grid.ScrollToOffset(grid.GetScrollOffset() + amount)
|
grid.ScrollToOffset(grid.GetScrollOffset() + amount)
|
||||||
grid.Refresh()
|
grid.Refresh()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (a *FavoritesPage) Route() controller.Route {
|
func (a *FavoritesPage) Route() controller.Route {
|
||||||
return controller.FavoritesRoute()
|
return controller.FavoritesRoute()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *FavoritesPage) Tapped(*fyne.PointEvent) {
|
func (a *FavoritesPage) Tapped(*fyne.PointEvent) {
|
||||||
if a.tracklistCtr != nil {
|
if tr := a.tracklistOrNil(); tr != nil {
|
||||||
a.tracklistCtr.Objects[0].(*widgets.Tracklist).UnselectAll()
|
tr.UnselectAll()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,9 +197,8 @@ func (a *FavoritesPage) Reload() {
|
|||||||
if a.disposed {
|
if a.disposed {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if a.tracklistCtr != nil {
|
if tr := a.tracklistOrNil(); tr != nil {
|
||||||
// refresh favorite songs view
|
// refresh favorite songs view
|
||||||
tr := a.tracklistCtr.Objects[0].(*widgets.Tracklist)
|
|
||||||
tr.SetTracks(starred.Tracks)
|
tr.SetTracks(starred.Tracks)
|
||||||
if a.toggleBtns.ActivatedButtonIndex() == 2 {
|
if a.toggleBtns.ActivatedButtonIndex() == 2 {
|
||||||
// favorite songs view is visible
|
// favorite songs view is visible
|
||||||
@@ -239,8 +243,7 @@ func (a *FavoritesPage) Save() SavedPage {
|
|||||||
a.artistGrid.Clear()
|
a.artistGrid.Clear()
|
||||||
a.pool.Release(util.WidgetTypeGridView, a.artistGrid)
|
a.pool.Release(util.WidgetTypeGridView, a.artistGrid)
|
||||||
}
|
}
|
||||||
if a.tracklistCtr != nil {
|
if tl := a.tracklistOrNil(); tl != nil {
|
||||||
tl := a.tracklistCtr.Objects[0].(*widgets.Tracklist)
|
|
||||||
sf.trackSort = tl.Sorting()
|
sf.trackSort = tl.Sorting()
|
||||||
tl.Clear()
|
tl.Clear()
|
||||||
a.pool.Release(util.WidgetTypeTracklist, tl)
|
a.pool.Release(util.WidgetTypeTracklist, tl)
|
||||||
@@ -268,8 +271,7 @@ var _ CanShowNowPlaying = (*FavoritesPage)(nil)
|
|||||||
|
|
||||||
func (a *FavoritesPage) OnSongChange(song, lastScrobbledIfAny *mediaprovider.Track) {
|
func (a *FavoritesPage) OnSongChange(song, lastScrobbledIfAny *mediaprovider.Track) {
|
||||||
a.nowPlayingID = sharedutil.TrackIDOrEmptyStr(song)
|
a.nowPlayingID = sharedutil.TrackIDOrEmptyStr(song)
|
||||||
if a.tracklistCtr != nil {
|
if tracklist := a.tracklistOrNil(); tracklist != nil {
|
||||||
tracklist := a.tracklistCtr.Objects[0].(*widgets.Tracklist)
|
|
||||||
tracklist.SetNowPlaying(a.nowPlayingID)
|
tracklist.SetNowPlaying(a.nowPlayingID)
|
||||||
tracklist.IncrementPlayCount(sharedutil.TrackIDOrEmptyStr(lastScrobbledIfAny))
|
tracklist.IncrementPlayCount(sharedutil.TrackIDOrEmptyStr(lastScrobbledIfAny))
|
||||||
}
|
}
|
||||||
@@ -279,10 +281,17 @@ var _ CanSelectAll = (*FavoritesPage)(nil)
|
|||||||
|
|
||||||
func (a *FavoritesPage) SelectAll() {
|
func (a *FavoritesPage) SelectAll() {
|
||||||
if a.toggleBtns.ActivatedButtonIndex() == 2 /*songs*/ && a.tracklistCtr != nil {
|
if a.toggleBtns.ActivatedButtonIndex() == 2 /*songs*/ && a.tracklistCtr != nil {
|
||||||
a.tracklistCtr.Objects[0].(*widgets.Tracklist).SelectAll()
|
a.tracklistOrNil().SelectAll() // can't be nil in this case
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *FavoritesPage) tracklistOrNil() *widgets.Tracklist {
|
||||||
|
if a.tracklistCtr != nil {
|
||||||
|
return a.tracklistCtr.Objects[0].(*widgets.Tracklist)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (a *FavoritesPage) doSearchAlbums(query string) {
|
func (a *FavoritesPage) doSearchAlbums(query string) {
|
||||||
if a.searchText == "" {
|
if a.searchText == "" {
|
||||||
a.gridState = a.albumGrid.SaveToState()
|
a.gridState = a.albumGrid.SaveToState()
|
||||||
|
|||||||
@@ -93,6 +93,13 @@ func (a *GenresPage) SearchWidget() fyne.Focusable {
|
|||||||
return a.searcher
|
return a.searcher
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ Scrollable = (*GenresPage)(nil)
|
||||||
|
|
||||||
|
func (a *GenresPage) Scroll(amount float32) {
|
||||||
|
a.list.list.ScrollToOffset(a.list.list.GetScrollOffset() + amount)
|
||||||
|
a.list.list.Refresh()
|
||||||
|
}
|
||||||
|
|
||||||
func (a *GenresPage) Route() controller.Route {
|
func (a *GenresPage) Route() controller.Route {
|
||||||
return controller.GenresRoute()
|
return controller.GenresRoute()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -201,6 +201,12 @@ func (a *NowPlayingPage) Reload() {
|
|||||||
a.load("")
|
a.load("")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ Scrollable = (*NowPlayingPage)(nil)
|
||||||
|
|
||||||
|
func (a *NowPlayingPage) Scroll(scrollAmt float32) {
|
||||||
|
a.tracklist.Scroll(scrollAmt)
|
||||||
|
}
|
||||||
|
|
||||||
func (a *NowPlayingPage) onPlayTrackAt(tracknum int) {
|
func (a *NowPlayingPage) onPlayTrackAt(tracknum int) {
|
||||||
_ = a.pm.PlayTrackAt(tracknum)
|
_ = a.pm.PlayTrackAt(tracknum)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -142,6 +142,12 @@ func (a *PlaylistPage) SelectAll() {
|
|||||||
a.tracklist.SelectAll()
|
a.tracklist.SelectAll()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ Scrollable = (*PlaylistPage)(nil)
|
||||||
|
|
||||||
|
func (a *PlaylistPage) Scroll(scrollAmt float32) {
|
||||||
|
a.tracklist.Scroll(scrollAmt)
|
||||||
|
}
|
||||||
|
|
||||||
// should be called asynchronously
|
// should be called asynchronously
|
||||||
func (a *PlaylistPage) load() {
|
func (a *PlaylistPage) load() {
|
||||||
playlist, err := a.sm.Server.GetPlaylist(a.playlistID)
|
playlist, err := a.sm.Server.GetPlaylist(a.playlistID)
|
||||||
|
|||||||
@@ -88,6 +88,9 @@ func (p *PlaylistsPage) Scroll(scrollAmt float32) {
|
|||||||
if p.viewToggle.ActivatedButtonIndex() == 1 && p.gridView != nil {
|
if p.viewToggle.ActivatedButtonIndex() == 1 && p.gridView != nil {
|
||||||
p.gridView.ScrollToOffset(p.gridView.GetScrollOffset() + scrollAmt)
|
p.gridView.ScrollToOffset(p.gridView.GetScrollOffset() + scrollAmt)
|
||||||
p.gridView.Refresh()
|
p.gridView.Refresh()
|
||||||
|
} else if p.viewToggle.ActivatedButtonIndex() == 0 && p.listView != nil {
|
||||||
|
p.listView.list.ScrollToOffset(p.listView.list.GetScrollOffset() + scrollAmt)
|
||||||
|
p.listView.list.Refresh()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -105,6 +105,12 @@ func (t *TracksPage) OnSongChange(track, lastScrobbledIfAny *mediaprovider.Track
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ Scrollable = (*TracksPage)(nil)
|
||||||
|
|
||||||
|
func (g *TracksPage) Scroll(scrollAmt float32) {
|
||||||
|
g.tracklist.Scroll(scrollAmt)
|
||||||
|
}
|
||||||
|
|
||||||
var _ Searchable = (*TracksPage)(nil)
|
var _ Searchable = (*TracksPage)(nil)
|
||||||
|
|
||||||
func (t *TracksPage) SearchWidget() fyne.Focusable {
|
func (t *TracksPage) SearchWidget() fyne.Focusable {
|
||||||
|
|||||||
@@ -192,6 +192,11 @@ func (t *Tracklist) Reset() {
|
|||||||
t.SetSorting(TracklistSort{})
|
t.SetSorting(TracklistSort{})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t *Tracklist) Scroll(amount float32) {
|
||||||
|
t.list.ScrollToOffset(t.list.GetScrollOffset() + amount)
|
||||||
|
t.list.Refresh()
|
||||||
|
}
|
||||||
|
|
||||||
func (t *Tracklist) buildHeader() {
|
func (t *Tracklist) buildHeader() {
|
||||||
t.hdr = NewListHeader([]ListColumn{
|
t.hdr = NewListHeader([]ListColumn{
|
||||||
{Text: "#", Alignment: fyne.TextAlignTrailing, CanToggleVisible: false},
|
{Text: "#", Alignment: fyne.TextAlignTrailing, CanToggleVisible: false},
|
||||||
|
|||||||
Reference in New Issue
Block a user