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 (
|
2025-02-13 20:11:06 -06:00
|
|
|
"go.wit.com/lib/protobuf/guipb"
|
2024-01-18 04:08:11 -06:00
|
|
|
"go.wit.com/widget"
|
2024-01-18 00:05:54 -06:00
|
|
|
)
|
|
|
|
|
2025-02-02 13:03:44 -06:00
|
|
|
// TODO: use protocol buffers
|
|
|
|
|
2024-02-09 10:26:42 -06:00
|
|
|
// this is the root node of the binary tree
|
|
|
|
// There is only one of these per application
|
|
|
|
var treeRoot *Node
|
|
|
|
|
2024-01-18 04:08:11 -06:00
|
|
|
type TreeInfo struct {
|
2025-02-13 17:52:43 -06:00
|
|
|
ok bool // indicates the plugin actually initialized
|
|
|
|
PluginName string // used to identify the plugin
|
|
|
|
config *ToolkitConfigs // protobuf of plugin settings
|
|
|
|
callback chan widget.Action // mouse clicks or keyboard events back to the program
|
|
|
|
pluginChan chan widget.Action // this is the channel we get requests to make widgets
|
|
|
|
Add func(*Node) // add a new widget
|
|
|
|
AddText func(*Node, string) // add a string to a dropdown widget
|
|
|
|
SetText func(*Node, string) // set the text of a widget
|
|
|
|
SetTitle func(*Node, string) // update the title of a window or tab
|
|
|
|
SetLabel func(*Node, string) // update the "label" (aka "Name") for a widget
|
|
|
|
SetChecked func(*Node, bool) // set the state of a checkbox
|
|
|
|
ToolkitClose func() // shutdown and unload the plugin
|
|
|
|
Show func(*Node) // show a widget
|
|
|
|
Hide func(*Node) // hide a widget
|
|
|
|
Enable func(*Node) // enable a widget
|
|
|
|
Disable func(*Node) // disable a widget
|
2025-02-13 20:11:06 -06:00
|
|
|
ShowTable func(*guipb.Table) // attempt at sending a whole table
|
2025-02-12 15:43:58 -06:00
|
|
|
// NodeI interface{} // is an interface useful here?
|
2025-02-13 17:52:43 -06:00
|
|
|
// NodeAction func(*Node, widget.ActionType) // deprecate
|
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
|
|
|
|
}
|