Skip to content

Commit

Permalink
widget: Move some minsize calculations to the renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacalz committed Feb 27, 2024
1 parent 6b7246b commit 07c173f
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 20 deletions.
3 changes: 1 addition & 2 deletions widget/activity.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion widget/gridwrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down
7 changes: 2 additions & 5 deletions widget/hyperlink.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
9 changes: 2 additions & 7 deletions widget/label.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion widget/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down
6 changes: 2 additions & 4 deletions widget/separator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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() {
Expand Down

0 comments on commit 07c173f

Please sign in to comment.