summaryrefslogtreecommitdiff
path: root/redraw.go
blob: 0e3c03ae4f01230e0b695ca05943cb08fd666c1e (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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package gui

import (
	"git.wit.org/wit/gui/toolkit"
)

// This recreates the whole GUI for a plugin

func Redraw(s string) {
	var p *aplug
	log(logNow, "attempt to feed the binary tree to", s)
	for _, aplug := range allPlugins {
		log("Loaded plugin:", aplug.name, aplug.filename)
		if (aplug.name == s) {
			log("Found plugin:", aplug.name, aplug.filename)
			p = aplug
		}
	}
	if (p == nil) {
		log("Plugin", s, "is not loaded")
		return
	}
	Config.rootNode.Redraw(p)
}

// func (n *Node) ListChildren(dump bool, dropdown *Node, mapNodes map[string]*Node) {
func (n *Node) Redraw(p *aplug) {
	if (n == nil) {
		return
	}

	n.redo(p)
	for _, child := range n.children {
		child.Redraw(p)
	}
	return
}

func (n *Node) redo(plug *aplug) {
	log(logNow, "redo()", plug.name, n.id, n.WidgetType, n.Name)

	var a *toolkit.Action
	a = new(toolkit.Action)
	a.Name = n.Name
	a.Text = n.Text

	a.ActionType = toolkit.Add
	a.WidgetType = n.WidgetType
	a.WidgetId = n.id


	// used for Windows
	a.Width = n.Width
	a.Height = n.Height

	// used for anything that needs a range
	a.X = n.X
	a.Y = n.Y

	// used for grids and tables
//	a.NextX = n.NextX
//	a.NextY = n.NextY

	// used for values
	a.I = n.I
	a.S = n.S
	a.B = n.B

	if (n.parent == nil) {
		a.ParentId = 0
	} else {
		a.ParentId = n.parent.id
	}

	plug.pluginChan = plug.PluginChannel()

	// plug.Action(a)
	if (plug.pluginChan == nil) {
		log(debugNow, "Action() ERRRRRRROR pluginChan == nil", plug.name)
	} else {
		log(debugNow, "Action() SEND pluginChan", plug.name)
		log(debugNow, "Action() SEND pluginChan", plug.name)
		log(debugNow, "Action() SEND pluginChan", plug.name)
		plug.pluginChan <- *a
	}
	sleep(.5)
}