Documentation ¶
Index ¶
- Constants
- Variables
- func BBox(r1 sdl.Rect, r2 sdl.Rect) bool
- func Cleanup()
- func ClearScreen()
- func ColorToRGBA(c sdl.Color) (uint8, uint8, uint8, uint8)
- func DrawFilledRect(rect *sdl.Rect)
- func DrawImage(img *Image, x int32, y int32)
- func DrawLineRect(rect *sdl.Rect)
- func GetTextSize(s string) (int, int)
- func HexToColor(hex string) sdl.Color
- func Init(app *App) error
- func InitFonts() error
- func KeyboardEvent(cs []*Container, keyType uint32, key sdl.Keysym)
- func LoadFont(fontStyle string, path string, fontSize int32) error
- func LoadFontRanges(fontStyle string, r []int32) error
- func MouseButtonEvent(cs []*Container, event *sdl.MouseButtonEvent)
- func Print(s string, x int32, y int32) error
- func PrintInsideRect(s string, x int32, y int32, rect *sdl.Rect) error
- func RGBAToColor(r uint8, g uint8, b uint8, a uint8) sdl.Color
- func RedrawAllContainers(cs []*Container)
- func RedrawContainer(c *Container)
- func ResetClipRect()
- func SetColor(color sdl.Color)
- func SetFont(fontStyle string, fontSize int32) error
- func UpdateHoverStateForAllContainers(cs []*Container)
- func UpdateMousePos(x int32, y int32)
- type App
- type Container
- func (c *Container) AddElement(e interface{})
- func (c *Container) AlignElementsCenter()
- func (c *Container) Draw()
- func (c *Container) ResetHoverStates()
- func (c *Container) SetAlignment(a uint8)
- func (c *Container) SetBackgroundColor(newColor sdl.Color)
- func (c *Container) SetOutlineColor(newColor sdl.Color)
- type Element
- type Font
- type Image
- type ImgButton
- func (b *ImgButton) Draw()
- func (b *ImgButton) GetPos() (int32, int32)
- func (b *ImgButton) GetSize() (int32, int32)
- func (b *ImgButton) KeyboardEvent(keyType uint32, key sdl.Keysym)
- func (b *ImgButton) MouseButtonEvent(event *sdl.MouseButtonEvent)
- func (b *ImgButton) SetCallback(f func(i *ImgButton))
- func (b *ImgButton) SetHolding(which bool)
- func (b *ImgButton) SetHover(which bool)
- func (b *ImgButton) SetMargin(x int32, y int32)
- func (b *ImgButton) SetPadding(x int32, y int32)
- func (b *ImgButton) SetPos(x int32, y int32)
- func (b *ImgButton) SetSize(w int32, h int32)
- func (b *ImgButton) Trigger()
- type Label
- func (l *Label) Draw()
- func (l *Label) GetPos() (int32, int32)
- func (l *Label) GetSize() (int32, int32)
- func (l *Label) KeyboardEvent(keyType uint32, key sdl.Keysym)
- func (l *Label) MouseButtonEvent(event *sdl.MouseButtonEvent)
- func (l *Label) SetFont(fontStyle string, fontSize int32)
- func (l *Label) SetHover(which bool)
- func (l *Label) SetPos(x int32, y int32)
- func (l *Label) SetSize(w int32, h int32)
- func (l *Label) Trigger()
- type OneLineInput
- func (i *OneLineInput) AddText(t string)
- func (i *OneLineInput) Backspace()
- func (i *OneLineInput) ClearText()
- func (i *OneLineInput) Draw()
- func (i *OneLineInput) GetPos() (int32, int32)
- func (i *OneLineInput) GetSize() (int32, int32)
- func (i *OneLineInput) KeyboardEvent(t uint32, key sdl.Keysym)
- func (i *OneLineInput) MouseButtonEvent(event *sdl.MouseButtonEvent)
- func (i *OneLineInput) MoveCursor(pos int32)
- func (i *OneLineInput) SetActive(which bool)
- func (i *OneLineInput) SetCallback(f func(i *OneLineInput))
- func (i *OneLineInput) SetFont(fontStyle string, fontSize int32)
- func (i *OneLineInput) SetHover(which bool)
- func (i *OneLineInput) SetPos(x int32, y int32)
- func (i *OneLineInput) SetSize(w int32, h int32)
- func (i *OneLineInput) Trigger()
- type TextButton
- func (b *TextButton) Draw()
- func (b *TextButton) GetPos() (int32, int32)
- func (b *TextButton) GetSize() (int32, int32)
- func (b *TextButton) KeyboardEvent(keyType uint32, key sdl.Keysym)
- func (b *TextButton) MouseButtonEvent(event *sdl.MouseButtonEvent)
- func (b *TextButton) SetCallback(f func(i *TextButton))
- func (b *TextButton) SetFont(fontStyle string, fontSize int32)
- func (b *TextButton) SetHolding(which bool)
- func (b *TextButton) SetHover(which bool)
- func (b *TextButton) SetMargin(x int32, y int32)
- func (b *TextButton) SetPadding(x int32, y int32)
- func (b *TextButton) SetPos(x int32, y int32)
- func (b *TextButton) SetSize(w int32, h int32)
- func (b *TextButton) Trigger()
Constants ¶
View Source
const ALIGN_CENTER = 0 // margin, padding and center alignment
View Source
const ALIGN_FREE = 1 // no automated position adjustment
Variables ¶
View Source
var BUTTON_LIGHT = HexToColor("5DA7DB")
View Source
var BUTTON_LIGHTER = HexToColor("81C6E8")
View Source
var BUTTON_PRIMARY = HexToColor("5837D0")
View Source
var BUTTON_SECONDARY = HexToColor("7DE5ED")
View Source
var COLOR_BLACK = RGBAToColor(0, 0, 0, 0)
View Source
var COLOR_BLUE = RGBAToColor(0, 0, 255, 0)
View Source
var COLOR_CLEAR = RGBAToColor(50, 0, 0, 0)
View Source
var COLOR_GREEN = RGBAToColor(0, 255, 0, 0)
View Source
var COLOR_GREY = RGBAToColor(155, 155, 155, 0)
View Source
var COLOR_PRIMARY_DARK = RGBAToColor(27, 47, 51, 0)
View Source
var COLOR_PRIMARY_LIGHT = RGBAToColor(57, 77, 81, 0)
View Source
var COLOR_RED = RGBAToColor(255, 0, 0, 50)
View Source
var COLOR_WHITE = RGBAToColor(255, 255, 255, 0)
View Source
var COLOR_WHITE_ALPHA = RGBAToColor(255, 255, 255, 30)
View Source
var CharsLower = "abcdefghijklmnopqrstuvwxyz`1234567890-=[]\\;',./"
View Source
var CharsTypeable = "ABCDEFGHIJKLMNOPQRSTUVWXYZ`1234567890-=[]\\;',./"
View Source
var CharsUpper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ~!@#$%^&*()_+{}|:\"<>?"
View Source
var Color = COLOR_WHITE // current draw color for many things such as primitives and font text
View Source
var FontSize int32 = 14
View Source
var FontSizeRange = []int32{8, 14, 20, 24, 32, 36, 40, 48, 52}
View Source
var FontStyle = "normal" // can be regular or light
View Source
var Fonts = make(map[string]map[int32]*Font)
View Source
var R *sdl.Renderer
View Source
var S *sdl.Surface
View Source
var THEME_BLUE_50 = HexToColor("0a84ff")
View Source
var THEME_BLUE_60 = HexToColor("0060df")
View Source
var THEME_BLUE_70 = HexToColor("003eaa")
View Source
var THEME_BLUE_80 = HexToColor("16213E")
View Source
var THEME_BLUE_85 = HexToColor("27324F")
View Source
var THEME_BLUE_90 = HexToColor("1A1A2E")
View Source
var W *sdl.Window
Functions ¶
func ClearScreen ¶
func ClearScreen()
func ColorToRGBA ¶
ColorToRGBA returns the correct RGBA values because it's mixed up somehow
func DrawFilledRect ¶
func DrawLineRect ¶
func GetTextSize ¶
func HexToColor ¶
func LoadFontRanges ¶
func MouseButtonEvent ¶
func MouseButtonEvent(cs []*Container, event *sdl.MouseButtonEvent)
func RGBAToColor ¶
RGBAToColor returns the correct sdl.Color because it's mixed up somehow
func RedrawAllContainers ¶
func RedrawAllContainers(cs []*Container)
func RedrawContainer ¶
func RedrawContainer(c *Container)
func ResetClipRect ¶
func ResetClipRect()
func UpdateHoverStateForAllContainers ¶
func UpdateHoverStateForAllContainers(cs []*Container)
func UpdateMousePos ¶
Types ¶
type App ¶
type App struct { Title string ScreenWidth int32 ScreenHeight int32 Containers []*Container Running bool MouseX int32 MouseY int32 BackgroundColor sdl.Color }
var A *App
func (*App) AddContainer ¶
func (*App) SetBackgroundColor ¶
type Container ¶
type Container struct { X int32 Y int32 Width int32 Height int32 BackgroundColor sdl.Color OutlineColor sdl.Color Elements []interface{} ElementOffsetX int32 Alignment uint8 AlignMargin int32 }
func (*Container) AddElement ¶
func (c *Container) AddElement(e interface{})
func (*Container) AlignElementsCenter ¶
func (c *Container) AlignElementsCenter()
func (*Container) ResetHoverStates ¶
func (c *Container) ResetHoverStates()
func (*Container) SetAlignment ¶
func (*Container) SetBackgroundColor ¶
func (*Container) SetOutlineColor ¶
type Element ¶
type Element interface { Draw() Trigger() GetPos() (int32, int32) // get position inside container SetPos(x int32, y int32) // set position inside container GetSize() (int32, int32) // get size of element SetSize(w int32, h int32) // set size of element SetHover(which bool) // sets whether mouse is hovering over an element KeyboardEvent(keyType uint32, key sdl.Keysym) MouseButtonEvent(event *sdl.MouseButtonEvent) }
Element represents all drawable objects. Other libraries call these "widgets"
type Font ¶
func CurrentFont ¶
func CurrentFont() *Font
type ImgButton ¶
type ImgButton struct { X int32 Y int32 Width int32 Height int32 BackgroundColor sdl.Color OutlineColor sdl.Color MarginX int32 MarginY int32 PaddingX int32 PaddingY int32 IsHovering bool IsHolding bool Image *Image Callback func(b *ImgButton) }
func (*ImgButton) MouseButtonEvent ¶
func (b *ImgButton) MouseButtonEvent(event *sdl.MouseButtonEvent)
func (*ImgButton) SetCallback ¶
func (*ImgButton) SetHolding ¶
func (*ImgButton) SetPadding ¶
type Label ¶
type Label struct { Text string X int32 Y int32 Width int32 Height int32 Color sdl.Color IsHovering bool FontStyle string FontSize int32 }
func (*Label) MouseButtonEvent ¶
func (l *Label) MouseButtonEvent(event *sdl.MouseButtonEvent)
type OneLineInput ¶
type OneLineInput struct { X int32 Y int32 Width int32 Height int32 BackgroundColor sdl.Color OutlineColor sdl.Color TextColor sdl.Color HighlightColor sdl.Color PlaceholderColor sdl.Color CursorPos int32 CursorX int32 MaxChars int32 Text string Placeholder string HighlightStartPos int32 HighlightEndPos int32 MarginX int32 MarginY int32 PaddingX int32 PaddingY int32 Active bool IsHovering bool IsHoldingShift bool Callback func(i *OneLineInput) Font *Font FontStyle string FontSize int32 }
func NewOneLineInput ¶
func (*OneLineInput) AddText ¶
func (i *OneLineInput) AddText(t string)
func (*OneLineInput) Backspace ¶
func (i *OneLineInput) Backspace()
func (*OneLineInput) ClearText ¶
func (i *OneLineInput) ClearText()
func (*OneLineInput) Draw ¶
func (i *OneLineInput) Draw()
func (*OneLineInput) GetPos ¶
func (i *OneLineInput) GetPos() (int32, int32)
func (*OneLineInput) GetSize ¶
func (i *OneLineInput) GetSize() (int32, int32)
func (*OneLineInput) KeyboardEvent ¶
func (i *OneLineInput) KeyboardEvent(t uint32, key sdl.Keysym)
func (*OneLineInput) MouseButtonEvent ¶
func (i *OneLineInput) MouseButtonEvent(event *sdl.MouseButtonEvent)
func (*OneLineInput) MoveCursor ¶
func (i *OneLineInput) MoveCursor(pos int32)
func (*OneLineInput) SetActive ¶
func (i *OneLineInput) SetActive(which bool)
func (*OneLineInput) SetCallback ¶
func (i *OneLineInput) SetCallback(f func(i *OneLineInput))
func (*OneLineInput) SetFont ¶
func (i *OneLineInput) SetFont(fontStyle string, fontSize int32)
func (*OneLineInput) SetHover ¶
func (i *OneLineInput) SetHover(which bool)
func (*OneLineInput) SetPos ¶
func (i *OneLineInput) SetPos(x int32, y int32)
func (*OneLineInput) SetSize ¶
func (i *OneLineInput) SetSize(w int32, h int32)
func (*OneLineInput) Trigger ¶
func (i *OneLineInput) Trigger()
type TextButton ¶
type TextButton struct { X int32 Y int32 Width int32 Height int32 BackgroundColor sdl.Color OutlineColor sdl.Color MarginX int32 MarginY int32 PaddingX int32 PaddingY int32 Text string IsHovering bool IsHolding bool Callback func(i *TextButton) FontStyle string FontSize int32 }
func NewTextButton ¶
func NewTextButton(t string, x int32, y int32) *TextButton
func (*TextButton) Draw ¶
func (b *TextButton) Draw()
func (*TextButton) GetPos ¶
func (b *TextButton) GetPos() (int32, int32)
func (*TextButton) GetSize ¶
func (b *TextButton) GetSize() (int32, int32)
func (*TextButton) KeyboardEvent ¶
func (b *TextButton) KeyboardEvent(keyType uint32, key sdl.Keysym)
func (*TextButton) MouseButtonEvent ¶
func (b *TextButton) MouseButtonEvent(event *sdl.MouseButtonEvent)
func (*TextButton) SetCallback ¶
func (b *TextButton) SetCallback(f func(i *TextButton))
func (*TextButton) SetFont ¶
func (b *TextButton) SetFont(fontStyle string, fontSize int32)
func (*TextButton) SetHolding ¶
func (b *TextButton) SetHolding(which bool)
func (*TextButton) SetHover ¶
func (b *TextButton) SetHover(which bool)
func (*TextButton) SetMargin ¶
func (b *TextButton) SetMargin(x int32, y int32)
func (*TextButton) SetPadding ¶
func (b *TextButton) SetPadding(x int32, y int32)
func (*TextButton) SetPos ¶
func (b *TextButton) SetPos(x int32, y int32)
func (*TextButton) SetSize ¶
func (b *TextButton) SetSize(w int32, h int32)
func (*TextButton) Trigger ¶
func (b *TextButton) Trigger()
Source Files ¶
Click to show internal directories.
Click to hide internal directories.