Use ConstrainRectangle in label.go
This commit is contained in:
parent
01408701f9
commit
4f047b24de
1 changed files with 2 additions and 7 deletions
|
@ -12,15 +12,10 @@ func LabelEx(bounds rl.Rectangle, text string, textColor, border, inner rl.Color
|
|||
textHeight := GetStyle32(GlobalTextFontsize)
|
||||
textWidth := rl.MeasureText(text, textHeight)
|
||||
|
||||
b := bounds.ToInt32()
|
||||
if b.Width < textWidth {
|
||||
b.Width = textWidth + GetStyle32(LabelTextPadding)
|
||||
}
|
||||
if b.Height < textHeight {
|
||||
b.Height = textHeight + GetStyle32(LabelTextPadding)/2
|
||||
}
|
||||
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)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue