Fix #813: use tracklist header to determine minimum width
This commit is contained in:
@@ -239,6 +239,7 @@ type tracklistRowBase struct {
|
|||||||
|
|
||||||
// must be injected by extending widget
|
// must be injected by extending widget
|
||||||
setColVisibility func(int, bool) bool
|
setColVisibility func(int, bool) bool
|
||||||
|
layout func(fyne.Size)
|
||||||
}
|
}
|
||||||
|
|
||||||
type TracklistRow interface {
|
type TracklistRow interface {
|
||||||
@@ -297,6 +298,9 @@ func NewExpandedTracklistRow(tracklist *Tracklist, im *backend.ImageManager, pla
|
|||||||
c.Hidden = vis
|
c.Hidden = vis
|
||||||
return c.Hidden != wasHidden
|
return c.Hidden != wasHidden
|
||||||
}
|
}
|
||||||
|
t.layout = func(s fyne.Size) {
|
||||||
|
container.Layout.Layout(container.Objects, s)
|
||||||
|
}
|
||||||
return t
|
return t
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -316,8 +320,9 @@ func NewCompactTracklistRow(tracklist *Tracklist, playingIcon fyne.CanvasObject)
|
|||||||
t.tracklistRowBase.create(tracklist)
|
t.tracklistRowBase.create(tracklist)
|
||||||
t.playingIcon = playingIcon
|
t.playingIcon = playingIcon
|
||||||
|
|
||||||
t.Content = container.New(tracklist.colLayout,
|
container := container.New(tracklist.colLayout,
|
||||||
t.num, t.name, t.artist, t.album, t.albumArtist, t.composer, t.genre, t.dur, t.year, t.favorite, t.rating, t.plays, t.lastPlayed, t.comment, t.bpm, t.bitrate, t.size, t.fileType, t.dateAdded, t.path)
|
t.num, t.name, t.artist, t.album, t.albumArtist, t.composer, t.genre, t.dur, t.year, t.favorite, t.rating, t.plays, t.lastPlayed, t.comment, t.bpm, t.bitrate, t.size, t.fileType, t.dateAdded, t.path)
|
||||||
|
t.Content = container
|
||||||
|
|
||||||
colHiddenPtrMap := map[int]*bool{
|
colHiddenPtrMap := map[int]*bool{
|
||||||
2: &t.artist.Hidden,
|
2: &t.artist.Hidden,
|
||||||
@@ -348,6 +353,9 @@ func NewCompactTracklistRow(tracklist *Tracklist, playingIcon fyne.CanvasObject)
|
|||||||
*ptr = vis
|
*ptr = vis
|
||||||
return vis != wasHidden
|
return vis != wasHidden
|
||||||
}
|
}
|
||||||
|
t.layout = func(s fyne.Size) {
|
||||||
|
container.Layout.Layout(container.Objects, s)
|
||||||
|
}
|
||||||
return t
|
return t
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -409,11 +417,20 @@ func (t *tracklistRowBase) TrackID() string {
|
|||||||
return t.trackID
|
return t.trackID
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t *tracklistRowBase) MinSize() fyne.Size {
|
||||||
|
// because tracklist rows have variable column visibility,
|
||||||
|
// we return a zero width here so that the tracklist
|
||||||
|
// can size based on the header instead.
|
||||||
|
s := t.BaseWidget.MinSize()
|
||||||
|
return fyne.NewSize(0, s.Height)
|
||||||
|
}
|
||||||
|
|
||||||
func (t *tracklistRowBase) Update(tm *util.TrackListModel, rowNum int, onUpdate func()) {
|
func (t *tracklistRowBase) Update(tm *util.TrackListModel, rowNum int, onUpdate func()) {
|
||||||
// Show only columns configured to be visible
|
// Show only columns configured to be visible
|
||||||
for i := 2; i < len(t.tracklist.columns); i++ {
|
for i := 2; i < len(t.tracklist.columns); i++ {
|
||||||
t.setColVisibility(i, !t.tracklist.visibleColumns[i])
|
t.setColVisibility(i, !t.tracklist.visibleColumns[i])
|
||||||
}
|
}
|
||||||
|
t.layout(t.Size())
|
||||||
|
|
||||||
// Ealy return if nothing else needs updating
|
// Ealy return if nothing else needs updating
|
||||||
if !t.needsUpdate(tm, rowNum) {
|
if !t.needsUpdate(tm, rowNum) {
|
||||||
|
|||||||
Reference in New Issue
Block a user