(labelText string, rect, iconSrcRect *sdl.FRect, worldSpace bool, pressedFunc func())
| 769 | } |
| 770 | |
| 771 | func NewButton(labelText string, rect, iconSrcRect *sdl.FRect, worldSpace bool, pressedFunc func()) *Button { |
| 772 | |
| 773 | button := &Button{ |
| 774 | Label: NewLabel(labelText, rect, worldSpace, AlignCenter), |
| 775 | IconSrc: iconSrcRect, |
| 776 | OnPressed: pressedFunc, |
| 777 | WorldSpace: worldSpace, |
| 778 | FadeOnInactive: true, |
| 779 | Highlighter: NewHighlighter(nil, worldSpace), |
| 780 | BackgroundColor: ColorTransparent, |
| 781 | TintByFontColor: true, |
| 782 | } |
| 783 | |
| 784 | button.Highlighter.HighlightMode = HighlightUnderline |
| 785 | |
| 786 | if rect == nil { |
| 787 | button.Label.RecreateTexture() |
| 788 | rect = button.Label.Rectangle() |
| 789 | |
| 790 | if iconSrcRect != nil && labelText != "" { |
| 791 | rect.W += float32(iconSrcRect.W) |
| 792 | rect.X -= float32(iconSrcRect.W) / 2 |
| 793 | } |
| 794 | |
| 795 | } |
| 796 | |
| 797 | button.SetRectangle(rect) |
| 798 | |
| 799 | return button |
| 800 | } |
| 801 | |
| 802 | func (button *Button) Update() { |
| 803 |
no test coverage detected