SetAttribs sets common attributes from the description to the specified panel
(am map[string]interface{}, ipan IPanel)
| 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 { |
| 519 | |
| 520 | panel := ipan.GetPanel() |
| 521 | // Set optional position |
| 522 | if am[AttribPosition] != nil { |
| 523 | va := am[AttribPosition].([]float32) |
| 524 | panel.SetPosition(va[0], va[1]) |
| 525 | } |
| 526 | |
| 527 | // Set optional panel width |
| 528 | if am[AttribWidth] != nil { |
| 529 | panel.SetWidth(am[AttribWidth].(float32)) |
| 530 | } |
| 531 | |
| 532 | // Sets optional panel height |
| 533 | if am[AttribHeight] != nil { |
| 534 | panel.SetHeight(am[AttribHeight].(float32)) |
| 535 | } |
| 536 | |
| 537 | // Set optional margin sizes |
| 538 | if am[AttribMargins] != nil { |
| 539 | panel.SetMarginsFrom(am[AttribMargins].(*RectBounds)) |
| 540 | } |
| 541 | |
| 542 | // Set optional border sizes |
| 543 | if am[AttribBorders] != nil { |
| 544 | panel.SetBordersFrom(am[AttribBorders].(*RectBounds)) |
| 545 | } |
| 546 | |
| 547 | // Set optional border color |
| 548 | if am[AttribBorderColor] != nil { |
| 549 | panel.SetBordersColor4(am[AttribBorderColor].(*math32.Color4)) |
| 550 | } |
| 551 | |
| 552 | // Set optional paddings sizes |
| 553 | if am[AttribPaddings] != nil { |
| 554 | panel.SetPaddingsFrom(am[AttribPaddings].(*RectBounds)) |
| 555 | } |
| 556 | |
| 557 | // Set optional panel color |
| 558 | if am[AttribColor] != nil { |
| 559 | panel.SetColor4(am[AttribColor].(*math32.Color4)) |
| 560 | } |
| 561 | |
| 562 | if am[AttribName] != nil { |
| 563 | panel.SetName(am[AttribName].(string)) |
| 564 | } |
| 565 | |
| 566 | if am[AttribVisible] != nil { |
| 567 | panel.SetVisible(am[AttribVisible].(bool)) |
| 568 | } |
| 569 | |
| 570 | if am[AttribEnabled] != nil { |
| 571 | panel.SetEnabled(am[AttribEnabled].(bool)) |
| 572 | } |
| 573 | |
| 574 | if am[AttribRender] != nil { |
| 575 | panel.SetRenderable(am[AttribRender].(bool)) |
no test coverage detected