MCPcopy
hub / github.com/g3n/engine / buildLabel

Function buildLabel

gui/builder_panel.go:88–131  ·  view source on GitHub ↗

buildLabel builds a gui object of type Label

(b *Builder, am map[string]interface{})

Source from the content-addressed store, hash-verified

86
87// buildLabel builds a gui object of type Label
88func 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
134func buildImageLabel(b *Builder, am map[string]interface{}) (IPanel, error) {

Callers

nothing calls this directly

Calls 8

SetBgColor4Method · 0.95
SetColor4Method · 0.95
SetFontSizeMethod · 0.95
SetFontDPIMethod · 0.95
SetLineSpacingMethod · 0.95
NewIconFunction · 0.85
NewLabelFunction · 0.85
SetAttribsMethod · 0.80

Tested by

no test coverage detected