From 07c173f2f684323fc878540f9588badd97ecbc43 Mon Sep 17 00:00:00 2001 From: Jacob Date: Tue, 27 Feb 2024 14:16:29 +0100 Subject: [PATCH] widget: Move some minsize calculations to the renderer --- widget/activity.go | 3 +-- widget/gridwrap.go | 1 - widget/hyperlink.go | 7 ++----- widget/label.go | 9 ++------- widget/list.go | 1 - widget/separator.go | 6 ++---- 6 files changed, 7 insertions(+), 20 deletions(-) diff --git a/widget/activity.go b/widget/activity.go index 07b62fb431..1bfa3eb584 100644 --- a/widget/activity.go +++ b/widget/activity.go @@ -34,8 +34,7 @@ func NewActivity() *Activity { func (a *Activity) MinSize() fyne.Size { a.ExtendBaseWidget(a) - - return fyne.NewSquareSize(a.Theme().Size(theme.SizeNameInlineIcon)) + return a.BaseWidget.MinSize() } // Start the activity indicator animation diff --git a/widget/gridwrap.go b/widget/gridwrap.go index 6be54a6a92..b6245396fc 100644 --- a/widget/gridwrap.go +++ b/widget/gridwrap.go @@ -112,7 +112,6 @@ func (l *GridWrap) FocusLost() { // MinSize returns the size that this widget should not shrink below. func (l *GridWrap) MinSize() fyne.Size { l.ExtendBaseWidget(l) - return l.BaseWidget.MinSize() } diff --git a/widget/hyperlink.go b/widget/hyperlink.go index e07f3156e9..728bfa5111 100644 --- a/widget/hyperlink.go +++ b/widget/hyperlink.go @@ -163,11 +163,8 @@ func (hl *Hyperlink) Refresh() { // MinSize returns the smallest size this widget can shrink to func (hl *Hyperlink) MinSize() fyne.Size { - if len(hl.provider.Segments) == 0 { - hl.syncSegments() - } - - return hl.provider.MinSize() + hl.ExtendBaseWidget(hl) + return hl.BaseWidget.MinSize() } // Resize sets a new size for the hyperlink. diff --git a/widget/label.go b/widget/label.go index e3bab90a57..a587137d36 100644 --- a/widget/label.go +++ b/widget/label.go @@ -3,7 +3,6 @@ package widget import ( "fyne.io/fyne/v2" "fyne.io/fyne/v2/data/binding" - "fyne.io/fyne/v2/internal/cache" "fyne.io/fyne/v2/theme" ) @@ -77,12 +76,8 @@ func (l *Label) CreateRenderer() fyne.WidgetRenderer { // // Implements: fyne.Widget func (l *Label) MinSize() fyne.Size { - if l.provider == nil { - l.ExtendBaseWidget(l) - cache.Renderer(l.super()) - } - - return l.provider.MinSize() + l.ExtendBaseWidget(l) + return l.BaseWidget.MinSize() } // Refresh triggers a redraw of the label. diff --git a/widget/list.go b/widget/list.go index 53bca499b1..dab4f25b91 100644 --- a/widget/list.go +++ b/widget/list.go @@ -110,7 +110,6 @@ func (l *List) FocusLost() { // MinSize returns the size that this widget should not shrink below. func (l *List) MinSize() fyne.Size { l.ExtendBaseWidget(l) - return l.BaseWidget.MinSize() } diff --git a/widget/separator.go b/widget/separator.go index 8f61de80ef..30d9433156 100644 --- a/widget/separator.go +++ b/widget/separator.go @@ -55,8 +55,7 @@ func (s *Separator) CreateRenderer() fyne.WidgetRenderer { // Implements: fyne.Widget func (s *Separator) MinSize() fyne.Size { s.ExtendBaseWidget(s) - t := s.Theme().Size(theme.SizeNameSeparatorThickness) - return fyne.NewSize(t, t) + return s.BaseWidget.MinSize() } var _ fyne.WidgetRenderer = (*separatorRenderer)(nil) @@ -68,8 +67,7 @@ type separatorRenderer struct { } func (r *separatorRenderer) MinSize() fyne.Size { - t := r.d.Theme().Size(theme.SizeNameSeparatorThickness) - return fyne.NewSize(t, t) + return fyne.NewSquareSize(r.d.Theme().Size(theme.SizeNameSeparatorThickness)) } func (r *separatorRenderer) Refresh() {