Fix #149: correct MinSize calculation for CustomHyperlink
This commit is contained in:
@@ -60,7 +60,7 @@ type CustomHyperlink struct {
|
|||||||
|
|
||||||
lastDisabled bool
|
lastDisabled bool
|
||||||
container *fyne.Container
|
container *fyne.Container
|
||||||
minSize fyne.Size
|
fullTextWidth float32
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewCustomHyperlink() *CustomHyperlink {
|
func NewCustomHyperlink() *CustomHyperlink {
|
||||||
@@ -74,8 +74,8 @@ func NewCustomHyperlink() *CustomHyperlink {
|
|||||||
c.OnTapped()
|
c.OnTapped()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
c.fullTextWidth = c.l.MinSize().Width
|
||||||
c.ExtendBaseWidget(c)
|
c.ExtendBaseWidget(c)
|
||||||
c.minSize = c.h.MinSize()
|
|
||||||
c.updateContainer(c.Disabled)
|
c.updateContainer(c.Disabled)
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
@@ -84,13 +84,8 @@ func (c *CustomHyperlink) SetText(text string) {
|
|||||||
c.l.Text = text
|
c.l.Text = text
|
||||||
lastWrapping := c.l.Wrapping
|
lastWrapping := c.l.Wrapping
|
||||||
c.l.Wrapping = fyne.TextWrapOff
|
c.l.Wrapping = fyne.TextWrapOff
|
||||||
s := c.l.MinSize()
|
c.fullTextWidth = c.l.MinSize().Width
|
||||||
c.h.SetText(text)
|
c.h.SetText(text)
|
||||||
if c.NoTruncate {
|
|
||||||
c.minSize = s
|
|
||||||
} else {
|
|
||||||
c.minSize = fyne.NewSize(fyne.Min(c.Size().Width, s.Width), s.Height)
|
|
||||||
}
|
|
||||||
c.l.Wrapping = lastWrapping
|
c.l.Wrapping = lastWrapping
|
||||||
c.Refresh()
|
c.Refresh()
|
||||||
}
|
}
|
||||||
@@ -114,7 +109,10 @@ func (c *CustomHyperlink) Refresh() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *CustomHyperlink) MinSize() fyne.Size {
|
func (c *CustomHyperlink) MinSize() fyne.Size {
|
||||||
return c.minSize
|
if c.NoTruncate {
|
||||||
|
return fyne.NewSize(c.fullTextWidth, c.l.MinSize().Height)
|
||||||
|
}
|
||||||
|
return fyne.NewSize(0, c.l.MinSize().Height)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *CustomHyperlink) CreateRenderer() fyne.WidgetRenderer {
|
func (c *CustomHyperlink) CreateRenderer() fyne.WidgetRenderer {
|
||||||
|
|||||||
Reference in New Issue
Block a user