Parcourir la source

gui builder dev...

leonsal il y a 8 ans
Parent
commit
223ba0b95a
3 fichiers modifiés avec 23 ajouts et 14 suppressions
  1. 1 1
      gui/builder.go
  2. 6 6
      gui/style_light.go
  3. 16 7
      math32/color4.go

+ 1 - 1
gui/builder.go

@@ -47,7 +47,7 @@ type descLayoutParams struct {
 	Edge    string   // Dock layout edge: top,right,bottom,left,center
 }
 
-// descPanel describes all panel types
+// descPanel describes all panel attributes
 type descPanel struct {
 	Type         string            // Gui object type: Panel, Label, Edit, etc ...
 	Name         string            // Optional name for identification

+ 6 - 6
gui/style_light.go

@@ -27,8 +27,8 @@ func NewLightStyle() *Style {
 	font.SetLineSpacing(1.0)
 	font.SetSize(14)
 	font.SetDPI(72)
-	font.SetFgColor4(&math32.Color4{0, 0, 0, 1})
-	font.SetBgColor4(&math32.Color4{1, 1, 1, 0})
+	font.SetFgColor4(math32.NewColor4("black"))
+	font.SetBgColor4(math32.NewColor4("black", 0))
 	s.Font = font
 
 	// Creates icon font
@@ -40,13 +40,13 @@ func NewLightStyle() *Style {
 	fontIcon.SetLineSpacing(1.0)
 	fontIcon.SetSize(14)
 	fontIcon.SetDPI(72)
-	fontIcon.SetFgColor4(&math32.Color4{0, 0, 0, 1})
-	fontIcon.SetBgColor4(&math32.Color4{1, 1, 1, 1})
+	fontIcon.SetFgColor4(math32.NewColor4("black"))
+	fontIcon.SetBgColor4(math32.NewColor4("white", 0))
 	s.FontIcon = fontIcon
 
 	borderSizes := BorderSizes{1, 1, 1, 1}
-	borderColor := math32.Color4{0, 0, 0, 1}
-	borderColorDis := math32.Color4{0.4, 0.4, 0.4, 1}
+	borderColor := math32.Color4Name("DimGray")
+	borderColorDis := math32.Color4Name("LightGray")
 
 	bgColor := math32.Color{0.85, 0.85, 0.85}
 	bgColor4 := math32.Color4{0, 0, 0, 0}

+ 16 - 7
math32/color4.go

@@ -17,23 +17,31 @@ type Color4 struct {
 
 // NewColor4 creates and returns a pointer to a new Color4
 // with the specified standard web color name (case insensitive)
-// and specified alpha channel value.
+// and an optional alpha channel value.
 // Returns nil if the specified color name not found
-func NewColor4(name string, alpha float32) *Color4 {
+func NewColor4(name string, alpha ...float32) *Color4 {
 
 	c, ok := mapColorNames[strings.ToLower(name)]
 	if !ok {
 		return nil
 	}
-	return &Color4{c.R, c.G, c.B, alpha}
+	a := float32(1)
+	if len(alpha) > 0 {
+		a = alpha[0]
+	}
+	return &Color4{c.R, c.G, c.B, a}
 }
 
 // Color4Name returns a Color4 with the specified standard web color name
-// and specified alpha channel.
-func Color4Name(name string, alpha float32) Color4 {
+// and an optional alpha channel value.
+func Color4Name(name string, alpha ...float32) Color4 {
 
-	c := mapColorNames[name]
-	return Color4{c.R, c.G, c.B, alpha}
+	c := mapColorNames[strings.ToLower(name)]
+	a := float32(1)
+	if len(alpha) > 0 {
+		a = alpha[0]
+	}
+	return Color4{c.R, c.G, c.B, a}
 }
 
 // Set sets this color individual R,G,B,A components
@@ -79,6 +87,7 @@ func (c *Color4) MultiplyScalar(v float32) *Color4 {
 	c.R *= v
 	c.G *= v
 	c.B *= v
+	c.A *= v
 	return c
 }