Documentation
¶
Index ¶
- Constants
- func BuildTextLines(in string, width int) []string
- func GenCellSlice(str string, points map[int]AttribPair) []termbox.Cell
- func HeightRequired(str string, width int) int
- func RunFunc(e Entity, f func(e Entity))
- func RunFuncCond(e Entity, f func(e Entity) bool) bool
- func RunFuncCondTraverse(e Entity, f func(e Entity) bool)
- func RuneByPhysPosition(s string, runePos int) (rune, int)
- func SafeSetCursor(x, y int)
- func SetCells(cells []termbox.Cell, startX, startY, width, height int) int
- func SimpleSetText(startX, startY, width int, str string, fg, bg termbox.Attribute) int
- func StrSplit(s string, width int) (split, rest string)
- func StringSearch(search, content string) int
- type AttribPair
- type AutoLayoutContainer
- func (a *AutoLayoutContainer) BuildLayout()
- func (a *AutoLayoutContainer) Destroy()
- func (a AutoLayoutContainer) EmitChangedEvent(e LayoutElement)
- func (a *AutoLayoutContainer) GetRequiredSize() common.Vector2F
- func (a *AutoLayoutContainer) IsLayoutDynamic() bool
- func (a *AutoLayoutContainer) Update()
- type BackHandler
- type BaseEntity
- type Container
- type DataType
- type Direction
- type DrawHandler
- type Entity
- type InputHandler
- type LateUpdateHandler
- type LayoutChangeHandler
- type LayoutElement
- type LayoutType
- type Manager
- func (u *Manager) AddInput(input *TextInput, setActive bool)
- func (u *Manager) AddWindow(e Entity)
- func (u *Manager) AddWindowFront(e Entity)
- func (u *Manager) CurrentWindow() Entity
- func (u *Manager) RemoveInput(input *TextInput, reAssignActive bool)
- func (u *Manager) RemoveWindow(e Entity) bool
- func (u *Manager) SetActiveInput(input *TextInput)
- type MenuItem
- type MenuItemSlice
- type MenuWindow
- func (mw *MenuWindow) AddMarked(index int)
- func (mw *MenuWindow) ApplyStyleToItem(item *MenuItem)
- func (mw *MenuWindow) Back() bool
- func (mw *MenuWindow) CheckBounds(index int) int
- func (mw *MenuWindow) CheckBoundsSelectedable(index int) int
- func (mw *MenuWindow) Destroy()
- func (mw *MenuWindow) FilterOptions()
- func (mw *MenuWindow) GetHighlighted() *MenuItem
- func (mw *MenuWindow) GetIndex(item *MenuItem) int
- func (mw *MenuWindow) OptionsHeight() int
- func (mw *MenuWindow) Rebuild()
- func (mw *MenuWindow) RemoveMarked(index int)
- func (mw *MenuWindow) RunFunc(f func(item *MenuItem) bool)
- func (mw *MenuWindow) Scroll(dir Direction, amount int)
- func (mw *MenuWindow) Select()
- func (mw *MenuWindow) SetHighlighted(index int)
- func (mw *MenuWindow) SetOptions(options []*MenuItem)
- func (mw *MenuWindow) SetOptionsString(options []string)
- func (mw *MenuWindow) Update()
- type Scrollable
- type SelectAble
- type SimpleEntity
- type Text
- type TextInput
- func (ti *TextInput) Destroy()
- func (ti *TextInput) Draw()
- func (ti *TextInput) Erase(dir Direction, amount int, byWords bool)
- func (ti *TextInput) GetDrawLayer() int
- func (ti *TextInput) GetRequiredSize() common.Vector2F
- func (ti *TextInput) HandleInput(event termbox.Event)
- func (ti *TextInput) IsLayoutDynamic() bool
- func (ti *TextInput) MoveCursor(dir Direction, amount int, byWords bool)
- func (ti *TextInput) SetActive(active bool)
- func (ti *TextInput) Update()
- type ToggleAble
- type Transform
- type UpdateHandler
- type Window
Constants ¶
const ( TextModeOverflow = iota TextModeHide TextModeWrap )
const (
DefaultWindowFillBG = termbox.ColorBlack
)
Variables ¶
This section is empty.
Functions ¶
func BuildTextLines ¶
func GenCellSlice ¶
func GenCellSlice(str string, points map[int]AttribPair) []termbox.Cell
Generates a cellslice with attributes
func HeightRequired ¶
Returns the number of lines required
func RunFunc ¶
Runs f recursively and in order on e and its children by in order it means it runs on parent first and children last
func RunFuncCond ¶
Same as above but stops completely if f returns false
func RunFuncCondTraverse ¶
Same as above but instead of stopping completely, will not traverse the children of e when f returns false
func RuneByPhysPosition ¶
Returns the rune at the physical position, that means it takes The width of runes into account
func SafeSetCursor ¶
func SafeSetCursor(x, y int)
Crashes on windows otherwise if going out of bounds
func SimpleSetText ¶
A Helper for drawing simple text, returns number of lines
func StringSearch ¶
Types ¶
type AttribPair ¶
Simple bg fg attribute pair
type AutoLayoutContainer ¶
type AutoLayoutContainer struct {
*BaseEntity
ForceExpandWidth, ForceExpandHeight bool
LayoutType LayoutType
LayoutDynamic bool
Spacing int
}
func NewAutoLayoutContainer ¶
func NewAutoLayoutContainer() *AutoLayoutContainer
func (*AutoLayoutContainer) BuildLayout ¶
func (a *AutoLayoutContainer) BuildLayout()
func (*AutoLayoutContainer) Destroy ¶
func (a *AutoLayoutContainer) Destroy()
func (AutoLayoutContainer) EmitChangedEvent ¶
func (a AutoLayoutContainer) EmitChangedEvent(e LayoutElement)
func (*AutoLayoutContainer) GetRequiredSize ¶
func (a *AutoLayoutContainer) GetRequiredSize() common.Vector2F
func (*AutoLayoutContainer) IsLayoutDynamic ¶
func (a *AutoLayoutContainer) IsLayoutDynamic() bool
func (*AutoLayoutContainer) Update ¶
func (a *AutoLayoutContainer) Update()
type BackHandler ¶
type BackHandler interface {
Back() bool // Return false for not handled
}
type BaseEntity ¶
type BaseEntity struct {
Transform Transform
}
func (*BaseEntity) Children ¶
func (b *BaseEntity) Children(recursive bool) []Entity
func (*BaseEntity) DestroyChildren ¶
func (b *BaseEntity) DestroyChildren()
func (*BaseEntity) GetTransform ¶
func (b *BaseEntity) GetTransform() *Transform
type Container ¶
type Container struct {
*BaseEntity
ProxySize LayoutElement
Dynamic bool
AllowZeroSize bool
}
func (*Container) GetRequiredSize ¶
func (*Container) IsLayoutDynamic ¶
type DrawHandler ¶
type DrawHandler interface {
GetDrawLayer() int
Draw()
}
type InputHandler ¶
type LateUpdateHandler ¶
type LateUpdateHandler interface {
LateUpdate() // Ran after update, shouldnt change the size of the element
}
type LayoutChangeHandler ¶
type LayoutChangeHandler interface {
OnLayoutChanged()
}
type LayoutElement ¶
type LayoutType ¶
type LayoutType int
const ( LayoutTypeVertical LayoutType = iota LayoutTypeHorizontal )
type Manager ¶
func NewManager ¶
func NewManager() *Manager
func (*Manager) AddWindowFront ¶
func (*Manager) CurrentWindow ¶
func (*Manager) RemoveInput ¶
func (*Manager) RemoveWindow ¶
func (*Manager) SetActiveInput ¶
type MenuItem ¶
type MenuItem struct {
Name string
IsCategory bool
Decorative bool // Not selectable
IsInput bool
InputType DataType
InputDefaultText string
Marked bool
Highlighted bool
Info string
UserData interface{}
Children []*MenuItem
Text *Text
Input *TextInput
// contains filtered or unexported fields
}
func FilterOptionsByPath ¶
func (*MenuItem) GetDisplayName ¶
type MenuItemSlice ¶
type MenuItemSlice []*MenuItem
func (MenuItemSlice) Len ¶
func (mi MenuItemSlice) Len() int
func (MenuItemSlice) Less ¶
func (mi MenuItemSlice) Less(a, b int) bool
func (MenuItemSlice) Swap ¶
func (mi MenuItemSlice) Swap(i, j int)
type MenuWindow ¶
type MenuWindow struct {
*BaseEntity
Window *Window
LowerWindow *Window
MainContainer *AutoLayoutContainer
TopContainer *Container
MenuItemContainer *AutoLayoutContainer
LowerContainer *Container
InfoText *Text
SearchInput *TextInput
// Style
StyleNormal AttribPair
StyleMarked AttribPair
StyleSelected AttribPair
StyleMarkedSelected AttribPair
StyleInputNormal AttribPair
Options []*MenuItem
FilteredOptions []*MenuItem
Selectables []int
Highlighted int
CurDir []string
Dirty bool
Layer int
OnSelect func(*MenuItem)
// contains filtered or unexported fields
}
func NewMenuWindow ¶
func NewMenuWindow(layer int, manager *Manager, searchEnabled bool) *MenuWindow
func (*MenuWindow) AddMarked ¶
func (mw *MenuWindow) AddMarked(index int)
func (*MenuWindow) ApplyStyleToItem ¶
func (mw *MenuWindow) ApplyStyleToItem(item *MenuItem)
func (*MenuWindow) Back ¶
func (mw *MenuWindow) Back() bool
func (*MenuWindow) CheckBounds ¶
func (mw *MenuWindow) CheckBounds(index int) int
Makes sure index is within len(options)
func (*MenuWindow) CheckBoundsSelectedable ¶
func (mw *MenuWindow) CheckBoundsSelectedable(index int) int
func (*MenuWindow) Destroy ¶
func (mw *MenuWindow) Destroy()
func (*MenuWindow) FilterOptions ¶
func (mw *MenuWindow) FilterOptions()
func (*MenuWindow) GetHighlighted ¶
func (mw *MenuWindow) GetHighlighted() *MenuItem
func (*MenuWindow) GetIndex ¶
func (mw *MenuWindow) GetIndex(item *MenuItem) int
func (*MenuWindow) OptionsHeight ¶
func (mw *MenuWindow) OptionsHeight() int
func (*MenuWindow) Rebuild ¶
func (mw *MenuWindow) Rebuild()
func (*MenuWindow) RemoveMarked ¶
func (mw *MenuWindow) RemoveMarked(index int)
func (*MenuWindow) RunFunc ¶
func (mw *MenuWindow) RunFunc(f func(item *MenuItem) bool)
func (*MenuWindow) Scroll ¶
func (mw *MenuWindow) Scroll(dir Direction, amount int)
func (*MenuWindow) Select ¶
func (mw *MenuWindow) Select()
func (*MenuWindow) SetHighlighted ¶
func (mw *MenuWindow) SetHighlighted(index int)
func (*MenuWindow) SetOptions ¶
func (mw *MenuWindow) SetOptions(options []*MenuItem)
func (*MenuWindow) SetOptionsString ¶
func (mw *MenuWindow) SetOptionsString(options []string)
func (*MenuWindow) Update ¶
func (mw *MenuWindow) Update()
type Scrollable ¶
type SelectAble ¶
type SelectAble interface {
Select()
}
type SimpleEntity ¶
type SimpleEntity struct {
*BaseEntity
}
func NewSimpleEntity ¶
func NewSimpleEntity() *SimpleEntity
func (*SimpleEntity) Destroy ¶
func (s *SimpleEntity) Destroy()
type Text ¶
type Text struct {
*BaseEntity
Disabled bool // won't draw then
Text string
SkipLines int
Mode int
Style AttribPair
Layer int
Userdata interface{}
// contains filtered or unexported fields
}
func (*Text) BuildLines ¶
func (t *Text) BuildLines()
func (*Text) GetDrawLayer ¶
func (*Text) GetRequiredSize ¶
Implement LayoutElement
func (*Text) HeightRequired ¶
func (*Text) IsLayoutDynamic ¶
func (*Text) SetAttribs ¶
func (t *Text) SetAttribs(attribs map[int]AttribPair)
type TextInput ¶
type TextInput struct {
*BaseEntity
Text *Text
TextBuffer string
CursorLocation int
Active bool
MaskInput bool // Replecas everything with "*"
HideCursorWhenEmpty bool
Layer int
DataType DataType
MinHeight int
Manager *Manager
}
func NewTextInput ¶
func (*TextInput) GetDrawLayer ¶
func (*TextInput) GetRequiredSize ¶
Implement LayoutElement
func (*TextInput) HandleInput ¶
func (*TextInput) IsLayoutDynamic ¶
func (*TextInput) MoveCursor ¶
type ToggleAble ¶
type ToggleAble interface {
Toggle()
}
type Transform ¶
type Transform struct {
AnchorMin common.Vector2F
AnchorMax common.Vector2F
Position common.Vector2F
Size common.Vector2F
Top, Bottom, Left, Right int
Parent *Transform
Children []Entity
}
Unity3d like UI transform (minus scale, pivot and rotation)
func (*Transform) AddChildren ¶
func (*Transform) ClearChildren ¶
Revmoves and optinally clears children
func (*Transform) RemoveChild ¶
type UpdateHandler ¶
type UpdateHandler interface {
Update() // Ran before drawing, for example add or remove children
}
type Window ¶
type Window struct {
*BaseEntity
Title string
Layer int
Border AttribPair
FillBG termbox.Attribute
Manager *Manager
}