Documentation ¶
Index ¶
- Constants
- Variables
- func ArrangeChild(e Element, finalWidth, finalHeight int)
- func MeasureChild(e Element, availableWidth, availableHeight int) (int, int)
- func SetBody(e Element)
- func SetFocus(e FocusElement)
- func Start(body Element)
- func Stop()
- func Update()
- func Wait()
- type AttributePropertyDefinition
- type BaseElement
- type Border
- func (b *Border) Arrange(finalWidth, finalHeight int)
- func (b *Border) Children() []css.Styleable
- func (b *Border) Height() int
- func (b *Border) Measure(availableWidth, availableHeight int) (width int, height int)
- func (b *Border) Name() string
- func (b *Border) Render(r Renderer)
- func (b *Border) Width() int
- type Element
- type ElementCollection
- func (c *ElementCollection) Add(e ...Element)
- func (c *ElementCollection) At(i int) Element
- func (c *ElementCollection) Clear()
- func (c *ElementCollection) IndexOf(e Element) int
- func (c *ElementCollection) Items() []Element
- func (c *ElementCollection) Len() int
- func (c *ElementCollection) Remove(e Element)
- func (c *ElementCollection) RemoveAt(i int)
- type FocusElement
- type Gravity
- type GravityPropertyDefinition
- type Grid
- func (g *Grid) AddChild(e Element, pos GridPosition)
- func (g *Grid) Arrange(finalWidth, finalHeight int)
- func (g *Grid) Children() []css.Styleable
- func (g *Grid) Height() int
- func (g *Grid) Measure(availableWidth, availableHeight int) (width int, height int)
- func (g *Grid) Name() string
- func (g *Grid) Render(r Renderer)
- func (g *Grid) Width() int
- type GridPosition
- type KeyHandler
- type Orientation
- type Renderer
- type StackPanel
- func (v *StackPanel) AddChild(e ...Element)
- func (v *StackPanel) Arrange(finalWidth, finalHeight int)
- func (v *StackPanel) Children() []css.Styleable
- func (v *StackPanel) Height() int
- func (v *StackPanel) Measure(availableWidth, availableHeight int) (width int, height int)
- func (v *StackPanel) Name() string
- func (v *StackPanel) Render(rn Renderer)
- func (v *StackPanel) Width() int
- type Text
- func (t *Text) Arrange(finalWidth, finalHeight int)
- func (t *Text) Children() []css.Styleable
- func (t *Text) Height() int
- func (t *Text) Measure(availableWidth, availableHeight int) (width int, height int)
- func (t *Text) Name() string
- func (t *Text) Render(rn Renderer)
- func (t *Text) SetText(txt string)
- func (t *Text) Text() string
- func (t *Text) Width() int
- type TextBorder
- type TextBox
- func (tb *TextBox) Arrange(finalWidth, finalHeight int)
- func (tb *TextBox) Children() []css.Styleable
- func (tb *TextBox) DeleteRuneBackward()
- func (tb *TextBox) DeleteRuneForward()
- func (tb *TextBox) DeleteTheRestOfTheLine()
- func (tb *TextBox) HandleKey(k termbox.Key, ch rune) bool
- func (tb *TextBox) Height() int
- func (tb *TextBox) InsertRune(r rune)
- func (tb *TextBox) Measure(availableWidth, availableHeight int) (width int, height int)
- func (tb *TextBox) MoveCursorOneRuneBackward()
- func (tb *TextBox) MoveCursorOneRuneForward()
- func (tb *TextBox) MoveCursorToBeginningOfTheLine()
- func (tb *TextBox) MoveCursorToEndOfTheLine()
- func (tb *TextBox) Name() string
- func (tb *TextBox) Render(fn Renderer)
- func (tb *TextBox) SetFocused(v bool)
- func (tb *TextBox) SetText(s string)
- func (tb *TextBox) Text() string
- func (tb *TextBox) Width() int
- type Thickness
- type ThicknessPropertyDefinition
- type WrapPanel
- func (v *WrapPanel) Add(e ...Element)
- func (v *WrapPanel) Arrange(finalWidth, finalHeight int)
- func (v *WrapPanel) Children() []css.Styleable
- func (v *WrapPanel) Clear()
- func (v *WrapPanel) Height() int
- func (v *WrapPanel) Len() int
- func (v *WrapPanel) Measure(availableWidth, availableHeight int) (width int, height int)
- func (v *WrapPanel) Name() string
- func (v *WrapPanel) Remove(e Element)
- func (v *WrapPanel) Render(rn Renderer)
- func (v *WrapPanel) Width() int
Constants ¶
const ( // GridSizeAuto is a Grid Size that takes only that much space as needed GridSizeAuto int = 0 // GridSizeAuto defines a Grid Size that takes as that much space as available after layout all others. // The total width is distributed between all rows / columns with Star definitions // For example you can have one column with 1*GridSizeStar and one with 2*GridSizeStar. In this case // the second column will be twice as wide as the first one. GridSizeStar int = -1 )
Variables ¶
var ( // BackgroundProperty is a css property for the background color. BackgroundProperty = NewAttributeProperty("background", css.PropertyBehaviorInherit) // ForegroundProperty is a css property for the foreground color ForegroundProperty = NewAttributeProperty("color", css.PropertyBehaviorInherit) // GravityProperty is a css property for the gravity. GravityProperty = NewGravityProperty("gravity", css.PropertyBehaviorDefault) )
var (
// Events can be used to recieve unhandled termbox events.
Events <-chan termbox.Event
)
var MarginProperty = NewThicknessProperty("margin")
Functions ¶
func ArrangeChild ¶
ArrangeChild arranges the child and takes margin in account
func MeasureChild ¶
MeasureChild measures the child and takes margin in account
func SetFocus ¶
func SetFocus(e FocusElement)
Types ¶
type AttributePropertyDefinition ¶
AttributePropertyDefinition is a typesafe encapsulation of a css property for termbox.Attributes values.
func NewAttributeProperty ¶
func NewAttributeProperty(name string, b css.PropertyBehavior) *AttributePropertyDefinition
NewAttributeProperty creates a new AttributePropertyDefinition
func (*AttributePropertyDefinition) FromInt ¶
func (a *AttributePropertyDefinition) FromInt(i int) (interface{}, error)
FromInt converts an integer to a termbox attribute.
func (*AttributePropertyDefinition) FromStrings ¶
func (a *AttributePropertyDefinition) FromStrings(s ...string) (interface{}, error)
FromStrings converts strings to a termbox attribute.
func (*AttributePropertyDefinition) Get ¶
func (a *AttributePropertyDefinition) Get(e Element) termbox.Attribute
Get returns the value of the property for the given element.
type BaseElement ¶
type BaseElement struct { css.IDAndClasses // contains filtered or unexported fields }
BaseElement helps implementing the Element interface for ui elements. It handles classes, the ID and also the parent element.
func (*BaseElement) Parent ¶
func (be *BaseElement) Parent() css.Styleable
Parent returns the parent of the element
func (*BaseElement) SetParent ¶
func (be *BaseElement) SetParent(e Element)
SetParent sets the parent element of this element
type Border ¶
type Border struct { BaseElement // contains filtered or unexported fields }
Border draws a border around a given child element
type Element ¶
type Element interface { css.Styleable // Measure gets the "wanted" size of the element based on the available size Measure(availableWidth, availableHeight int) (width int, height int) // Arrange sets the final size for the Element end tells it to Arrange itself Arrange(finalWidth, finalHeight int) // Render renders the element on the given Renderer Render(fn Renderer) // Width returns the width of the border Width() int // Height returns the height of the element Height() int // SetParent sets the parent element of this element SetParent(e Element) }
Element must be implemented by any UI element.
type ElementCollection ¶
type ElementCollection struct {
// contains filtered or unexported fields
}
func (*ElementCollection) Add ¶
func (c *ElementCollection) Add(e ...Element)
func (*ElementCollection) At ¶
func (c *ElementCollection) At(i int) Element
func (*ElementCollection) Clear ¶
func (c *ElementCollection) Clear()
func (*ElementCollection) IndexOf ¶
func (c *ElementCollection) IndexOf(e Element) int
func (*ElementCollection) Items ¶
func (c *ElementCollection) Items() []Element
func (*ElementCollection) Len ¶
func (c *ElementCollection) Len() int
func (*ElementCollection) Remove ¶
func (c *ElementCollection) Remove(e Element)
func (*ElementCollection) RemoveAt ¶
func (c *ElementCollection) RemoveAt(i int)
type FocusElement ¶
type FocusElement interface { KeyHandler // SetFocused is called by the ui system to indicate that the element has the focus. SetFocused(v bool) }
FocusElement is an element which can get the input focus.
type Gravity ¶
type Gravity byte
Gravity defines the horizontal and vertical orientation of an element.
type GravityPropertyDefinition ¶
GravityPropertyDefinition is a typesafe encapsulation of a css property for Gravity values.
func NewGravityProperty ¶
func NewGravityProperty(name string, b css.PropertyBehavior) *GravityPropertyDefinition
NewGravityProperty creates a new GravityPropertyDefinition
func (*GravityPropertyDefinition) FromInt ¶
func (gp *GravityPropertyDefinition) FromInt(i int) (interface{}, error)
FromInt converts an integer to a gravity value.
func (GravityPropertyDefinition) FromStrings ¶
func (gp GravityPropertyDefinition) FromStrings(s ...string) (interface{}, error)
FromStrings converts strings to a gravity value.
func (*GravityPropertyDefinition) Get ¶
func (gp *GravityPropertyDefinition) Get(e Element) Gravity
Get returns the value of the property for the given element.
type Grid ¶
type Grid struct { BaseElement // ColumnDefinitions contains the the column sizes for the grid ColumnDefinitions []int // RowDefinitions contains the the row sizes for the grid RowDefinitions []int // contains filtered or unexported fields }
Grid renders its children in a table like layout
func (*Grid) AddChild ¶
func (g *Grid) AddChild(e Element, pos GridPosition)
type GridPosition ¶
type GridPosition struct { // Column contains the column of the element Column int // Row contains the row of element Row int // ColumnSpan of the element. Auto-Width columns doesn't take spanned elements into account ColumnSpan int // RowSpan of the element. Auto-Height rows doesn't take spanned elements into account RowSpan int }
GridPosition defines the location of an element within a grid
type KeyHandler ¶
type Orientation ¶
type Orientation int
const ( // Vertical orientation Vertical Orientation = iota // Horizontal orientation Horizontal )
type Renderer ¶
type Renderer struct {
// contains filtered or unexported fields
}
Renderer helps drawing an element
func (Renderer) RenderChild ¶
RenderChild draws the given child.
type StackPanel ¶
type StackPanel struct { BaseElement // contains filtered or unexported fields }
StackPanel is an UI element which stacks multiple elements in vertical order.
func NewStackPanel ¶
func NewStackPanel(o Orientation) *StackPanel
NewStackPanel creates a new StackPanel
func (*StackPanel) AddChild ¶
func (v *StackPanel) AddChild(e ...Element)
AddChild adds the given children to the StackPanel
func (*StackPanel) Arrange ¶
func (v *StackPanel) Arrange(finalWidth, finalHeight int)
Arrange sets the final size for the Element end tells it to Arrange itself
func (*StackPanel) Children ¶
func (v *StackPanel) Children() []css.Styleable
Children returns all nested elements.
func (*StackPanel) Height ¶
func (v *StackPanel) Height() int
Height returns the height of the StackPanel.
func (*StackPanel) Measure ¶
func (v *StackPanel) Measure(availableWidth, availableHeight int) (width int, height int)
Measure gets the "wanted" size of the element based on the available size
func (*StackPanel) Name ¶
func (v *StackPanel) Name() string
Name returns the constant name of the StackPanel for css styling.
func (*StackPanel) Render ¶
func (v *StackPanel) Render(rn Renderer)
Render renders the element on the given Renderer
func (*StackPanel) Width ¶
func (v *StackPanel) Width() int
Width returns the width of the StackPanel
type Text ¶
type Text struct { BaseElement // contains filtered or unexported fields }
Text is an element which simply draws a static text.
type TextBorder ¶
type TextBorder struct { *Border // contains filtered or unexported fields }
TextBorder is a border with a text on the top left corner
func NewTextBorder ¶
func NewTextBorder(txt string, child Element) *TextBorder
NewTextBorder creates a new TextBorder with a given text and child
func (*TextBorder) Render ¶
func (b *TextBorder) Render(rn Renderer)
Render renders the element on the given Renderer
func (*TextBorder) SetText ¶
func (b *TextBorder) SetText(txt string)
SetText sets the text on the border
type TextBox ¶
type TextBox struct { BaseElement // contains filtered or unexported fields }
TextBox is an UI element which can be used to query text input from the user.
func (*TextBox) Arrange ¶
Arrange sets the final size for the Element end tells it to Arrange itself
func (*TextBox) DeleteRuneBackward ¶
func (tb *TextBox) DeleteRuneBackward()
DeleteRuneBackward deletes the rune before the current cursor position
func (*TextBox) DeleteRuneForward ¶
func (tb *TextBox) DeleteRuneForward()
DeleteRuneForward deletes the rune which is at the current cursor position
func (*TextBox) DeleteTheRestOfTheLine ¶
func (tb *TextBox) DeleteTheRestOfTheLine()
DeleteTheRestOfTheLine removes all text from the current position to the end of the text.
func (*TextBox) HandleKey ¶
HandleKey is called by the ui system if the element is asked to process a key.
func (*TextBox) InsertRune ¶
InsertRune inserts the rune at the current cursor position
func (*TextBox) MoveCursorOneRuneBackward ¶
func (tb *TextBox) MoveCursorOneRuneBackward()
MoveCursorOneRuneBackward moves the cursor one rune to the left.
func (*TextBox) MoveCursorOneRuneForward ¶
func (tb *TextBox) MoveCursorOneRuneForward()
MoveCursorOneRuneForward moves the cursor one rune to the right
func (*TextBox) MoveCursorToBeginningOfTheLine ¶
func (tb *TextBox) MoveCursorToBeginningOfTheLine()
MoveCursorToBeginningOfTheLine moves the cursor to the beginning of the text.
func (*TextBox) MoveCursorToEndOfTheLine ¶
func (tb *TextBox) MoveCursorToEndOfTheLine()
MoveCursorToEndOfTheLine moves the cursor to the end of the line
func (*TextBox) SetFocused ¶
SetFocused is called by the ui system to indicate that the element has the focus.
type ThicknessPropertyDefinition ¶
type ThicknessPropertyDefinition struct { Property *css.Property // contains filtered or unexported fields }
func NewThicknessProperty ¶
func NewThicknessProperty(name string) *ThicknessPropertyDefinition
func (*ThicknessPropertyDefinition) Get ¶
func (tp *ThicknessPropertyDefinition) Get(e Element) (res Thickness)
type WrapPanel ¶
type WrapPanel struct { BaseElement // contains filtered or unexported fields }
func NewWrapPanel ¶
func NewWrapPanel(o Orientation) *WrapPanel
func (*WrapPanel) Arrange ¶
Arrange sets the final size for the Element end tells it to Arrange itself
func (*WrapPanel) Measure ¶
Measure gets the "wanted" size of the element based on the available size