blob: f308fba413beabc3c1af1e0f09d708dab4b7fff1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
package ui
import (
rl "github.com/gen2brain/raylib-go/raylib"
)
// Arguments that UI elements use to render
type Style struct {
BacgroundColor *rl.Color
FontColor *rl.Color
Padding *float32
// Used in the drawing rectangles. Works like border-radius
Roundness *float32
}
// Fills up not specifiend elements with default ones
func (base *Style) FillMissing(defaultStyle *Style) {
if base.BacgroundColor == nil {
base.BacgroundColor = defaultStyle.BacgroundColor
}
if base.Padding == nil {
base.Padding = defaultStyle.Padding
}
if base.FontColor == nil {
base.FontColor = defaultStyle.FontColor
}
if base.Roundness == nil {
base.Roundness = defaultStyle.Roundness
}
}
// Ensures that the provided style is not nil and fills in gaps with default style
func InitStyle(provided *Style, defaultStyle *Style) *Style {
if provided == nil {
return defaultStyle
}
provided.FillMissing(defaultStyle)
return provided
}
|