summaryrefslogtreecommitdiff
path: root/engine/UI/Label.go
diff options
context:
space:
mode:
authorPhyscik <mynameisgennadiy@vk.com>2026-02-01 16:29:13 +0500
committerPhyscik <mynameisgennadiy@vk.com>2026-02-01 16:29:13 +0500
commitb4bb2cc1de2004153a1357e2e6678df7377b42e3 (patch)
tree47d4dd062550582aa5b6eaef9b25dba09798ace7 /engine/UI/Label.go
parent95b7170acdfa73c5842db002ec64f78125fe2f90 (diff)
UI button
Diffstat (limited to 'engine/UI/Label.go')
-rw-r--r--engine/UI/Label.go11
1 files changed, 7 insertions, 4 deletions
diff --git a/engine/UI/Label.go b/engine/UI/Label.go
index a1fdf00..f412eff 100644
--- a/engine/UI/Label.go
+++ b/engine/UI/Label.go
@@ -3,6 +3,7 @@ package ui
import rl "github.com/gen2brain/raylib-go/raylib"
var defaultLabelPadding float32 = 5
+var defaultLabelRoundness float32 = 0.2
// If the text formation formula is applied without it the text is
// overlowing on the right due to rounding errors
@@ -12,6 +13,7 @@ var defaultLabelStyle = &Style{
BacgroundColor: &rl.LightGray,
FontColor: &rl.DarkGray,
Padding: &defaultLabelPadding,
+ Roundness: &defaultLabelRoundness ,
}
type Label struct {
@@ -28,12 +30,12 @@ func (base *Label) Init(*Menu) {
func (base *Label) Destroy() {
}
-func (base *Label) Update() {
-}
-
func (base *Label) Draw(position *rl.Rectangle) {
// rl.TraceLog(rl.LogInfo, "Drawn at %v/%v/%v/%v", position.X, position.Y, position.Width, position.Height)
- rl.DrawRectangleRec(*position, *base.Style.BacgroundColor)
+ rl.DrawRectangleRounded(*position,
+ *base.Style.Roundness,
+ 0, // Assume the segments param is always 0 - it doesn't really matter without a border
+ *base.Style.BacgroundColor)
rl.DrawText(base.Text,
int32(position.X+*base.Style.Padding),
int32(position.Y+*base.Style.Padding),
@@ -45,6 +47,7 @@ func (base *Label) GetOccupationWeight() float32 {
return base.WidthWeight
}
+// Returns the size of the text that will not overflow in the side
func (base *Label) getTextHeight(position *rl.Rectangle) int32 {
var width = position.Width - 2 * *base.Style.Padding
var outp = position.Height - 2 * *base.Style.Padding