buildImageLabel builds a gui object of type: ImageLabel
(b *Builder, am map[string]interface{})
| 132 | |
| 133 | // buildImageLabel builds a gui object of type: ImageLabel |
| 134 | func 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 |
| 169 | func buildButton(b *Builder, am map[string]interface{}) (IPanel, error) { |
nothing calls this directly
no test coverage detected