Label cleanup
This commit is contained in:
parent
da00f22f9c
commit
a406f4bf03
1 changed files with 5 additions and 6 deletions
|
@ -9,20 +9,19 @@ func Label(bounds rl.Rectangle, text string) {
|
||||||
|
|
||||||
// LabelEx - Label element extended, configurable colors
|
// LabelEx - Label element extended, configurable colors
|
||||||
func LabelEx(bounds rl.Rectangle, text string, textColor, border, inner rl.Color) {
|
func LabelEx(bounds rl.Rectangle, text string, textColor, border, inner rl.Color) {
|
||||||
b := bounds.ToInt32()
|
|
||||||
// Update control
|
// Update control
|
||||||
textHeight := int32(style[GlobalTextFontsize])
|
textHeight := GetStyle32(GlobalTextFontsize)
|
||||||
textWidth := rl.MeasureText(text, textHeight)
|
textWidth := rl.MeasureText(text, textHeight)
|
||||||
|
|
||||||
|
b := bounds.ToInt32()
|
||||||
if b.Width < textWidth {
|
if b.Width < textWidth {
|
||||||
b.Width = textWidth + int32(style[LabelTextPadding])
|
b.Width = textWidth + GetStyle32(LabelTextPadding)
|
||||||
}
|
}
|
||||||
if b.Height < textHeight {
|
if b.Height < textHeight {
|
||||||
b.Height = textHeight + int32(style[LabelTextPadding])/2
|
b.Height = textHeight + GetStyle32(LabelTextPadding)/2
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw control
|
// Draw control
|
||||||
rl.DrawRectangle(b.X, b.Y, b.Width, b.Height, border)
|
DrawBorderedRectangle(b, GetStyle32(LabelBorderWidth), border, inner)
|
||||||
rl.DrawRectangle(b.X+int32(style[LabelBorderWidth]), b.Y+int32(style[LabelBorderWidth]), b.Width-(2*int32(style[LabelBorderWidth])), b.Height-(2*int32(style[LabelBorderWidth])), inner)
|
|
||||||
rl.DrawText(text, b.X+((b.Width/2)-(textWidth/2)), b.Y+((b.Height/2)-(textHeight/2)), textHeight, textColor)
|
rl.DrawText(text, b.X+((b.Width/2)-(textWidth/2)), b.Y+((b.Height/2)-(textHeight/2)), textHeight, textColor)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue