diff --git a/raygui/progressbar.go b/raygui/progressbar.go index 4d6164c..a9410b8 100644 --- a/raygui/progressbar.go +++ b/raygui/progressbar.go @@ -11,11 +11,13 @@ func ProgressBar(bounds rl.Rectangle, value float32) { value = 0.0 } - progressBar := rl.RectangleInt32{b.X + int32(style[ProgressbarBorderWidth]), b.Y + int32(style[ProgressbarBorderWidth]), b.Width - (int32(style[ProgressbarBorderWidth]) * 2), b.Height - (int32(style[ProgressbarBorderWidth]) * 2)} - progressValue := rl.RectangleInt32{b.X + int32(style[ProgressbarBorderWidth]), b.Y + int32(style[ProgressbarBorderWidth]), int32(value * float32(b.Width-int32(style[ProgressbarBorderWidth])*2)), b.Height - (int32(style[ProgressbarBorderWidth]) * 2)} + borderWidth := GetStyle32(ProgressbarBorderWidth) + progressBar := InsetRectangle(b, borderWidth) // backing rectangle + progressWidth := int32(value * float32(progressBar.Width)) // how much should be replaced with progress + progressValue := rl.RectangleInt32{progressBar.X, progressBar.Y, progressWidth, progressBar.Height} // Draw control - rl.DrawRectangle(b.X, b.Y, b.Width, b.Height, rl.GetColor(int32(style[ProgressbarBorderColor]))) - rl.DrawRectangle(progressBar.X, progressBar.Y, progressBar.Width, progressBar.Height, rl.GetColor(int32(style[ProgressbarInsideColor]))) - rl.DrawRectangle(progressValue.X, progressValue.Y, progressValue.Width, progressValue.Height, rl.GetColor(int32(style[ProgressbarProgressColor]))) + rl.DrawRectangle(b.X, b.Y, b.Width, b.Height, GetStyleColor(ProgressbarBorderColor)) + rl.DrawRectangle(progressBar.X, progressBar.Y, progressBar.Width, progressBar.Height, GetStyleColor(ProgressbarInsideColor)) + rl.DrawRectangle(progressValue.X, progressValue.Y, progressValue.Width, progressValue.Height, GetStyleColor(ProgressbarProgressColor)) }