summaryrefslogtreecommitdiff
path: root/engine/UI/Label.go
diff options
context:
space:
mode:
Diffstat (limited to 'engine/UI/Label.go')
-rw-r--r--engine/UI/Label.go24
1 files changed, 20 insertions, 4 deletions
diff --git a/engine/UI/Label.go b/engine/UI/Label.go
index 3a3528f..53c6e96 100644
--- a/engine/UI/Label.go
+++ b/engine/UI/Label.go
@@ -1,8 +1,15 @@
package ui
-import rl "github.com/gen2brain/raylib-go/raylib"
+import (
+ "encoding/json"
+ "fmt"
-var defaultLabelPadding float32 = 5
+ rl "github.com/gen2brain/raylib-go/raylib"
+)
+
+const LabelTypeName string = "label"
+
+var defaultLabelPadding float32 = 0.1
var defaultLabelRoundness float32 = 0.2
// If the text formation formula is applied without it the text is
@@ -13,7 +20,7 @@ var defaultLabelStyle = &Style{
BacgroundColor: &rl.LightGray,
FontColor: &rl.DarkGray,
Padding: &defaultLabelPadding,
- Roundness: &defaultLabelRoundness ,
+ Roundness: &defaultLabelRoundness,
}
type TextAlignment uint8
@@ -23,12 +30,13 @@ const (
Start
)
+// A UI element containing a text field
type Label struct {
WidthWeight float32
Text string
Alignment TextAlignment
- Style Style
+ Style Style `json:"-"`
}
func (base *Label) Init(*Menu) {
@@ -73,3 +81,11 @@ func (base *Label) getTextHeight(position *rl.Rectangle) int32 {
}
return int32(outp)
}
+
+func (base Label) String() string {
+ var outp, jsonErr = json.Marshal(base)
+ if jsonErr != nil {
+ return fmt.Sprintf("Failed to parse settings: %s", jsonErr.Error())
+ }
+ return string(outp)
+}