2024-01-18 00:05:54 -06:00
|
|
|
package tree
|
|
|
|
|
|
|
|
/*
|
|
|
|
There are some helper functions that are probably going to be
|
|
|
|
the same everywhere. Mostly due to handling the binary tree structure
|
|
|
|
and the channel communication
|
|
|
|
*/
|
|
|
|
|
|
|
|
import (
|
2024-01-18 04:08:11 -06:00
|
|
|
"go.wit.com/widget"
|
2024-01-18 00:05:54 -06:00
|
|
|
)
|
|
|
|
|
2024-01-18 04:08:11 -06:00
|
|
|
type TreeInfo struct {
|
2024-02-05 15:03:11 -06:00
|
|
|
PluginName string
|
2024-02-05 09:05:09 -06:00
|
|
|
|
2024-01-18 00:05:54 -06:00
|
|
|
// this is the channel we send user events like
|
|
|
|
// mouse clicks or keyboard events back to the program
|
|
|
|
callback chan widget.Action
|
|
|
|
|
|
|
|
// this is the channel we get requests to make widgets
|
|
|
|
pluginChan chan widget.Action
|
|
|
|
|
2024-02-05 15:03:11 -06:00
|
|
|
treeRoot *Node
|
2024-02-05 09:05:09 -06:00
|
|
|
// NodeI interface{}
|
|
|
|
|
2024-02-05 09:13:55 -06:00
|
|
|
// ActionFromChannel func(widget.Action)
|
2024-02-09 09:30:50 -06:00
|
|
|
NodeAction func(*Node, widget.ActionType)
|
|
|
|
Add func(*Node)
|
|
|
|
AddText func(*Node, string)
|
|
|
|
SetText func(*Node, string)
|
|
|
|
SetTitle func(*Node, string)
|
|
|
|
SetLabel func(*Node, string)
|
|
|
|
SetChecked func(*Node, bool)
|
2024-02-07 15:22:47 -06:00
|
|
|
ToolkitClose func()
|
2024-01-18 00:05:54 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
type Node struct {
|
2024-01-18 04:08:11 -06:00
|
|
|
Parent *Node
|
2024-01-18 00:05:54 -06:00
|
|
|
children []*Node
|
|
|
|
|
2024-01-18 04:08:11 -06:00
|
|
|
WidgetId int // widget ID
|
|
|
|
WidgetType widget.WidgetType
|
|
|
|
ParentId int // parent ID
|
2024-01-18 00:05:54 -06:00
|
|
|
|
2024-01-18 04:08:11 -06:00
|
|
|
State widget.State
|
2024-01-18 00:05:54 -06:00
|
|
|
|
2024-02-09 03:43:55 -06:00
|
|
|
ddStrings []string
|
2024-01-18 00:05:54 -06:00
|
|
|
|
|
|
|
// the internal plugin toolkit structure
|
|
|
|
// in the gtk plugin, it has gtk things like margin & border settings
|
|
|
|
// in the text console one, it has text console things like colors for menus & buttons
|
|
|
|
TK any
|
|
|
|
}
|