This commit is contained in:
Konstantin8105 2022-11-23 12:35:50 +03:00
parent 7a467d5aae
commit f19f61b778
19 changed files with 1202 additions and 37 deletions

21
raygui/label.go Normal file
View file

@ -0,0 +1,21 @@
package raygui
import rl "github.com/gen2brain/raylib-go/raylib"
// Label - Label element, show text
func Label(bounds rl.Rectangle, text string) {
LabelEx(bounds, text, rl.GetColor(uint(style[LabelTextColor])), rl.NewColor(0, 0, 0, 0), rl.NewColor(0, 0, 0, 0))
}
// LabelEx - Label element extended, configurable colors
func LabelEx(bounds rl.Rectangle, text string, textColor, border, inner rl.Color) {
textHeight := GetStyle32(GlobalTextFontsize)
textWidth := rl.MeasureText(text, textHeight)
ConstrainRectangle(&bounds, textWidth, textWidth+GetStyle32(LabelTextPadding), textHeight, textHeight+GetStyle32(LabelTextPadding)/2)
// Draw control
b := bounds.ToInt32()
DrawBorderedRectangle(b, GetStyle32(LabelBorderWidth), border, inner)
rl.DrawText(text, b.X+((b.Width/2)-(textWidth/2)), b.Y+((b.Height/2)-(textHeight/2)), textHeight, textColor)
}