Documentation ¶
Overview ¶
package attribute contains property for view interface.
Index ¶
- Constants
- Variables
- func ColorOfName(name string) (uint32, bool)
- type Alignment
- type Attributes
- type Colors
- type Edge
- type LayoutData
- func NewFixedSplit(e Edge, fixedC, restC *LayoutData) *LayoutData
- func NewFlowHorizontal(ls ...*LayoutData) *LayoutData
- func NewFlowVertical(ls ...*LayoutData) *LayoutData
- func NewSingleImage(src string) *LayoutData
- func NewSingleText(name string) *LayoutData
- func WithParentValue(l *LayoutData, v interface{}) *LayoutData
- func WithValue(l *LayoutData, v interface{}) *LayoutData
- type LayoutType
Constants ¶
const ( DefaultColorFg = 0xffffff // white DefaultColorBg = 0x000000 // black )
const ( EdgeNone = iota EdgeLeft EdgeRight EdgeTop EdgeBottom )
Variables ¶
var DefaultColors = Colors{DefaultColorFg, DefaultColorBg}
default colors.
var HTMLColorTable = map[string]uint32{}/* 148 elements not displayed */
html color name to hex color table
Functions ¶
func ColorOfName ¶
get hex color of given name. if not found return black
Types ¶
type Colors ¶
type Colors struct {
Fg, Bg uint32
}
Colors has foreground and background 16bit color as like 0xRRGGBB.
type LayoutData ¶
type LayoutData struct { Type LayoutType Children []*LayoutData // ParentValue is sepecified by its' Parent LayoutData, for example, // Flow references a weight for each child to layout its children. // Value is sepecified by itself, such as Image's source name. // // Since these are interface{} and data type is undefined, // use utility functions to get a specific value after // LayoutData's Type is detected. ParentValue, Value interface{} }
LayoutData is a plan of Layouting which is defined by its Type and children. It can construct LayoutData tree to build complex layout structure.
func NewFixedSplit ¶
func NewFixedSplit(e Edge, fixedC, restC *LayoutData) *LayoutData
return FixedVertical LayoutData with its children. it will be occurs panic if first child fixedC has no fixed size. To specify fixed size for first child, use: fixedC = WithChildValue(fixedC, size).
func NewFlowHorizontal ¶
func NewFlowHorizontal(ls ...*LayoutData) *LayoutData
return FlowHorizontal LayoutData with its children. no children occurs panic. each child may have a weight to fill Flow's space. weight is set by using WithChildValue(child, weight).
func NewFlowVertical ¶
func NewFlowVertical(ls ...*LayoutData) *LayoutData
return FlowVertical LayoutData with its children. no children occurs panic. each child may have a weight to fill Flow's space. weight is set by using WithChildValue(child, weight).
func NewSingleImage ¶
func NewSingleImage(src string) *LayoutData
return SingleImage LayoutData with image source name.
func NewSingleText ¶
func NewSingleText(name string) *LayoutData
return SingleText LayoutData with a uniq name for it.
func WithParentValue ¶
func WithParentValue(l *LayoutData, v interface{}) *LayoutData
set a value which is used by its parent LayoutData. return given LayoutData itself after set value.
func WithValue ¶
func WithValue(l *LayoutData, v interface{}) *LayoutData
set a value which is used by itself. return given LayoutData itself after set value.
func (*LayoutData) FixedChildSize ¶
func (l *LayoutData) FixedChildSize() int
get a size from a child LayoutData of Fixed. a size means string width or line count for horizontal or vertical respectively.
func (*LayoutData) FixedEdge ¶
func (l *LayoutData) FixedEdge() Edge
get a edge type from a LayoutData of FixedSplit.
func (*LayoutData) FlowChildWeight ¶
func (l *LayoutData) FlowChildWeight() int
get a weight from a child LayoutData of LayoutData type Flow.
flow := LayoutData{Type: TypeFlowVertical, Children: ... } for _, c := range flow.Children { weight := c.FlowChildWeight() }
func (*LayoutData) SingleImageSrc ¶
func (l *LayoutData) SingleImageSrc() string
get source name from LayoutData of type SingleImage.
func (*LayoutData) SingleTextName ¶
func (l *LayoutData) SingleTextName() string
get a uniq name from LayoutData of type SingleText.
type LayoutType ¶
type LayoutType uint32
LayoutType indicates a type of layout.
const ( // * Single // Single has only one window and the implemetation for content view. // it *MUST* have specific value to define its content. // - TypeSingleText has a Value as Name to identify text windows. // - TypeSingleImage has a Value as Src to detect what image to show. // // single window showing text. TypeSingleText LayoutType = iota // single window showing image TypeSingleImage // * Flow // Flow has auto resized multiple windows aligend by its direction, horizontal or vertical. // its each child can have weight (int) to indicate how much child fill Flow's area. // If any child has no weight, zero or not set, all of children set 1 weight so that // the Flow's area is distributed equlitity. // a space of acrossing direction of Flow is filled to max size of Flow. // For example, If FlowHorizontal has width 100 (unit is unknown) and its 3 Children have // weights 6, 3 and 1, these children have width 60, 30 and 10. // // A 0 weight means a child will be not showed on screen but exist. // Remenber that set weight for all children if any child has weight. // // auto resized multiple window, align vertically. TypeFlowVertical // auto resized multiple window, align horizontally TypeFlowHorizontal // * FixedSplit // FixedSplit has 2 children, fixed sized child close to specific Edge and // fluided sized child at away from the Edge. // Split line's axis is same as Edge. // its first child must have size (int) to indicate how much first child fill the area. // a size means string width or line count for horizontal or vertical respectively. // a space along the Edge is filled to max size of Fixed. // For example, If FixedSplit had EdgeTop and 2 Children, and the first had fixed size 40, // first child has line count 40 and the second has rest of Fixed. TypeFixedSplit )