func (a *TreeToListAdapter) Count() int {
	return a.node.descendants
}
Count returns the total number of expanded nodes in the tree.
package mixins
import (
	"github.com/google/gxui"
	"github.com/google/gxui/math"
)
type TreeControlCreator interface {
	Create(theme gxui.Theme, control gxui.Control, node *TreeToListNode) gxui.Control
	Size(theme gxui.Theme, treeControlSize math.Size) math.Size
}
type TreeToListAdapter struct {
	gxui.AdapterBase
	node    TreeToListNode
	adapter gxui.TreeAdapter
	creator TreeControlCreator
}
func CreateTreeToListAdapter(treeAdapter gxui.TreeAdapter, creator TreeControlCreator) *TreeToListAdapter {
	listAdapter := &TreeToListAdapter{}
	listAdapter.node.depth = -1  
	listAdapter.node.container = treeAdapter
	listAdapter.adapter = treeAdapter
	listAdapter.creator = creator
	treeAdapter.OnDataReplaced(func() {
		listAdapter.reset()
		listAdapter.DataReplaced()
	})
	treeAdapter.OnDataChanged(func(recreateControls bool) {
		listAdapter.node.update(listAdapter)
		listAdapter.DataChanged(recreateControls)
	})
	listAdapter.reset()
	return listAdapter
}
func (a *TreeToListAdapter) adjustDescendants(delta int) {
	if delta != 0 {
		a.node.descendants += delta
		a.DataChanged(false)
	}
}
func (a *TreeToListAdapter) reset() {
	count := a.adapter.Count()
	a.node.descendants = count
	a.node.children = make([]*TreeToListNode, count)
	for i := range a.node.children {
		node := a.adapter.NodeAt(i)
		item := node.Item()
		a.node.children[i] = &TreeToListNode{container: node, item: item, parent: a}
	}
}