From a8ec3968d9a942ee8daf2aa8cf8703a80ddfaddc Mon Sep 17 00:00:00 2001 From: sewn Date: Mon, 2 Oct 2023 18:15:02 +0300 Subject: [PATCH] widget/material: allow changing height & radius of progressbar Signed-off-by: sewn --- widget/material/progressbar.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/widget/material/progressbar.go b/widget/material/progressbar.go index d13978a4..2ee9a416 100644 --- a/widget/material/progressbar.go +++ b/widget/material/progressbar.go @@ -15,6 +15,8 @@ import ( type ProgressBarStyle struct { Color color.NRGBA + Height unit.Dp + Radius unit.Dp TrackColor color.NRGBA Progress float32 } @@ -22,6 +24,8 @@ type ProgressBarStyle struct { func ProgressBar(th *Theme, progress float32) ProgressBarStyle { return ProgressBarStyle{ Progress: progress, + Height: unit.Dp(4), + Radius: unit.Dp(2), Color: th.Palette.ContrastBg, TrackColor: f32color.MulAlpha(th.Palette.Fg, 0x88), } @@ -29,10 +33,8 @@ func ProgressBar(th *Theme, progress float32) ProgressBarStyle { func (p ProgressBarStyle) Layout(gtx layout.Context) layout.Dimensions { shader := func(width int, color color.NRGBA) layout.Dimensions { - const maxHeight = unit.Dp(4) - rr := gtx.Dp(2) - - d := image.Point{X: width, Y: gtx.Dp(maxHeight)} + d := image.Point{X: width, Y: gtx.Dp(p.Height)} + rr := gtx.Dp(p.Radius) defer clip.UniformRRect(image.Rectangle{Max: image.Pt(width, d.Y)}, rr).Push(gtx.Ops).Pop() paint.ColorOp{Color: color}.Add(gtx.Ops)