Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Event ¶
type Event uint8
I want to try and simplify event handling for widgets. Not sure this counts.
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
Group adds a list of children to widgets embedding it, as well as an Add() method to append children to the list, and event dispatching.
func (*Group) Clear ¶
func (g *Group) Clear()
Clear removes all children from the group and clears their textures.
func (*Group) ProcessEvent ¶
ProcessEvent calls ProcessEvent for each child widget until one of them returns true. If none return true, false is returned.
type HorizontalLayout ¶
type HorizontalLayout struct {
*Group
}
HorizontalLayout renders its children widgets from left to right, horizontally centered.
func NewHorizontalLayout ¶
func NewHorizontalLayout(size *sdl.Rect, children []Widget, props ...Properties) *HorizontalLayout
func (*HorizontalLayout) Add ¶
func (l *HorizontalLayout) Add(child Widget)
func (HorizontalLayout) Destroy ¶
func (w HorizontalLayout) Destroy()
Destroy frees the widget's internal texture.
func (*HorizontalLayout) ProcessEvent ¶
func (l *HorizontalLayout) ProcessEvent(e Event) bool
type Input ¶
type Input struct { *HorizontalLayout Text string // Input value as text, set at confirm time // contains filtered or unexported fields }
func NewInput ¶
NewInput instantiates an Input widget with the given number of editable characters. Each character can be selected within the given charset. By default, the first character of the string given as a charset is used.
func (*Input) ProcessEvent ¶
type Label ¶
type Label struct {
// contains filtered or unexported fields
}
func NewLabel ¶
func NewLabel(sizeHint *sdl.Rect, text string, props ...Properties) *Label
TODO: why couldn't these be methods of a global UI object abstracting the renderer?
I'd just need to move all widgets back up to the ui package.
TODO: actual font size
func (Label) ProcessEvent ¶
ProcessEvent should be overridden in widgets that actually do process events. The default implementation always returns false to indicate no event is handled.
type Menu ¶
type Menu struct { *VerticalLayout // contains filtered or unexported fields }
Menu widget displaying a list of potential choices, each of which should map to some kind of Action.
func (*Menu) ProcessEvent ¶
type Properties ¶
type Properties struct { Font *ttf.Font TitleFont *ttf.Font // FIXME: only one Font property, to be set to small or large. BgColor sdl.Color // FIXME: OutlineColor FgColor sdl.Color Background sdl.Color // Background color (default is transparent) Margin int32 // TODO: individual horizontal/vertical margin HorizontalAlign align.Align // Widget contents alignment (horizontal) VerticalAlign align.Align // Widget contents alignment (vertical) // For debugging if nothing else. Border int32 BorderColor sdl.Color Zoom int // Zoom factor for the GameBoy display. Used for outlines, margins. }
Properties stores useful configuration variables to be passed to all widgets at creation time. Internally uses SDL types for convenience. FIXME: separate actual widget properties (margin, background...) and configuration (Fg/BgColor, fonts...)
var DefaultProperties Properties
type Stack ¶
type Stack struct { *Group // contains filtered or unexported fields }
func (*Stack) Add ¶
Add appends the given widget to the stack's internal children, and shows it if it's the very first child to be added.
func (*Stack) ProcessEvent ¶
ProcessEvent calls ProcessEvent for the currently displayed widget if any.
type VerticalLayout ¶
type VerticalLayout struct {
*Group
}
VerticalLayout renders its children widgets from top to bottom, vertically centered.
func NewVerticalLayout ¶
func NewVerticalLayout(size *sdl.Rect, children []Widget, props ...Properties) *VerticalLayout
func (*VerticalLayout) Add ¶
func (l *VerticalLayout) Add(child Widget)
type Widget ¶
type Widget interface { // ProcessEvent returns true if the widget caught and handled the event, // false if it did not. ProcessEvent(Event) bool // Texture return the widget's internal texture in its current state. This // call might modify the renderer's state if a widget redraws its texture // just-in-time. Texture() *sdl.Texture // Destroy releases all resources dynamically allocated by the widget, like // its internal texture. Destroy() }