use disabled list to avoid builtin focus handling
This commit is contained in:
@@ -144,7 +144,7 @@ type GenreList struct {
|
|||||||
|
|
||||||
columnsLayout *layouts.ColumnsLayout
|
columnsLayout *layouts.ColumnsLayout
|
||||||
hdr *widgets.ListHeader
|
hdr *widgets.ListHeader
|
||||||
list *widget.List
|
list *widgets.DisabledList
|
||||||
container *fyne.Container
|
container *fyne.Container
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,7 +184,7 @@ func NewGenreList(sorting widgets.ListHeaderSort) *GenreList {
|
|||||||
{"Name", fyne.TextAlignLeading, false}, {"Album Count", fyne.TextAlignTrailing, false}, {"Track Count", fyne.TextAlignTrailing, false}}, a.columnsLayout)
|
{"Name", fyne.TextAlignLeading, false}, {"Album Count", fyne.TextAlignTrailing, false}, {"Track Count", fyne.TextAlignTrailing, false}}, a.columnsLayout)
|
||||||
a.hdr.SetSorting(sorting)
|
a.hdr.SetSorting(sorting)
|
||||||
a.hdr.OnColumnSortChanged = a.onSorted
|
a.hdr.OnColumnSortChanged = a.onSorted
|
||||||
a.list = widget.NewList(
|
a.list = widgets.NewDisabledList(
|
||||||
func() int { return len(a.genres) },
|
func() int { return len(a.genres) },
|
||||||
func() fyne.CanvasObject {
|
func() fyne.CanvasObject {
|
||||||
r := NewGenreListRow(a.columnsLayout)
|
r := NewGenreListRow(a.columnsLayout)
|
||||||
|
|||||||
@@ -289,7 +289,7 @@ type PlaylistList struct {
|
|||||||
|
|
||||||
columnsLayout *layouts.ColumnsLayout
|
columnsLayout *layouts.ColumnsLayout
|
||||||
header *widgets.ListHeader
|
header *widgets.ListHeader
|
||||||
list *widget.List
|
list *widgets.DisabledList
|
||||||
container *fyne.Container
|
container *fyne.Container
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -299,7 +299,7 @@ func NewPlaylistList(initialSort widgets.ListHeaderSort) *PlaylistList {
|
|||||||
columnsLayout: layouts.NewColumnsLayout([]float32{-1, -1, 200, 125}),
|
columnsLayout: layouts.NewColumnsLayout([]float32{-1, -1, 200, 125}),
|
||||||
}
|
}
|
||||||
a.buildHeader()
|
a.buildHeader()
|
||||||
a.list = widget.NewList(
|
a.list = widgets.NewDisabledList(
|
||||||
func() int {
|
func() int {
|
||||||
return len(a.playlists)
|
return len(a.playlists)
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -217,7 +217,7 @@ type GenreFilterSubsection struct {
|
|||||||
noneBtn *widget.Button
|
noneBtn *widget.Button
|
||||||
listModelMutex sync.RWMutex
|
listModelMutex sync.RWMutex
|
||||||
genreListViewModel []string
|
genreListViewModel []string
|
||||||
genreListView *widget.List
|
genreListView *DisabledList
|
||||||
|
|
||||||
container *fyne.Container
|
container *fyne.Container
|
||||||
}
|
}
|
||||||
@@ -233,7 +233,7 @@ func NewGenreFilterSubsection(onChanged func([]string), initialSelectedGenres []
|
|||||||
g.selectedGenres[genre] = nil
|
g.selectedGenres[genre] = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
g.genreListView = widget.NewList(
|
g.genreListView = NewDisabledList(
|
||||||
func() int {
|
func() int {
|
||||||
g.listModelMutex.RLock()
|
g.listModelMutex.RLock()
|
||||||
defer g.listModelMutex.RUnlock()
|
defer g.listModelMutex.RUnlock()
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package widgets
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fyne.io/fyne/v2"
|
||||||
|
"fyne.io/fyne/v2/widget"
|
||||||
|
)
|
||||||
|
|
||||||
|
// DisabledList extends List to be disabled so that the
|
||||||
|
// focus manager considers it unfocusable.
|
||||||
|
// This is needed since we handle row focusability ourselves.
|
||||||
|
type DisabledList struct {
|
||||||
|
widget.List
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewDisabledList(len func() int, create func() fyne.CanvasObject, update func(widget.GridWrapItemID, fyne.CanvasObject)) *DisabledList {
|
||||||
|
g := &DisabledList{
|
||||||
|
List: widget.List{
|
||||||
|
Length: len,
|
||||||
|
CreateItem: create,
|
||||||
|
UpdateItem: update,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
g.ExtendBaseWidget(g)
|
||||||
|
return g
|
||||||
|
}
|
||||||
|
|
||||||
|
var _ fyne.Disableable = (*DisabledList)(nil)
|
||||||
|
|
||||||
|
func (g *DisabledList) Disabled() bool { return true }
|
||||||
|
|
||||||
|
func (g *DisabledList) Disable() {}
|
||||||
|
|
||||||
|
func (g *DisabledList) Enable() {}
|
||||||
+10
-10
@@ -74,7 +74,7 @@ type GridView struct {
|
|||||||
fetchCancel context.CancelFunc
|
fetchCancel context.CancelFunc
|
||||||
GridViewState
|
GridViewState
|
||||||
|
|
||||||
grid *unfocusableGridWrap
|
grid *disabledGridWrap
|
||||||
menu *widget.PopUpMenu
|
menu *widget.PopUpMenu
|
||||||
menuGridViewItemId string
|
menuGridViewItemId string
|
||||||
}
|
}
|
||||||
@@ -196,7 +196,7 @@ func (g *GridView) ScrollToOffset(offs float32) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (g *GridView) createGridWrap() {
|
func (g *GridView) createGridWrap() {
|
||||||
g.grid = NewUnfocusableGridWrap(
|
g.grid = NewDisabledGridWrap(
|
||||||
func() int {
|
func() int {
|
||||||
return g.lenItems()
|
return g.lenItems()
|
||||||
},
|
},
|
||||||
@@ -369,12 +369,13 @@ func (g *GridView) CreateRenderer() fyne.WidgetRenderer {
|
|||||||
return widget.NewSimpleRenderer(g.grid)
|
return widget.NewSimpleRenderer(g.grid)
|
||||||
}
|
}
|
||||||
|
|
||||||
type unfocusableGridWrap struct {
|
// a disabled widget is not considered focusable by the focus manager
|
||||||
|
type disabledGridWrap struct {
|
||||||
widget.GridWrap
|
widget.GridWrap
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewUnfocusableGridWrap(len func() int, create func() fyne.CanvasObject, update func(widget.GridWrapItemID, fyne.CanvasObject)) *unfocusableGridWrap {
|
func NewDisabledGridWrap(len func() int, create func() fyne.CanvasObject, update func(widget.GridWrapItemID, fyne.CanvasObject)) *disabledGridWrap {
|
||||||
g := &unfocusableGridWrap{
|
g := &disabledGridWrap{
|
||||||
GridWrap: widget.GridWrap{
|
GridWrap: widget.GridWrap{
|
||||||
Length: len,
|
Length: len,
|
||||||
CreateItem: create,
|
CreateItem: create,
|
||||||
@@ -385,11 +386,10 @@ func NewUnfocusableGridWrap(len func() int, create func() fyne.CanvasObject, upd
|
|||||||
return g
|
return g
|
||||||
}
|
}
|
||||||
|
|
||||||
// a disabled widget is not considered focusable by the focus manager
|
var _ fyne.Disableable = (*disabledGridWrap)(nil)
|
||||||
var _ fyne.Disableable = (*unfocusableGridWrap)(nil)
|
|
||||||
|
|
||||||
func (g *unfocusableGridWrap) Disabled() bool { return true }
|
func (g *disabledGridWrap) Disabled() bool { return true }
|
||||||
|
|
||||||
func (g *unfocusableGridWrap) Disable() {}
|
func (g *disabledGridWrap) Disable() {}
|
||||||
|
|
||||||
func (g *unfocusableGridWrap) Enable() {}
|
func (g *disabledGridWrap) Enable() {}
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ type Tracklist struct {
|
|||||||
nowPlayingID string
|
nowPlayingID string
|
||||||
colLayout *layouts.ColumnsLayout
|
colLayout *layouts.ColumnsLayout
|
||||||
hdr *ListHeader
|
hdr *ListHeader
|
||||||
list *widget.List
|
list *DisabledList
|
||||||
ctxMenu *fyne.Menu
|
ctxMenu *fyne.Menu
|
||||||
container *fyne.Container
|
container *fyne.Container
|
||||||
}
|
}
|
||||||
@@ -132,7 +132,7 @@ func NewTracklist(tracks []*mediaprovider.Track) *Tracklist {
|
|||||||
playIcon.ColorName = theme.ColorNamePrimary
|
playIcon.ColorName = theme.ColorNamePrimary
|
||||||
playingIcon := container.NewCenter(container.NewHBox(util.NewHSpace(2), widget.NewIcon(playIcon)))
|
playingIcon := container.NewCenter(container.NewHBox(util.NewHSpace(2), widget.NewIcon(playIcon)))
|
||||||
|
|
||||||
t.list = widget.NewList(
|
t.list = NewDisabledList(
|
||||||
t.lenTracks,
|
t.lenTracks,
|
||||||
func() fyne.CanvasObject {
|
func() fyne.CanvasObject {
|
||||||
tr := NewTrackRow(t, playingIcon)
|
tr := NewTrackRow(t, playingIcon)
|
||||||
|
|||||||
Reference in New Issue
Block a user