Feature#
func (tree *Tree) Feature(word string) ScopeFeature returns the top-level scope named by a page or overlay.
type Tree struct {
// contains filtered or unexported fields
}Tree is the set of places an application has named. The application owns one, and every canvas that paints its identities shares it; an embedded view is given a scope of the tree to build under, so it needs no translation between its identities and the page's.
A Tree is not safe for concurrent use: the window thread paints and handles events, and so uses it.
Feature#func (tree *Tree) Feature(word string) ScopeFeature returns the top-level scope named by a page or overlay.
FeatureOf#func (tree *Tree) FeatureOf(scope Scope) ScopeFeatureOf returns the page or overlay a scope is in.
ID#func (tree *Tree) ID(scope Scope, word string) IDID returns the identity of the control a word names in scope: the common way to declare one.
var hitAdd = tree.ID(proxies, "add")Len#func (tree *Tree) Len() intLen returns how many places the tree has named.
Local#func (tree *Tree) Local(mount Scope, id ID) (ID, bool)Local is the inverse of MountID: for an identity made by mounting a view at mount it returns the identity the view painted, which is how an event on an embedded view's control reaches that view's own handler. It reports false for an identity that was not made by mounting at mount. The zero mount is no mounting: the view is the page, and every identity is its own.
Mount#func (tree *Tree) Mount(mount, local Scope) ScopeMount returns where the place local of an embedded view sits when the view is mounted at mount. The view paints with identities of its own and does not know where it is placed: a session page is painted in every pane with the same controls. Mounting replays the view's path below mount, so the result is a place inside mount (Within says so) and the embedding canvas needs no translation tables or numeric windows. The first call for a place makes it; a later one is a lookup.
MountID#func (tree *Tree) MountID(mount Scope, id ID) IDMountID is Mount for an identity.
MountOf#func (tree *Tree) MountOf(scope Scope) (Scope, bool)MountOf returns the mount an identity's scope was made by, and false when it was not made by mounting. Nested mounts return the innermost.
Name#func (tree *Tree) Name(word string) NameName returns the name for a word, making it the first time the word is asked for. Call it when the program starts (a package-level variable), not while painting. A name from a word is never equal to an item's, or to another word's.
NameText#func (tree *Tree) NameText(name Name) stringNameText returns the word of a name made by Tree.Name, or "#n" for item n.
Parent#func (tree *Tree) Parent(scope Scope) ScopeParent returns the place scope is inside, and the zero Scope for a feature.
Path#func (tree *Tree) Path(scope Scope) stringPath writes a scope as the names that lead to it, such as "proxies/rows", for logs and test failures. It is not for painting: it allocates.
ScopeName#func (tree *Tree) ScopeName(scope Scope) NameScopeName returns the name a scope was made with: the number of a mount made for item i of a list, or the word of a page or a list.
Sub#func (tree *Tree) Sub(parent Scope, name Name) ScopeSub returns the scope of a list, a group or a dialog inside parent, making it the first time it is asked for. The zero parent is the root.
Text#func (tree *Tree) Text(id ID) stringText writes an identity as its path and name, such as "proxies/rows/#3" or "proxies/add", and an Item as "#n": for the headless driver's replies, logs and test failures. It allocates.
Within#func (tree *Tree) Within(scope, ancestor Scope) boolWithin reports whether scope is ancestor or a place below it, however deep. It is how a window-level handler hands an event to the page it belongs to.