build builds the gui object from the specified description. All its children are also built recursively Returns the built object or an error
(am map[string]interface{}, iparent IPanel)
| 488 | // All its children are also built recursively |
| 489 | // Returns the built object or an error |
| 490 | func (b *Builder) build(am map[string]interface{}, iparent IPanel) (IPanel, error) { |
| 491 | |
| 492 | // Get panel type |
| 493 | itype := am[AttribType] |
| 494 | if itype == nil { |
| 495 | return nil, fmt.Errorf("Type not specified") |
| 496 | } |
| 497 | typename := itype.(string) |
| 498 | |
| 499 | // Get builder function for this type name |
| 500 | builder := b.builders[typename] |
| 501 | if builder == nil { |
| 502 | return nil, fmt.Errorf("Invalid type:%v", typename) |
| 503 | } |
| 504 | |
| 505 | // Builds panel |
| 506 | pan, err := builder(b, am) |
| 507 | if err != nil { |
| 508 | return nil, err |
| 509 | } |
| 510 | // Adds built panel to parent |
| 511 | if iparent != nil { |
| 512 | iparent.GetPanel().Add(pan) |
| 513 | } |
| 514 | return pan, nil |
| 515 | } |
| 516 | |
| 517 | // SetAttribs sets common attributes from the description to the specified panel |
| 518 | func (b *Builder) SetAttribs(am map[string]interface{}, ipan IPanel) error { |
no test coverage detected