add (non-focused) keyboard scrolling to grid view pages

This commit is contained in:
Drew Weymouth
2024-02-18 09:10:01 -08:00
parent 74a8aea72c
commit c6687aaa95
7 changed files with 92 additions and 21 deletions
+19
View File
@@ -30,10 +30,17 @@ type Searchable interface {
SearchWidget() fyne.Focusable
}
// Pages with selection should implement this interface to receive Ctrl+A events
type CanSelectAll interface {
SelectAll()
}
// Pages that have one main scrollable view should implement this interface
// to receive callbacks from window-level keyboard scrolling (up/down)
type Scrollable interface {
Scroll(amount float32)
}
type CanShowNowPlaying interface {
OnSongChange(song, lastScrobbledIfAny *mediaprovider.Track)
}
@@ -169,6 +176,18 @@ func (b *BrowsingPane) SelectAll() {
}
}
func (b *BrowsingPane) ScrollUp() {
if s, ok := b.curPage.(Scrollable); ok {
s.Scroll(-75)
}
}
func (b *BrowsingPane) ScrollDown() {
if s, ok := b.curPage.(Scrollable); ok {
s.Scroll(75)
}
}
func (b *BrowsingPane) doSetPage(p Page) bool {
if b.curPage != nil && b.curPage.Route() == p.Route() {
return false