buildLabel builds a gui object of type Label
(b *Builder, am map[string]interface{})
| 86 | |
| 87 | // buildLabel builds a gui object of type Label |
| 88 | func buildLabel(b *Builder, am map[string]interface{}) (IPanel, error) { |
| 89 | |
| 90 | var label *Label |
| 91 | if am[AttribIcon] != nil { |
| 92 | label = NewIcon(am[AttribIcon].(string)) |
| 93 | } else if am[AttribText] != nil { |
| 94 | label = NewLabel(am[AttribText].(string)) |
| 95 | } else { |
| 96 | label = NewLabel("") |
| 97 | } |
| 98 | |
| 99 | // Sets common attributes |
| 100 | err := b.SetAttribs(am, label) |
| 101 | if err != nil { |
| 102 | return nil, err |
| 103 | } |
| 104 | |
| 105 | // Set optional background color |
| 106 | if bgc := am[AttribBgColor]; bgc != nil { |
| 107 | label.SetBgColor4(bgc.(*math32.Color4)) |
| 108 | } |
| 109 | |
| 110 | // Set optional font color |
| 111 | if fc := am[AttribFontColor]; fc != nil { |
| 112 | label.SetColor4(fc.(*math32.Color4)) |
| 113 | } |
| 114 | |
| 115 | // Sets optional font size |
| 116 | if fs := am[AttribFontSize]; fs != nil { |
| 117 | label.SetFontSize(float64(fs.(float32))) |
| 118 | } |
| 119 | |
| 120 | // Sets optional font dpi |
| 121 | if fdpi := am[AttribFontDPI]; fdpi != nil { |
| 122 | label.SetFontDPI(float64(fdpi.(float32))) |
| 123 | } |
| 124 | |
| 125 | // Sets optional line spacing |
| 126 | if ls := am[AttribLineSpacing]; ls != nil { |
| 127 | label.SetLineSpacing(float64(ls.(float32))) |
| 128 | } |
| 129 | |
| 130 | return label, nil |
| 131 | } |
| 132 | |
| 133 | // buildImageLabel builds a gui object of type: ImageLabel |
| 134 | func buildImageLabel(b *Builder, am map[string]interface{}) (IPanel, error) { |
nothing calls this directly
no test coverage detected