Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix progressbar text having the wrong color sometimes #4186

Merged
merged 2 commits into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions widget/progressbar.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ func (p *progressRenderer) MinSize() fyne.Size {
tsize = fyne.MeasureText("100%", p.label.TextSize, p.label.TextStyle)
}

return fyne.NewSize(tsize.Width+theme.InnerPadding()*2, tsize.Height+theme.InnerPadding()*2)
padding := theme.InnerPadding() * 2
return fyne.NewSize(tsize.Width+padding, tsize.Height+padding)
}

func (p *progressRenderer) updateBar() {
Expand Down Expand Up @@ -76,6 +77,7 @@ func (p *progressRenderer) Refresh() {
p.updateBar()
p.background.Refresh()
p.bar.Refresh()
p.label.Refresh()
canvas.Refresh(p.progress.super())
}

Expand Down Expand Up @@ -127,7 +129,7 @@ func (p *ProgressBar) CreateRenderer() fyne.WidgetRenderer {
background.CornerRadius = theme.InputRadiusSize()
bar := canvas.NewRectangle(theme.PrimaryColor())
bar.CornerRadius = theme.InputRadiusSize()
label := canvas.NewText("0%", theme.ForegroundColor())
label := canvas.NewText("0%", theme.BackgroundColor())
label.Alignment = fyne.TextAlignCenter
return &progressRenderer{widget.NewBaseRenderer([]fyne.CanvasObject{background, bar, label}), background, bar, label, p}
}
Expand Down
5 changes: 5 additions & 0 deletions widget/progressbar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ func TestProgressRenderer_ApplyTheme(t *testing.T) {
bar := NewProgressBar()
render := test.WidgetRenderer(bar).(*progressRenderer)

oldLabelColor := render.label.Color
render.Refresh()
newLabelColor := render.label.Color
assert.Equal(t, oldLabelColor, newLabelColor)

textSize := render.label.TextSize
customTextSize := textSize
test.WithTestTheme(t, func() {
Expand Down