ProgressBar cleanup

This commit is contained in:
Oliver 'kfsone' Smith 2021-02-24 13:23:09 -08:00
parent a406f4bf03
commit 113982db71

View file

@ -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))
}