beginning work on browse by favorite artists and songs

This commit is contained in:
Drew Weymouth
2023-02-21 18:10:10 -08:00
parent d9ec269191
commit c4dba8f1fb
3 changed files with 150 additions and 8 deletions
+58
View File
@@ -0,0 +1,58 @@
package layouts
import (
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/theme"
)
var _ fyne.Layout = (*VboxCustomPadding)(nil)
type HboxCustomPadding struct {
ExtraPad float32
DisableThemePad bool
}
func (v *HboxCustomPadding) MinSize(objects []fyne.CanvasObject) fyne.Size {
minSize := fyne.NewSize(0, 0)
for _, child := range objects {
if !child.Visible() {
continue
}
minSize.Height = fyne.Max(child.MinSize().Height, minSize.Height)
minSize.Width += child.MinSize().Width
}
minSize.Width += (v.themePad() + v.ExtraPad) * float32(len(objects)-1)
return minSize
}
func (v *HboxCustomPadding) Layout(objects []fyne.CanvasObject, size fyne.Size) {
total := float32(0)
for _, child := range objects {
if !child.Visible() {
continue
}
total += child.MinSize().Width
}
x, y := float32(0), float32(0)
extra := float32(0)
for _, child := range objects {
if !child.Visible() {
continue
}
width := child.MinSize().Width
child.Move(fyne.NewPos(x+extra, y))
x += width
child.Resize(fyne.NewSize(width, size.Height))
extra += (v.themePad() + v.ExtraPad)
}
}
func (v *HboxCustomPadding) themePad() float32 {
if v.DisableThemePad {
return 0
}
return theme.Padding()
}