MCPcopy Index your code
hub / github.com/g3n/engine / buildImageLabel

Function buildImageLabel

gui/builder_panel.go:134–166  ·  view source on GitHub ↗

buildImageLabel builds a gui object of type: ImageLabel

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

Source from the content-addressed store, hash-verified

132
133// buildImageLabel builds a gui object of type: ImageLabel
134func buildImageLabel(b *Builder, am map[string]interface{}) (IPanel, error) {
135
136 // Builds image label and set common attributes
137 var text string
138 if am[AttribText] != nil {
139 text = am[AttribText].(string)
140 }
141 imglabel := NewImageLabel(text)
142 err := b.SetAttribs(am, imglabel)
143 if err != nil {
144 return nil, err
145 }
146
147 // Sets optional icon(s)
148 if icon := am[AttribIcon]; icon != nil {
149 imglabel.SetIcon(icon.(string))
150 }
151
152 // Sets optional image from file
153 // If path is not absolute join with user supplied image base path
154 if imgf := am[AttribImageFile]; imgf != nil {
155 path := imgf.(string)
156 if !filepath.IsAbs(path) {
157 path = filepath.Join(b.imgpath, path)
158 }
159 err := imglabel.SetImageFromFile(path)
160 if err != nil {
161 return nil, err
162 }
163 }
164
165 return imglabel, nil
166}
167
168// buildButton builds a gui object of type: Button
169func buildButton(b *Builder, am map[string]interface{}) (IPanel, error) {

Callers

nothing calls this directly

Calls 4

SetIconMethod · 0.95
SetImageFromFileMethod · 0.95
NewImageLabelFunction · 0.85
SetAttribsMethod · 0.80

Tested by

no test coverage detected