summaryrefslogtreecommitdiff
path: root/structs.go
blob: e4a5bb8c2282005016ad9c7f8e6caf956c74d53c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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 (
	"sync"

	"go.wit.com/lib/protobuf/guipb"
	"go.wit.com/widget"
)

// TODO: use protocol buffers

// this is the root node of the binary tree
// There is only one of these per application
var treeRoot *Node

type TreeInfo struct {
	sync.Mutex                        // a lock around the tree to serialize access
	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
	frozenChan    chan widget.Action  // expirement to get fyne to work
	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
	ToolkitInit   func()              // init the plugin
	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
	ShowTable     func(*guipb.Table)  // attempt at sending a whole table
	currentTables []*guipb.Table      // track the list of tables?
	// Root          *guipb.Tree         // this is the future of this system
}

type Node struct {
	Parent   *Node
	children []*Node

	WidgetId   int // widget ID
	WidgetType widget.WidgetType
	ParentId   int // parent ID

	State widget.State

	ddStrings []string

	// 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
}