Skip to content

Commit

Permalink
widget: Remove unnecessary function
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacalz committed Jan 9, 2025
1 parent f37e80a commit 61e206b
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 15 deletions.
2 changes: 1 addition & 1 deletion widget/accordion.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ func (r *accordionRenderer) Refresh() {
}

func (r *accordionRenderer) updateObjects() {
th := r.container.themeWithLock()
th := r.container.Theme()
is := len(r.container.Items)
hs := len(r.headers)
ds := len(r.dividers)
Expand Down
2 changes: 1 addition & 1 deletion widget/button.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ func (r *buttonRenderer) Refresh() {
// applyTheme updates this button to match the current theme
// must be called with the button propertyLock RLocked
func (r *buttonRenderer) applyTheme() {
th := r.button.themeWithLock()
th := r.button.Theme()
v := fyne.CurrentApp().Settings().ThemeVariant()
fgColorName, bgColorName, bgBlendName := r.buttonColorNames()
if bg := r.background; bg != nil {
Expand Down
6 changes: 3 additions & 3 deletions widget/entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -919,7 +919,7 @@ func (e *Entry) copyToClipboard(clipboard fyne.Clipboard) {
}

func (e *Entry) cursorColAt(text []rune, pos fyne.Position) int {
th := e.themeWithLock()
th := e.Theme()
textSize := th.Size(theme.SizeNameText)
innerPad := th.Size(theme.SizeNameInnerPadding)

Expand Down Expand Up @@ -1063,7 +1063,7 @@ func (e *Entry) placeholderProvider() *RichText {
}

e.placeholder.Scroll = widget.ScrollNone
e.placeholder.inset = fyne.NewSize(0, e.themeWithLock().Size(theme.SizeNameInputBorder))
e.placeholder.inset = fyne.NewSize(0, e.Theme().Size(theme.SizeNameInputBorder))

style := RichTextStyleInline
style.ColorName = theme.ColorNamePlaceHolder
Expand Down Expand Up @@ -1367,7 +1367,7 @@ func (e *Entry) textProvider() *RichText {
}

e.text.Scroll = widget.ScrollNone
e.text.inset = fyne.NewSize(0, e.themeWithLock().Size(theme.SizeNameInputBorder))
e.text.inset = fyne.NewSize(0, e.Theme().Size(theme.SizeNameInputBorder))
e.text.Segments = []RichTextSegment{&TextSegment{Style: RichTextStyleInline, Text: e.Text}}
return &e.text
}
Expand Down
4 changes: 2 additions & 2 deletions widget/fileicon.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (i *FileIcon) SetURI(uri fyne.URI) {
// must be called with i.propertyLock RLocked
func (i *FileIcon) setURI(uri fyne.URI) {
if uri == nil {
i.resource = i.themeWithLock().Icon(theme.IconNameFile)
i.resource = i.Theme().Icon(theme.IconNameFile)
return
}

Expand Down Expand Up @@ -101,7 +101,7 @@ func (i *FileIcon) lookupIcon(uri fyne.URI) fyne.Resource {
return theme.FolderIcon()
}

th := i.themeWithLock()
th := i.Theme()
mainMimeType, _ := mime.Split(uri.MimeType())
switch mainMimeType {
case "application":
Expand Down
4 changes: 2 additions & 2 deletions widget/hyperlink.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,14 @@ func (hl *Hyperlink) MouseOut() {
}

func (hl *Hyperlink) focusWidth() float32 {
th := hl.themeWithLock()
th := hl.Theme()

innerPad := th.Size(theme.SizeNameInnerPadding)
return fyne.Min(hl.size.Load().Width, hl.textSize.Width+innerPad+th.Size(theme.SizeNamePadding)*2) - innerPad
}

func (hl *Hyperlink) focusXPos() float32 {
innerPad := hl.themeWithLock().Size(theme.SizeNameInnerPadding)
innerPad := hl.Theme().Size(theme.SizeNameInnerPadding)

switch hl.Alignment {
case fyne.TextAlignLeading:
Expand Down
2 changes: 1 addition & 1 deletion widget/menu.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ func (r *menuRenderer) layoutActiveChild() {
cp.X = c.Size().Width - absPos.X - childSize.Width
}
}
requiredHeight := childSize.Height - r.m.themeWithLock().Size(theme.SizeNamePadding)
requiredHeight := childSize.Height - r.m.Theme().Size(theme.SizeNamePadding)
availableHeight := c.Size().Height - absPos.Y
missingHeight := requiredHeight - availableHeight
if missingHeight > 0 {
Expand Down
2 changes: 1 addition & 1 deletion widget/select.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ func (s *selectRenderer) Refresh() {
s.updateLabel()
s.updateIcon(th)
s.background.FillColor = s.bgColor(th, v)
s.background.CornerRadius = s.combo.themeWithLock().Size(theme.SizeNameInputRadius)
s.background.CornerRadius = s.combo.Theme().Size(theme.SizeNameInputRadius)

s.Layout(s.combo.Size())
if s.combo.popUp != nil {
Expand Down
4 changes: 0 additions & 4 deletions widget/widget.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,6 @@ func (w *BaseWidget) Refresh() {
//
// Since: 2.5
func (w *BaseWidget) Theme() fyne.Theme {
return w.themeWithLock()
}

func (w *BaseWidget) themeWithLock() fyne.Theme {
cached := w.themeCache
if cached == nil {
cached = cache.WidgetTheme(w.super())
Expand Down

0 comments on commit 61e206b

Please sign in to comment.