()
| 843 | } |
| 844 | |
| 845 | func (button *Button) Draw() { |
| 846 | |
| 847 | buttonRect := button.Rectangle() |
| 848 | |
| 849 | if button.BackgroundColor[3] > 0 { |
| 850 | // gfx.RoundedRectangleColor(globals.Renderer, int32(buttonRect.X), int32(buttonRect.Y), int32(buttonRect.X)+int32(buttonRect.W), int32(buttonRect.Y)+int32(buttonRect.H), 4, button.BackgroundColor.SDLColor()) |
| 851 | globals.Renderer.SetDrawColor(button.BackgroundColor.RGBA()) |
| 852 | globals.Renderer.RenderFillRect(buttonRect) |
| 853 | } |
| 854 | |
| 855 | if len(button.Label.Text) > 0 { |
| 856 | button.Label.Draw() |
| 857 | } |
| 858 | |
| 859 | mousePos := globals.Mouse.Position() |
| 860 | |
| 861 | if button.WorldSpace { |
| 862 | mousePos = globals.Mouse.WorldPosition() |
| 863 | } |
| 864 | |
| 865 | button.Highlighter.Highlighting = (mousePos.Inside(buttonRect) || !button.FadeOnInactive) && !button.Disabled |
| 866 | |
| 867 | button.Highlighter.SetRect(buttonRect) |
| 868 | button.Highlighter.Draw() |
| 869 | |
| 870 | color := getThemeColor(GUIFontColor) |
| 871 | |
| 872 | if button.IconSrc != nil { |
| 873 | |
| 874 | guiTexture := globals.GUITexture.Texture |
| 875 | |
| 876 | guiTexture.SetAlphaMod(uint8(button.Label.Alpha * 255)) |
| 877 | if button.TintByFontColor { |
| 878 | guiTexture.SetColorMod(color.RGB()) |
| 879 | } else { |
| 880 | guiTexture.SetColorMod(255, 255, 255) |
| 881 | } |
| 882 | guiTexture.SetBlendMode(sdl.BLENDMODE_BLEND) |
| 883 | tx := float32(0) |
| 884 | if button.Label.RendererResult != nil { |
| 885 | tx = button.Label.RendererResult.TextSize.X |
| 886 | } |
| 887 | dst := &sdl.FRect{buttonRect.X + (buttonRect.W / 2) - (tx / 2) - float32(button.IconSrc.W), buttonRect.Y, float32(button.IconSrc.W), float32(button.IconSrc.H)} |
| 888 | // textHalfWidth := button.Label.RendererResult.TextSize.X / 2 |
| 889 | // dst := &sdl.FRect{buttonRect.X + (buttonRect.W / 2) - float32(button.IconSrc.W) - textHalfWidth, buttonRect.Y, float32(button.IconSrc.W), float32(button.IconSrc.H)} |
| 890 | |
| 891 | if button.WorldSpace { |
| 892 | dst = globals.Project.Camera.TranslateRect(dst) |
| 893 | } |
| 894 | |
| 895 | globals.Renderer.RenderTexture(guiTexture, button.IconSrc, dst) |
| 896 | |
| 897 | } |
| 898 | |
| 899 | if globals.DebugMode == DebugModeUI { |
| 900 | dst := &sdl.FRect{buttonRect.X, buttonRect.Y, buttonRect.W, buttonRect.H} |
| 901 | if button.WorldSpace { |
| 902 | dst = globals.Project.Camera.TranslateRect(dst) |
nothing calls this directly
no test coverage detected