Documentation ¶
Index ¶
- Variables
- func PositionFromVec2(vector2 rl.Vector2) geom.Point
- func StrToColour(str string) rl.Color
- type Button
- type ButtonCallback
- type Cell
- type CellLayer
- type CellMap
- type Console
- func (c *Console) Blit(xSrc, ySrc, wSrc, hSrc int, dst IConsole, xDst, yDst int, ...)
- func (c *Console) Clear()
- func (c *Console) ClearDirty()
- func (c *Console) ClearRect(pos geom.Point, w, h uint)
- func (c *Console) GetCellAtPos(pos geom.Point) *Cell
- func (c Console) GetChar(pos geom.Point) uint
- func (c Console) GetCharBackground(pos geom.Point) rl.Color
- func (c Console) GetCharForeground(pos geom.Point) rl.Color
- func (c Console) GetData() CellMap
- func (c Console) GetDefaultBackground() rl.Color
- func (c Console) GetDefaultForeground() rl.Color
- func (c Console) GetDirty() DirtyMap
- func (c Console) GetHeight() uint
- func (c Console) GetWidth() uint
- func (c *Console) Hline(pos geom.Point, l uint)
- func (c *Console) InBounds(pos geom.Point) bool
- func (c *Console) Print(pos geom.Point, str string)
- func (c *Console) PrintFrame(pos geom.Point, w, h uint, style FrameStyle, title FrameTitle, ...)
- func (c *Console) PutChar(r uint, p geom.Point)
- func (c *Console) PutCharEx(r uint, p geom.Point, fg, bg rl.Color)
- func (c *Console) SetChar(r uint, pos geom.Point)
- func (c *Console) SetCharBackground(pos geom.Point, colour rl.Color)
- func (c *Console) SetCharForeground(pos geom.Point, colour rl.Color)
- func (c *Console) SetDefaultBackground(colour rl.Color)
- func (c *Console) SetDefaultForeground(colour rl.Color)
- func (c *Console) SetDirty(pos geom.Point)
- func (c *Console) SetKeyColor(colour rl.Color)
- type Container
- type DirtyMap
- type FrameStyle
- type FrameTitle
- type Gui
- func (g *Gui) GetConsole() IConsole
- func (g *Gui) GetFocusedKeyboardWidget() IWidget
- func (g *Gui) GetFocusedWidget() IWidget
- func (g *Gui) IsFocused(w IWidget) bool
- func (g *Gui) IsKeyboardFocused(w IWidget) bool
- func (g *Gui) NewBasicButton(pos geom.Point, width, height uint, label string, borderStyle FrameStyle) *Button
- func (g *Gui) NewBasicRadioButton(pos geom.Point, width, height uint, label string, borderStyle FrameStyle) *RadioButton
- func (g *Gui) NewBasicToggleButton(pos geom.Point, width, height uint, label string, borderStyle FrameStyle) *ToggleButton
- func (g *Gui) NewButton(pos geom.Point, width, height uint, label string, tip string, ...) *Button
- func (g *Gui) NewContainer(pos geom.Point, width, height uint) *Container
- func (g *Gui) NewHBox(pos geom.Point, padding uint) *HBox
- func (g *Gui) NewRadioButton(pos geom.Point, width, height uint, label string, tip string, ...) *RadioButton
- func (g *Gui) NewSeparator(text, tip string) *Separator
- func (g *Gui) NewToggleButton(pos geom.Point, width, height uint, label string, tip string, ...) *ToggleButton
- func (g *Gui) NewToolbar(pos geom.Point, width uint, name string) *Toolbar
- func (g *Gui) NewVBox(pos geom.Point, padding uint) *VBox
- func (g *Gui) Register(w IWidget)
- func (g *Gui) RenderWidgets()
- func (g *Gui) SetConsole(console IConsole)
- func (g *Gui) Unregister(w IWidget)
- func (g *Gui) UpdateWidgets(dt float32)
- type HBox
- type IConsole
- type IWidget
- type Mouse
- type RadioButton
- type RadioButtonCallback
- type RadioButtonGroups
- type RaylibConsole
- type Separator
- type TextAlignment
- type ToggleButton
- type ToggleButtonCallback
- type Toolbar
- type VBox
- type Widget
- func (w *Widget) ComputeSize()
- func (w *Widget) Delete()
- func (w Widget) GetBorderStyle() FrameStyle
- func (w *Widget) GetCurrentColors() (fore, back rl.Color)
- func (w *Widget) GetDefaultBackground() (col, colFocus rl.Color)
- func (w *Widget) GetDefaultForeground() (col, colFocus rl.Color)
- func (w Widget) GetDisabled() bool
- func (w Widget) GetGui() *Gui
- func (w Widget) GetHeight() uint
- func (w Widget) GetMouseIn() bool
- func (w Widget) GetMouseL() bool
- func (w Widget) GetPosition() geom.Point
- func (w Widget) GetTip() string
- func (w *Widget) GetUserData() interface{}
- func (w Widget) GetWidth() uint
- func (w Widget) IsVisible() bool
- func (w *Widget) Move(pos geom.Point)
- func (w Widget) Render(iW IWidget)
- func (w *Widget) SetBorderStyle(f FrameStyle)
- func (w *Widget) SetDefaultBackground(col, colFocus rl.Color)
- func (w *Widget) SetDefaultForeground(col, colFocus rl.Color)
- func (w *Widget) SetDisabled(d bool)
- func (w *Widget) SetGui(g *Gui)
- func (w *Widget) SetHeight(height uint)
- func (w *Widget) SetMouseIn(mouseIn bool)
- func (w *Widget) SetMouseL(mouseL bool)
- func (w *Widget) SetTip(tip string)
- func (w *Widget) SetUserData(data interface{})
- func (w *Widget) SetVisible(visible bool)
- func (w *Widget) SetWidth(width uint)
- func (w *Widget) SetX(x int)
- func (w *Widget) SetY(y int)
- func (w *Widget) Update(iW IWidget)
Constants ¶
This section is empty.
Variables ¶
var MouseStatus = &Mouse{}
var SingleWallBorder = FrameStyle{ sprites.TCOD_CHAR_VLINE, sprites.TCOD_CHAR_HLINE, sprites.TCOD_CHAR_NE, sprites.TCOD_CHAR_SE, sprites.TCOD_CHAR_SW, sprites.TCOD_CHAR_NW, }
SingleWallBorder displays a single line border
var UpdateMouseStatus func()
var ZeroFrameTitle = FrameTitle{ // contains filtered or unexported fields }
var ZeroWallBorder = FrameStyle{
0, 0, 0, 0, 0, 0,
}
ZeroWallBorder displays no border
Functions ¶
Types ¶
type Button ¶
type Button struct { Widget // contains filtered or unexported fields }
func (*Button) ComputeSize ¶
func (b *Button) ComputeSize()
type ButtonCallback ¶
type ButtonCallback func(w *Button, userData interface{})
type Console ¶
type Console struct {
// contains filtered or unexported fields
}
func NewVirtualConsole ¶
You can create as many off-screen consoles as you want by using this function. Then use the blit function to draw content to a windowed virtual console such as RaylibConsole.
func (*Console) Blit ¶
func (c *Console) Blit(xSrc, ySrc, wSrc, hSrc int, dst IConsole, xDst, yDst int, foregroundAlpha, backgroundAlpha float32)
This function allows you to blit a rectangular area of the source console at a specific position on a destination console. It can also simulate alpha transparency with the fade parameter.
func (*Console) ClearDirty ¶
func (c *Console) ClearDirty()
func (Console) GetCharBackground ¶
TODO This will result in a panic if pos is out of bounds
func (Console) GetCharForeground ¶
TODO This will result in a panic if pos is out of bounds
func (Console) GetDefaultBackground ¶
func (Console) GetDefaultForeground ¶
func (*Console) Print ¶
Split str into individual runes and then loop over and set the char at that geom position.
<%FG:colour_name>Text<%/> <%BG:colour_name>Text<%/> <%FG:colour_name,BG:colour_name>Text<%/>
func (*Console) PrintFrame ¶
func (c *Console) PrintFrame(pos geom.Point, w, h uint, style FrameStyle, title FrameTitle, filled, clear bool)
func (*Console) SetCharBackground ¶
TODO This will result in a panic if pos is out of bounds
func (*Console) SetCharForeground ¶
TODO This will result in a panic if pos is out of bounds
func (*Console) SetDefaultBackground ¶
func (*Console) SetDefaultForeground ¶
func (*Console) SetKeyColor ¶
type Container ¶
type Container struct { Widget // contains filtered or unexported fields }
Container is a workspace for displaying Widgets within a particular "viewport"
func (*Container) RemoveWidget ¶
type FrameStyle ¶
type FrameStyle struct {
V, H, NE, SE, SW, NW uint
}
FrameStyle defines a Widget's border. Those without a border will have it set to ZeroWallBorder.
func (FrameStyle) IsZeroWallBorder ¶
func (f FrameStyle) IsZeroWallBorder() bool
IsZeroWallBorder is used to determine if a Widget's border should be drawn
type FrameTitle ¶
type FrameTitle struct {
// contains filtered or unexported fields
}
FrameTitle is complementary to FrameStyle, both are used by IConsole.PrintFrame
func (FrameTitle) IsVisible ¶
func (f FrameTitle) IsVisible() bool
type Gui ¶
type Gui struct {
// contains filtered or unexported fields
}
func (*Gui) GetConsole ¶
func (*Gui) GetFocusedKeyboardWidget ¶
Get the focused Widget for keyboard input
func (*Gui) GetFocusedWidget ¶
Get the focused Widget for mouse input
func (*Gui) IsKeyboardFocused ¶
Set the focused Widget for keyboard input
func (*Gui) NewBasicButton ¶
func (*Gui) NewBasicRadioButton ¶
func (g *Gui) NewBasicRadioButton(pos geom.Point, width, height uint, label string, borderStyle FrameStyle) *RadioButton
func (*Gui) NewBasicToggleButton ¶
func (g *Gui) NewBasicToggleButton(pos geom.Point, width, height uint, label string, borderStyle FrameStyle) *ToggleButton
func (*Gui) NewButton ¶
func (g *Gui) NewButton(pos geom.Point, width, height uint, label string, tip string, borderStyle FrameStyle, callback ButtonCallback, userData interface{}) *Button
func (*Gui) NewContainer ¶
func (*Gui) NewRadioButton ¶
func (g *Gui) NewRadioButton(pos geom.Point, width, height uint, label string, tip string, borderStyle FrameStyle, callback RadioButtonCallback, userData interface{}) *RadioButton
func (*Gui) NewSeparator ¶
func (*Gui) NewToggleButton ¶
func (g *Gui) NewToggleButton(pos geom.Point, width, height uint, label string, tip string, borderStyle FrameStyle, callback ToggleButtonCallback, userData interface{}) *ToggleButton
func (*Gui) RenderWidgets ¶
func (g *Gui) RenderWidgets()
func (*Gui) SetConsole ¶
Set the Console the Gui should render to
func (*Gui) UpdateWidgets ¶
type HBox ¶
type HBox struct {
VBox
}
HBox is an extension to Container that ensures Widget's added to it are presented in a row
func (*HBox) ComputeSize ¶
func (h *HBox) ComputeSize()
type IConsole ¶
type IConsole interface { InBounds(pos geom.Point) bool GetData() CellMap GetDirty() DirtyMap ClearDirty() GetCellAtPos(pos geom.Point) *Cell GetDefaultBackground() rl.Color GetDefaultForeground() rl.Color SetDefaultForeground(colour rl.Color) SetDefaultBackground(colour rl.Color) Clear() GetCharBackground(pos geom.Point) rl.Color GetCharForeground(pos geom.Point) rl.Color SetCharBackground(pos geom.Point, colour rl.Color) SetCharForeground(pos geom.Point, colour rl.Color) SetChar(r uint, pos geom.Point) PutChar(r uint, p geom.Point) PutCharEx(r uint, p geom.Point, fg, bg rl.Color) Print(pos geom.Point, str string) //PrintRect(x, y, w, h int, fmts string, v ...interface{}) int ClearRect(pos geom.Point, w, h uint) // TODO: Rename PrintFrame to DrawFrame ?? PrintFrame(pos geom.Point, w, h uint, boxStyle FrameStyle, title FrameTitle, filled, clear bool) //PrintRectEx(x, y, w, h int, flag BkgndFlag, alignment Alignment, fmts string, v ...interface{}) int //HeightRect(x, y, w, h int, fmts string, v ...interface{}) int //SetBackgroundFlag(flag BkgndFlag) //GetBackgroundFlag() BkgndFlag //SetAlignment(alignment Alignment) //GetAlignment() Alignment //Rect(x, y, w, h int, clear bool, flag BkgndFlag) Hline(pos geom.Point, l uint) //Vline(x, y, l int, flag BkgndFlag) GetChar(pos geom.Point) uint GetWidth() uint GetHeight() uint SetKeyColor(colour rl.Color) Blit(xSrc, ySrc, wSrc, hSrc int, dst IConsole, xDst, yDst int, foregroundAlpha, backgroundAlpha float32) }
type IWidget ¶
type IWidget interface { SetGui(*Gui) GetGui() *Gui Delete() SetX(int) SetY(int) GetWidth() uint SetWidth(width uint) GetHeight() uint SetHeight(height uint) GetPosition() geom.Point Move(pos geom.Point) IsVisible() bool SetVisible(visible bool) GetUserData() interface{} SetUserData(data interface{}) SetDisabled(d bool) GetDisabled() bool GetTip() string SetTip(tip string) GetMouseIn() bool SetMouseIn(mouseIn bool) GetMouseL() bool SetMouseL(mouseL bool) ComputeSize() Update(w IWidget) Render(w IWidget) SetDefaultBackground(col, colFocus rl.Color) SetDefaultForeground(col, colFocus rl.Color) GetDefaultBackground() (col, colFocus rl.Color) GetDefaultForeground() (col, colFocus rl.Color) GetCurrentColors() (fore, back rl.Color) GetBorderStyle() FrameStyle SetBorderStyle(f FrameStyle) // contains filtered or unexported methods }
IWidget is an interface based upon the libtcod widget toolkit. It's partially implemented by the base Widget struct, which itself is extended by the GUI components such as Button and VBox.
type RadioButton ¶
type RadioButton struct { Button // contains filtered or unexported fields }
func (*RadioButton) IsSelected ¶
func (b *RadioButton) IsSelected() bool
func (*RadioButton) Render ¶
func (b *RadioButton) Render(iB IWidget)
func (*RadioButton) Select ¶
func (b *RadioButton) Select()
func (*RadioButton) SetGroup ¶
func (b *RadioButton) SetGroup(group uint)
func (*RadioButton) UnSelect ¶
func (b *RadioButton) UnSelect()
type RadioButtonCallback ¶
type RadioButtonCallback func(w *RadioButton, userData interface{})
type RadioButtonGroups ¶
type RadioButtonGroups struct {
// contains filtered or unexported fields
}
func NewRadioButtonGroups ¶
func NewRadioButtonGroups() *RadioButtonGroups
func (*RadioButtonGroups) SetDefaultGroup ¶
func (g *RadioButtonGroups) SetDefaultGroup(group uint)
func (*RadioButtonGroups) SetGroupSelection ¶
func (g *RadioButtonGroups) SetGroupSelection(btn *RadioButton)
func (*RadioButtonGroups) UnSelectGroup ¶
func (g *RadioButtonGroups) UnSelectGroup(group uint)
type RaylibConsole ¶
type RaylibConsole struct { Console // contains filtered or unexported fields }
func NewRaylibConsole ¶
func NewRaylibConsole(w, h uint, fps uint, title string, fontProps sprites.TileSetProperties, fullscreen bool) *RaylibConsole
Create a new Virtual console wrapped in a Raylib window; only one of these should be used per application. In libtcod parlance this is a root console.
For a Windowed console the width/height of Console is equivalent to columns/rows.
@todo check and return error if division by zero when tile width/height is zero
func (RaylibConsole) Draw ¶
func (c RaylibConsole) Draw(dt float32)
func (*RaylibConsole) SetDebug ¶
func (c *RaylibConsole) SetDebug(b bool)
func (RaylibConsole) Unload ¶
func (c RaylibConsole) Unload()
type Separator ¶
type Separator struct { Widget // contains filtered or unexported fields }
func (*Separator) ComputeSize ¶
func (s *Separator) ComputeSize()
type TextAlignment ¶
type TextAlignment uint
const ( AlignTextLeft TextAlignment = iota AlignTextCenter AlignTextRight )
type ToggleButton ¶
type ToggleButton struct { Button // contains filtered or unexported fields }
func (ToggleButton) IsToggled ¶
func (b ToggleButton) IsToggled() bool
func (*ToggleButton) Render ¶
func (b *ToggleButton) Render(iB IWidget)
func (*ToggleButton) SetToggled ¶
func (b *ToggleButton) SetToggled(value bool)
type ToggleButtonCallback ¶
type ToggleButtonCallback func(w *ToggleButton, userData interface{})
type Toolbar ¶
type Toolbar struct { Container // contains filtered or unexported fields }
func (*Toolbar) AddSeparator ¶
func (*Toolbar) ComputeSize ¶
func (t *Toolbar) ComputeSize()
type VBox ¶
type VBox struct { Container // contains filtered or unexported fields }
VBox is an extension to Container that ensures Widget's added to it are presented in a column.
func (*VBox) ComputeSize ¶
func (v *VBox) ComputeSize()
ComputeSize calculates the VBox dimensions and updates each of its child Widget's position to be stacked within those bounds.
type Widget ¶
type Widget struct {
// contains filtered or unexported fields
}
Widget is the base struct extended by all GUI components. It implements all but eight of the methods defined by IWidget leaving them as "abstract" to be extended by GUI components.
func (*Widget) ComputeSize ¶
func (w *Widget) ComputeSize()
func (Widget) GetBorderStyle ¶
func (w Widget) GetBorderStyle() FrameStyle
func (*Widget) GetCurrentColors ¶
func (*Widget) GetDefaultBackground ¶
func (*Widget) GetDefaultForeground ¶
func (Widget) GetDisabled ¶
func (Widget) GetMouseIn ¶
func (Widget) GetPosition ¶
func (*Widget) GetUserData ¶
func (w *Widget) GetUserData() interface{}
func (*Widget) SetBorderStyle ¶
func (w *Widget) SetBorderStyle(f FrameStyle)
func (*Widget) SetDefaultBackground ¶
func (*Widget) SetDefaultForeground ¶
func (*Widget) SetDisabled ¶
func (*Widget) SetMouseIn ¶
func (*Widget) SetUserData ¶
func (w *Widget) SetUserData(data interface{})