Documentation ¶
Index ¶
- Constants
- Variables
- func DrawParentAndChildren(r *sdl.Renderer, c Component) error
- func PassKeyEventToChildren(event *sdl.KeyboardEvent, children []Component) bool
- func PassMouseButtonEventToChildren(event *sdl.MouseButtonEvent, children []Component) bool
- func RegisterPage(p Page)
- func SetupSDL() error
- func SwitchPage(newPage string)
- func SwitchPageWithData(newPage string, data interface{})
- type BaseComponent
- func (c *BaseComponent) AddChild(comp Component)
- func (c *BaseComponent) BaseMouseButtonEvent(event *sdl.MouseButtonEvent) bool
- func (c *BaseComponent) Draw(r *sdl.Renderer) error
- func (c *BaseComponent) DrawComponent(r *sdl.Renderer) error
- func (c BaseComponent) GetChildren() []Component
- func (c *BaseComponent) Initialize()
- func (c BaseComponent) IsPointInComponent(x, y int32) bool
- func (c BaseComponent) IsVisible() bool
- func (c *BaseComponent) KeyEvent(event *sdl.KeyboardEvent) bool
- func (c *BaseComponent) MouseButtonEvent(event *sdl.MouseButtonEvent) bool
- func (c BaseComponent) Position() (int32, int32)
- func (c *BaseComponent) RemoveChild(index int)
- func (c *BaseComponent) SetPosition(x, y int32)
- func (c *BaseComponent) SetSize(width, height int32)
- func (c *BaseComponent) SetVisible(visible bool)
- func (c BaseComponent) Size() (int32, int32)
- type BaseGame
- type BasePage
- type ButtonComponent
- type Component
- type LabelComponent
- type LabelConfig
- type LabelTextFunc
- type OnActionFunc
- type Page
- type RectangleComponent
- type Window
Constants ¶
View Source
const ( JUSTIFY_LEFT = iota JUSTIFY_CENTER JUSTIFY_RIGHT )
Variables ¶
View Source
var ActivePageWaitGroup sync.WaitGroup
View Source
var Scaling float32 = 1.0
Functions ¶
func PassKeyEventToChildren ¶
func PassKeyEventToChildren(event *sdl.KeyboardEvent, children []Component) bool
func PassMouseButtonEventToChildren ¶
func PassMouseButtonEventToChildren(event *sdl.MouseButtonEvent, children []Component) bool
func RegisterPage ¶
func RegisterPage(p Page)
func SwitchPage ¶
func SwitchPage(newPage string)
func SwitchPageWithData ¶
func SwitchPageWithData(newPage string, data interface{})
Types ¶
type BaseComponent ¶
type BaseComponent struct { X int32 Y int32 Width int32 Height int32 Children []Component Visible bool }
func (*BaseComponent) AddChild ¶
func (c *BaseComponent) AddChild(comp Component)
func (*BaseComponent) BaseMouseButtonEvent ¶
func (c *BaseComponent) BaseMouseButtonEvent(event *sdl.MouseButtonEvent) bool
func (*BaseComponent) DrawComponent ¶
func (c *BaseComponent) DrawComponent(r *sdl.Renderer) error
func (BaseComponent) GetChildren ¶
func (c BaseComponent) GetChildren() []Component
func (*BaseComponent) Initialize ¶
func (c *BaseComponent) Initialize()
func (BaseComponent) IsPointInComponent ¶
func (c BaseComponent) IsPointInComponent(x, y int32) bool
func (BaseComponent) IsVisible ¶
func (c BaseComponent) IsVisible() bool
func (*BaseComponent) KeyEvent ¶
func (c *BaseComponent) KeyEvent(event *sdl.KeyboardEvent) bool
func (*BaseComponent) MouseButtonEvent ¶
func (c *BaseComponent) MouseButtonEvent(event *sdl.MouseButtonEvent) bool
func (BaseComponent) Position ¶
func (c BaseComponent) Position() (int32, int32)
func (*BaseComponent) RemoveChild ¶
func (c *BaseComponent) RemoveChild(index int)
func (*BaseComponent) SetPosition ¶
func (c *BaseComponent) SetPosition(x, y int32)
func (*BaseComponent) SetSize ¶
func (c *BaseComponent) SetSize(width, height int32)
func (*BaseComponent) SetVisible ¶
func (c *BaseComponent) SetVisible(visible bool)
func (BaseComponent) Size ¶
func (c BaseComponent) Size() (int32, int32)
type BaseGame ¶
func (*BaseGame) Initialize ¶
Initialize should be called by any descending structs
func (*BaseGame) RegisterPages ¶
type BasePage ¶
type BasePage struct { BaseComponent Data interface{} Name string }
func (*BasePage) PageUnload ¶
type ButtonComponent ¶
type ButtonComponent struct { BaseComponent Text string OnAction OnActionFunc // contains filtered or unexported fields }
func NewButtonComponent ¶
func NewButtonComponent(x, y, w, h int32, text string, backgroundColor sdl.Color, buttonColor sdl.Color, textColor sdl.Color, onAction OnActionFunc) *ButtonComponent
func (*ButtonComponent) DrawComponent ¶
func (c *ButtonComponent) DrawComponent(r *sdl.Renderer) error
func (*ButtonComponent) KeyEvent ¶
func (c *ButtonComponent) KeyEvent(event *sdl.KeyboardEvent) bool
func (*ButtonComponent) MouseButtonEvent ¶
func (c *ButtonComponent) MouseButtonEvent(event *sdl.MouseButtonEvent) bool
type Component ¶
type Component interface { Initialize() Position() (int32, int32) Size() (int32, int32) AddChild(Component) RemoveChild(int) GetChildren() []Component Draw(r *sdl.Renderer) error DrawComponent(r *sdl.Renderer) error KeyEvent(event *sdl.KeyboardEvent) bool MouseButtonEvent(event *sdl.MouseButtonEvent) bool BaseMouseButtonEvent(event *sdl.MouseButtonEvent) bool IsPointInComponent(x, y int32) bool IsVisible() bool SetVisible(visible bool) }
Component is the base interface for all components in this system
type LabelComponent ¶
type LabelComponent struct { BaseComponent // contains filtered or unexported fields }
func NewLabelComponent ¶
func NewLabelComponent(x, y, width, height int32, fontSize int, labelTextFunc LabelTextFunc) *LabelComponent
func NewLabelComponentWithConfig ¶
func NewLabelComponentWithConfig(x, y, width, height int32, labelTextFunc LabelTextFunc, labelConfig LabelConfig) *LabelComponent
func (*LabelComponent) DrawComponent ¶
func (c *LabelComponent) DrawComponent(r *sdl.Renderer) error
type LabelConfig ¶
type LabelConfig struct { FontName string `default:"TruenoLight"` FontFile string `default:"built-in-fonts/TruenoLight.otf"` FontSize int `default:"24"` Justify int `default:"0" ` Color sdl.Color `default:"{\"R\": 50, \"G\": 255, \"B\": 50, \"A\": 255}"` }
func NewLabelConfig ¶
func NewLabelConfig() LabelConfig
type LabelTextFunc ¶
type LabelTextFunc func() string
type OnActionFunc ¶
type OnActionFunc func()
type Page ¶
type Page interface { Component GetName() string PageLoad() error PageUnload() error SetData(data interface{}) GetData() interface{} Quit() bool }
var ActivePage Page
type RectangleComponent ¶
type RectangleComponent struct { BaseComponent Background sdl.Color }
func NewRectangleComponent ¶
func NewRectangleComponent(x, y, width, height int32, background sdl.Color) *RectangleComponent
func (*RectangleComponent) DrawComponent ¶
func (c *RectangleComponent) DrawComponent(r *sdl.Renderer) error
type Window ¶
type Window struct { Width int32 Height int32 Title string Scaling float32 Background sdl.Color // contains filtered or unexported fields }
Window represents the main object to display text output
var MainWindow Window
Click to show internal directories.
Click to hide internal directories.