ensure clicking anywhere outside tracklists can unselect all
This commit is contained in:
@@ -143,14 +143,16 @@ func (a *AlbumPage) Reload() {
|
||||
go a.load()
|
||||
}
|
||||
|
||||
func (a *AlbumPage) Tapped(*fyne.PointEvent) {
|
||||
a.tracklist.UnselectAll()
|
||||
}
|
||||
var _ CanSelectAll = (*AlbumPage)(nil)
|
||||
|
||||
func (a *AlbumPage) SelectAll() {
|
||||
a.tracklist.SelectAll()
|
||||
}
|
||||
|
||||
func (a *AlbumPage) UnselectAll() {
|
||||
a.tracklist.UnselectAll()
|
||||
}
|
||||
|
||||
var _ Scrollable = (*AlbumPage)(nil)
|
||||
|
||||
func (a *AlbumPage) Scroll(scrollAmt float32) {
|
||||
|
||||
@@ -110,12 +110,6 @@ func newArtistPage(artistID string, cfg *backend.ArtistPageConfig, pool *util.Wi
|
||||
return a
|
||||
}
|
||||
|
||||
func (a *ArtistPage) Tapped(*fyne.PointEvent) {
|
||||
if a.tracklistCtr != nil {
|
||||
a.tracklistCtr.Objects[0].(*widgets.Tracklist).UnselectAll()
|
||||
}
|
||||
}
|
||||
|
||||
var _ CanSelectAll = (*ArtistPage)(nil)
|
||||
|
||||
func (a *ArtistPage) SelectAll() {
|
||||
@@ -124,6 +118,12 @@ func (a *ArtistPage) SelectAll() {
|
||||
}
|
||||
}
|
||||
|
||||
func (a *ArtistPage) UnselectAll() {
|
||||
if a.tracklistCtr != nil {
|
||||
a.tracklistCtr.Objects[0].(*widgets.Tracklist).UnselectAll()
|
||||
}
|
||||
}
|
||||
|
||||
func (a *ArtistPage) Route() controller.Route {
|
||||
return controller.ArtistRoute(a.artistID)
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ type Searchable interface {
|
||||
// Pages with selection should implement this interface to receive Ctrl+A events
|
||||
type CanSelectAll interface {
|
||||
SelectAll()
|
||||
UnselectAll()
|
||||
}
|
||||
|
||||
// Pages that have one main scrollable view should implement this interface
|
||||
@@ -199,6 +200,12 @@ func (b *BrowsingPane) SelectAll() {
|
||||
}
|
||||
}
|
||||
|
||||
func (b *BrowsingPane) UnselectAll() {
|
||||
if s, ok := b.curPage.(CanSelectAll); ok {
|
||||
s.UnselectAll()
|
||||
}
|
||||
}
|
||||
|
||||
func (b *BrowsingPane) ScrollUp() {
|
||||
b.scrollBy(-75)
|
||||
}
|
||||
|
||||
@@ -174,12 +174,6 @@ func (a *FavoritesPage) Route() controller.Route {
|
||||
return controller.FavoritesRoute()
|
||||
}
|
||||
|
||||
func (a *FavoritesPage) Tapped(*fyne.PointEvent) {
|
||||
if tr := a.tracklistOrNil(); tr != nil {
|
||||
tr.UnselectAll()
|
||||
}
|
||||
}
|
||||
|
||||
func (a *FavoritesPage) Reload() {
|
||||
// reload favorite albums view
|
||||
if a.searchText != "" {
|
||||
@@ -287,6 +281,12 @@ func (a *FavoritesPage) SelectAll() {
|
||||
}
|
||||
}
|
||||
|
||||
func (a *FavoritesPage) UnselectAll() {
|
||||
if a.toggleBtns.ActivatedButtonIndex() == 2 /*songs*/ && a.tracklistCtr != nil {
|
||||
a.tracklistOrNil().UnselectAll() // can't be nil in this case
|
||||
}
|
||||
}
|
||||
|
||||
func (a *FavoritesPage) Refresh() {
|
||||
if a.albumGrid != nil {
|
||||
a.albumGrid.ShowSuffix = a.cfg.ShowAlbumYears
|
||||
|
||||
@@ -470,31 +470,30 @@ func (a *NowPlayingPage) OnPlayTimeUpdate(curTime, _ float64, seeked bool) {
|
||||
}
|
||||
}
|
||||
|
||||
func (a *NowPlayingPage) currentTracklistOrNil() *widgets.PlayQueueList {
|
||||
if a.tabs != nil {
|
||||
|
||||
switch a.tabs.SelectedIndex() {
|
||||
case 0: /*queue*/
|
||||
return a.queueList
|
||||
case 2: /*related*/
|
||||
return a.relatedList
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
var _ CanSelectAll = (*NowPlayingPage)(nil)
|
||||
|
||||
func (a *NowPlayingPage) SelectAll() {
|
||||
if a.tabs == nil {
|
||||
return
|
||||
}
|
||||
switch a.tabs.SelectedIndex() {
|
||||
case 0: /*queue*/
|
||||
a.queueList.SelectAll()
|
||||
case 2: /*related*/
|
||||
a.relatedList.SelectAll()
|
||||
if l := a.currentTracklistOrNil(); l != nil {
|
||||
l.SelectAll()
|
||||
}
|
||||
}
|
||||
|
||||
var _ fyne.Tappable = (*NowPlayingPage)(nil)
|
||||
|
||||
func (a *NowPlayingPage) Tapped(*fyne.PointEvent) {
|
||||
if a.tabs == nil {
|
||||
return
|
||||
}
|
||||
switch a.tabs.SelectedIndex() {
|
||||
case 0: /*queue*/
|
||||
a.queueList.UnselectAll()
|
||||
case 2: /*related*/
|
||||
a.relatedList.UnselectAll()
|
||||
func (a *NowPlayingPage) UnselectAll() {
|
||||
if l := a.currentTracklistOrNil(); l != nil {
|
||||
l.UnselectAll()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -139,14 +139,16 @@ func (a *PlaylistPage) Reload() {
|
||||
go a.load()
|
||||
}
|
||||
|
||||
func (a *PlaylistPage) Tapped(*fyne.PointEvent) {
|
||||
a.tracklist.UnselectAll()
|
||||
}
|
||||
var _ CanSelectAll = (*PlaylistPage)(nil)
|
||||
|
||||
func (a *PlaylistPage) SelectAll() {
|
||||
a.tracklist.SelectAll()
|
||||
}
|
||||
|
||||
func (a *PlaylistPage) UnselectAll() {
|
||||
a.tracklist.UnselectAll()
|
||||
}
|
||||
|
||||
var _ Scrollable = (*PlaylistPage)(nil)
|
||||
|
||||
func (a *PlaylistPage) Scroll(scrollAmt float32) {
|
||||
|
||||
@@ -89,6 +89,18 @@ func (t *TracksPage) Route() controller.Route {
|
||||
return controller.TracksRoute()
|
||||
}
|
||||
|
||||
var _ CanSelectAll = (*TracksPage)(nil)
|
||||
|
||||
func (t *TracksPage) SelectAll() {
|
||||
// deliberate no-op since we don't want to give the impression
|
||||
// that you can select all tracks from the server, since only
|
||||
// some of them are actually loaded into the model
|
||||
}
|
||||
|
||||
func (t *TracksPage) UnselectAll() {
|
||||
t.currentTracklist().UnselectAll()
|
||||
}
|
||||
|
||||
func (t *TracksPage) Reload() {
|
||||
t.tracklist.Clear()
|
||||
iter := t.mp.IterateTracks("")
|
||||
@@ -161,6 +173,10 @@ func (t *TracksPage) doSearch(query string) {
|
||||
t.Refresh()
|
||||
}
|
||||
|
||||
func (t *TracksPage) currentTracklist() *widgets.Tracklist {
|
||||
return t.container.Objects[0].(*fyne.Container).Objects[0].(*widgets.Tracklist)
|
||||
}
|
||||
|
||||
func (t *TracksPage) CreateRenderer() fyne.WidgetRenderer {
|
||||
return widget.NewSimpleRenderer(t.container)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user