quick minSize optimizations
This commit is contained in:
@@ -35,7 +35,6 @@ type AlbumsPage struct {
|
|||||||
|
|
||||||
type selectWidget struct {
|
type selectWidget struct {
|
||||||
widget.Select
|
widget.Select
|
||||||
height float32
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewSelect(options []string, onChanged func(string)) *selectWidget {
|
func NewSelect(options []string, onChanged func(string)) *selectWidget {
|
||||||
@@ -45,13 +44,12 @@ func NewSelect(options []string, onChanged func(string)) *selectWidget {
|
|||||||
OnChanged: onChanged,
|
OnChanged: onChanged,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
s.height = widget.NewSelect(nil, nil).MinSize().Height
|
|
||||||
s.ExtendBaseWidget(s)
|
s.ExtendBaseWidget(s)
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *selectWidget) MinSize() fyne.Size {
|
func (s *selectWidget) MinSize() fyne.Size {
|
||||||
return fyne.NewSize(170, s.height)
|
return fyne.NewSize(170, s.Select.MinSize().Height)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewAlbumsPage(cfg *backend.AlbumsPageConfig, contr *controller.Controller, pm *backend.PlaybackManager, lm *backend.LibraryManager, im *backend.ImageManager) *AlbumsPage {
|
func NewAlbumsPage(cfg *backend.AlbumsPageConfig, contr *controller.Controller, pm *backend.PlaybackManager, lm *backend.LibraryManager, im *backend.ImageManager) *AlbumsPage {
|
||||||
|
|||||||
+5
-10
@@ -71,20 +71,15 @@ func (s *Searcher) sendSearch(text string) {
|
|||||||
|
|
||||||
type SearchEntry struct {
|
type SearchEntry struct {
|
||||||
widget.Entry
|
widget.Entry
|
||||||
height float32
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewSearchEntry() *SearchEntry {
|
func NewSearchEntry() *SearchEntry {
|
||||||
sf := &SearchEntry{}
|
sf := &SearchEntry{}
|
||||||
sf.ExtendBaseWidget(sf)
|
sf.ExtendBaseWidget(sf)
|
||||||
// this is a bit hacky
|
|
||||||
sf.height = widget.NewEntry().MinSize().Height
|
|
||||||
sf.PlaceHolder = "Search"
|
sf.PlaceHolder = "Search"
|
||||||
c := NewClearTextButton()
|
sf.ActionItem = NewClearTextButton(func() {
|
||||||
c.OnTapped = func() {
|
|
||||||
sf.SetText("")
|
sf.SetText("")
|
||||||
}
|
})
|
||||||
sf.ActionItem = c
|
|
||||||
return sf
|
return sf
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,7 +93,7 @@ func (s *SearchEntry) Refresh() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *SearchEntry) MinSize() fyne.Size {
|
func (s *SearchEntry) MinSize() fyne.Size {
|
||||||
return fyne.NewSize(200, s.height)
|
return fyne.NewSize(200, s.Entry.MinSize().Height)
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ fyne.Tappable = (*clearTextButton)(nil)
|
var _ fyne.Tappable = (*clearTextButton)(nil)
|
||||||
@@ -109,8 +104,8 @@ type clearTextButton struct {
|
|||||||
OnTapped func()
|
OnTapped func()
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewClearTextButton() *clearTextButton {
|
func NewClearTextButton(onTapped func()) *clearTextButton {
|
||||||
c := &clearTextButton{}
|
c := &clearTextButton{OnTapped: onTapped}
|
||||||
c.ExtendBaseWidget(c)
|
c.ExtendBaseWidget(c)
|
||||||
c.Resource = theme.SearchIcon()
|
c.Resource = theme.SearchIcon()
|
||||||
return c
|
return c
|
||||||
|
|||||||
Reference in New Issue
Block a user