Documentation ¶
Overview ¶
Package tree is a widget that displays a collection of widgets organized in a tree structure.
Index ¶
- func AddWalkerCallback(c gowid.ICallbacks, name interface{}, cb IWalkerCallback)
- func ConfirmPosition(tp IPos, tree IModel) bool
- func IsSubPosition(outer IPos, inner IPos) bool
- func New(walker list.IWalker) *list.Widget
- func RemoveWalkerCallback(c gowid.ICallbacks, name interface{}, id gowid.IIdentity)
- func RunWalkerCallbacks(c gowid.ICallbacks, name interface{}, app gowid.IApp, data ...interface{})
- func WalkerNext(f ITreeWalker, pos list.IWalkerPosition) list.IWalkerPosition
- func WalkerPrevious(f ITreeWalker, pos list.IWalkerPosition) list.IWalkerPosition
- func WidgetAt(walker ITreeWalker, pos IPos) gowid.IWidget
- type CacheKey
- type CachingDecorator
- type CachingDecoratorOptions
- type CachingMaker
- type CachingMakerOptions
- type Collapsed
- type CollapsedFunction
- type Collapsible
- func (t *Collapsible) AddOnCollapsed(name interface{}, cb ICollapsedCallback)
- func (t *Collapsible) AddOnExpanded(name interface{}, cb IExpandedCallback)
- func (t *Collapsible) Children() IIterator
- func (t *Collapsible) IsCollapsed() bool
- func (t *Collapsible) RemoveOnCollapsed(name interface{})
- func (t *Collapsible) RemoveOnExpanded(name interface{})
- func (t *Collapsible) SetCollapsed(app gowid.IApp, collapsed bool)
- func (t *Collapsible) String() string
- type DecoratorFunction
- type Expanded
- type ExpandedFunction
- type ICollapsedCallback
- type ICollapsible
- type IDecorator
- type IExpandedCallback
- type IIterator
- type IModel
- type IPos
- func DepthFirstSearch(tree IModel, fn ISearchPred) IPos
- func FirstChildPosition(tp IPos, tree IModel) IPos
- func LastChildPosition(tp IPos, tree IModel) IPos
- func LastDescendant(tp IPos, tree IModel) IPos
- func LastInDirection(tp IPos, tree IModel, f func(IPos, IModel) IPos) IPos
- func NextOfKin(tp IPos, tree IModel) IPos
- func NextPosition(tp IPos, tree IModel) IPos
- func NextSiblingPosition(tp IPos, tree IModel) IPos
- func ParentPosition(tp IPos) IPos
- func PreviousPosition(tp IPos, tree IModel) IPos
- func PreviousSiblingPosition(tp IPos, tree IModel) IPos
- type ISearchPred
- type ITreeWalker
- type IWalkerCallback
- type IWidgetMaker
- type SearchPred
- type Tree
- type TreePos
- func (tp *TreePos) Copy() IPos
- func (tp *TreePos) Equal(other list.IWalkerPosition) bool
- func (tp *TreePos) GetSubStructure(tree IModel) IModel
- func (tp *TreePos) GreaterThan(other list.IWalkerPosition) bool
- func (tp *TreePos) Indices() []int
- func (tp *TreePos) SetIndices(indices []int)
- func (tp *TreePos) String() string
- type TreeWalker
- func (f *TreeWalker) At(pos list.IWalkerPosition) gowid.IWidget
- func (f *TreeWalker) Decorator() IDecorator
- func (f *TreeWalker) Focus() list.IWalkerPosition
- func (f *TreeWalker) Maker() IWidgetMaker
- func (f *TreeWalker) Next(pos list.IWalkerPosition) list.IWalkerPosition
- func (t *TreeWalker) OnFocusChanged(f IWalkerCallback)
- func (f *TreeWalker) Previous(pos list.IWalkerPosition) list.IWalkerPosition
- func (t *TreeWalker) RemoveOnFocusChanged(f gowid.IIdentity)
- func (f *TreeWalker) SetFocus(pos list.IWalkerPosition, app gowid.IApp)
- func (f *TreeWalker) Tree() IModel
- type WalkerCallback
- type WalkerFunction
- type WidgetMakerFunction
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddWalkerCallback ¶
func AddWalkerCallback(c gowid.ICallbacks, name interface{}, cb IWalkerCallback)
func ConfirmPosition ¶
ConfirmPosition returns true if there is a tree at position tp of argument tree.
func IsSubPosition ¶
func RemoveWalkerCallback ¶
func RemoveWalkerCallback(c gowid.ICallbacks, name interface{}, id gowid.IIdentity)
func RunWalkerCallbacks ¶
func RunWalkerCallbacks(c gowid.ICallbacks, name interface{}, app gowid.IApp, data ...interface{})
func WalkerNext ¶
func WalkerNext(f ITreeWalker, pos list.IWalkerPosition) list.IWalkerPosition
func WalkerPrevious ¶
func WalkerPrevious(f ITreeWalker, pos list.IWalkerPosition) list.IWalkerPosition
Types ¶
type CacheKey ¶
CacheKey tracks content for a given tree and its expansion state. Note tree position isn't tracked in case objects are inserted into the tree in such a way that the position moves.
type CachingDecorator ¶
type CachingDecorator struct { IDecorator // contains filtered or unexported fields }
func NewCachingDecorator ¶
func NewCachingDecorator(dec IDecorator, opts ...CachingDecoratorOptions) *CachingDecorator
func (*CachingDecorator) MakeDecoration ¶
func (d *CachingDecorator) MakeDecoration(pos IPos, tree IModel, wmaker IWidgetMaker) gowid.IWidget
type CachingDecoratorOptions ¶
type CachingDecoratorOptions struct {
CacheSize int
}
type CachingMaker ¶
type CachingMaker struct { IWidgetMaker // contains filtered or unexported fields }
func NewCachingMaker ¶
func NewCachingMaker(dec IWidgetMaker, opts ...CachingMakerOptions) *CachingMaker
func (*CachingMaker) MakeWidget ¶
func (d *CachingMaker) MakeWidget(pos IPos, tree IModel) gowid.IWidget
type CachingMakerOptions ¶
type CachingMakerOptions struct {
CacheSize int
}
type CollapsedFunction ¶
func (CollapsedFunction) Collapsed ¶
func (f CollapsedFunction) Collapsed(app gowid.IApp)
type Collapsible ¶
type Collapsible struct { *Tree Callbacks *gowid.Callbacks // contains filtered or unexported fields }
func NewCollapsible ¶
func NewCollapsible(leaf string, children []IModel) *Collapsible
func (*Collapsible) AddOnCollapsed ¶
func (t *Collapsible) AddOnCollapsed(name interface{}, cb ICollapsedCallback)
func (*Collapsible) AddOnExpanded ¶
func (t *Collapsible) AddOnExpanded(name interface{}, cb IExpandedCallback)
func (*Collapsible) Children ¶
func (t *Collapsible) Children() IIterator
func (*Collapsible) IsCollapsed ¶
func (t *Collapsible) IsCollapsed() bool
func (*Collapsible) RemoveOnCollapsed ¶
func (t *Collapsible) RemoveOnCollapsed(name interface{})
func (*Collapsible) RemoveOnExpanded ¶
func (t *Collapsible) RemoveOnExpanded(name interface{})
func (*Collapsible) SetCollapsed ¶
func (t *Collapsible) SetCollapsed(app gowid.IApp, collapsed bool)
func (*Collapsible) String ¶
func (t *Collapsible) String() string
type DecoratorFunction ¶
type DecoratorFunction func(pos IPos, tree IModel, wmaker IWidgetMaker) gowid.IWidget
func (DecoratorFunction) MakeDecoration ¶
func (f DecoratorFunction) MakeDecoration(pos IPos, tree IModel, wmaker IWidgetMaker) gowid.IWidget
type ExpandedFunction ¶
func (ExpandedFunction) Expanded ¶
func (f ExpandedFunction) Expanded(app gowid.IApp)
type ICollapsedCallback ¶
type ICollapsible ¶
type IDecorator ¶
type IDecorator interface {
MakeDecoration(pos IPos, tree IModel, wmaker IWidgetMaker) gowid.IWidget
}
type IExpandedCallback ¶
type IPos ¶
type IPos interface { GetSubStructure(IModel) IModel Copy() IPos Indices() []int SetIndices([]int) Equal(list.IWalkerPosition) bool GreaterThan(list.IWalkerPosition) bool fmt.Stringer }
IPos is the interface of a type that represents the position of a sub-tree or leaf in a tree.
nil means invalid [] means the root of the tree [0] means 0th child of root [3] means 3rd child of root [1,2] means 2nd child of 1st child of root
func DepthFirstSearch ¶ added in v1.4.0
func DepthFirstSearch(tree IModel, fn ISearchPred) IPos
func FirstChildPosition ¶
FirstChildPosition returns the IPos corresponding to the first child of tp, or nil if there are no children.
func LastChildPosition ¶
LastChildPosition returns the IPos corresponding to the last child of tp, or nil if there are no children.
func LastDescendant ¶
LastDescendant moves to the last child of the current level, and then to the last child of that node, and onwards until the end is reached.
func LastInDirection ¶
LastInDirection navigates the tree starting at tp and moving in the direction determined by the function f until the end is reached. The function returns the last position that was passed through.
func NextOfKin ¶
NextOfKin returns the position of the sibling of the parent of tp if that position exists, and if not, the sibling of the parent's parent, and on upwards. If the next of kin is not found, nil is returned.
func NextPosition ¶
NextPosition is used to navigate the tree in a depth first manner. Starting at the current position, the first child is selected. If there isn't one, then the current node's sibling is selected. If there isn't one, then the "next of kin" is selected.
func NextSiblingPosition ¶
NextSiblingPosition returns the position of the next sibling relative to the position tp.
func ParentPosition ¶
ParentPosition returns the position of the parent of position tp or nil if tp is the root node.
func PreviousPosition ¶
PreviousPosition is used to navigate the tree backwards in a depth first manner.
func PreviousSiblingPosition ¶
PreviousSiblingPosition returns the position of the previous sibling relative to the position tp.
type ISearchPred ¶ added in v1.4.0
type ITreeWalker ¶
type ITreeWalker interface { Tree() IModel Maker() IWidgetMaker Decorator() IDecorator Focus() list.IWalkerPosition }
type IWalkerCallback ¶
type IWalkerCallback interface { gowid.IIdentity Changed(app gowid.IApp, tree ITreeWalker, data ...interface{}) }
type SearchPred ¶ added in v1.4.0
type Tree ¶
type Tree struct {
// contains filtered or unexported fields
}
func (*Tree) GetChildren ¶
func (*Tree) SetChildren ¶
type TreePos ¶
type TreePos struct {
Pos []int
}
TreePos is a simple implementation of IPos.
func (*TreePos) GetSubStructure ¶
GetSubStructure returns the (sub-)Tree at this position from the tree argument provided.
func (*TreePos) GreaterThan ¶
func (tp *TreePos) GreaterThan(other list.IWalkerPosition) bool
func (*TreePos) SetIndices ¶
type TreeWalker ¶
type TreeWalker struct { *gowid.Callbacks gowid.FocusCallbacks // contains filtered or unexported fields }
func NewWalker ¶
func NewWalker(tree IModel, pos IPos, maker IWidgetMaker, dec IDecorator) *TreeWalker
func (*TreeWalker) At ¶
func (f *TreeWalker) At(pos list.IWalkerPosition) gowid.IWidget
list.IWalker
func (*TreeWalker) Decorator ¶
func (f *TreeWalker) Decorator() IDecorator
func (*TreeWalker) Maker ¶
func (f *TreeWalker) Maker() IWidgetMaker
func (*TreeWalker) Next ¶
func (f *TreeWalker) Next(pos list.IWalkerPosition) list.IWalkerPosition
list.IWalker
func (*TreeWalker) OnFocusChanged ¶
func (t *TreeWalker) OnFocusChanged(f IWalkerCallback)
func (*TreeWalker) Previous ¶
func (f *TreeWalker) Previous(pos list.IWalkerPosition) list.IWalkerPosition
list.IWalker
func (*TreeWalker) RemoveOnFocusChanged ¶
func (t *TreeWalker) RemoveOnFocusChanged(f gowid.IIdentity)
func (*TreeWalker) SetFocus ¶
func (f *TreeWalker) SetFocus(pos list.IWalkerPosition, app gowid.IApp)
func (*TreeWalker) Tree ¶
func (f *TreeWalker) Tree() IModel
type WalkerCallback ¶
type WalkerCallback struct { Name interface{} WalkerFunction }
WidgetCallback is a simple struct with a name field for IIdentity and that embeds a WidgetChangedFunction to be issued as a callback when a widget property changes.
func MakeCallback ¶
func MakeCallback(name interface{}, fn WalkerFunction) WalkerCallback
func (WalkerCallback) ID ¶
func (f WalkerCallback) ID() interface{}
type WalkerFunction ¶
type WalkerFunction func(app gowid.IApp, tree ITreeWalker)
func (WalkerFunction) Changed ¶
func (f WalkerFunction) Changed(app gowid.IApp, tree ITreeWalker, data ...interface{})
type WidgetMakerFunction ¶
func (WidgetMakerFunction) MakeWidget ¶
func (f WidgetMakerFunction) MakeWidget(pos IPos, tree IModel) gowid.IWidget