Skip to content

Commit

Permalink
add locking to hyperlink renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
dweymouth authored and Jacalz committed Feb 6, 2024
1 parent 9f8f9da commit 5182822
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions widget/hyperlink.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,16 +275,20 @@ func (r *hyperlinkRenderer) Destroy() {
}

func (r *hyperlinkRenderer) Layout(s fyne.Size) {
innerPad := r.hl.Theme().Size(theme.SizeNameInnerPadding)
r.hl.propertyLock.RLock()
textSize := r.hl.textSize
w := r.hl.focusWidth()
xposFocus := r.hl.focusXPos()
r.hl.propertyLock.RUnlock()

innerPad := theme.InnerPadding()
xposUnderline := xposFocus + innerPad/2
lineCount := float32(len(r.hl.provider.rowBounds))

r.hl.provider.Resize(s)
lineCount := float32(len(r.hl.provider.rowBounds))
r.focus.Move(fyne.NewPos(xposFocus, innerPad/2))
r.focus.Resize(fyne.NewSize(w, r.hl.textSize.Height*lineCount+innerPad))
r.under.Move(fyne.NewPos(xposUnderline, r.hl.textSize.Height*lineCount+theme.Padding()*2))
r.focus.Resize(fyne.NewSize(w, textSize.Height*lineCount+innerPad))
r.under.Move(fyne.NewPos(xposUnderline, textSize.Height*lineCount+theme.Padding()*2))
r.under.Resize(fyne.NewSize(w-innerPad, 1))
}

Expand All @@ -301,7 +305,9 @@ func (r *hyperlinkRenderer) Refresh() {
v := fyne.CurrentApp().Settings().ThemeVariant()

r.hl.provider.Refresh()
r.focus.StrokeColor = th.Color(theme.ColorNameFocus, v)
r.hl.propertyLock.RLock()
defer r.hl.propertyLock.RUnlock()
r.focus.StrokeColor = theme.FocusColor()
r.focus.Hidden = !r.hl.focused
r.focus.Refresh()
r.under.FillColor = th.Color(theme.ColorNameHyperlink, v)
Expand Down

0 comments on commit 5182822

Please sign in to comment.