summaryrefslogtreecommitdiff
path: root/smartwindow/preReady.go
blob: 5009d54db7619220bf153eae714a885aeaafc12f (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
// these are things you can config
package smartwindow

import 	(
	"go.wit.com/log"
	"go.wit.com/gui/gui"
)

/*	for now, run these before the window is ready
	That is, they all start with:

	if ! sw.Initialized() {return}
	if sw.Ready() {return}
*/

func (sw *SmartWindow) Title(title string) {
	if ! sw.Initialized() {return}
	if sw.Ready() {return}

	log.Log(WARN, "Title() =", title)
	sw.title = title
}

func (sw *SmartWindow) SetParent(p *gui.Node) {
	if ! sw.Initialized() {return}
	if sw.Ready() {return}

	log.Log(WARN, "SetParent")
	if sw.parent == nil {
		log.Log(WARN, "SetParent =", p)
		sw.parent = p
		return
	} else {
		log.Log(WARN, "SetParent was already set. TODO: Move to new parent")
	}
}

func (sw *SmartWindow) SetDraw(f func(*SmartWindow)) {
	if ! sw.Initialized() {return}
	if sw.Ready() {return}

	sw.populate = f
}

func (sw *SmartWindow) Make() {
	if ! sw.Initialized() {return}
	if sw.Ready() {return}

	log.Log(WARN, "Make() window ready =", sw.ready)
	sw.window.Make()
	if (sw.populate != nil) {
		log.Log(WARN, "Make() trying to run Custom sw.populate() here")
		sw.populate(sw)
	}
	sw.ready = true
}

func (sw *SmartWindow) Draw() {
	if ! sw.Initialized() {return}
	if sw.Ready() {return}

	log.Log(WARN, "Draw() window ready =", sw.ready)
	sw.window.Draw()
	if (sw.populate != nil) {
		log.Log(WARN, "Make() trying to run Custom sw.populate() here")
		sw.populate(sw)
	}
	sw.ready = true
}


func (sw *SmartWindow) Vertical() {
	if ! sw.Initialized() {return}
	if sw.Ready() {return}

	log.Log(WARN, "Draw() window ready =", sw.ready)
	sw.window.Draw()
	if (sw.populate != nil) {
		log.Log(WARN, "Make() trying to run Custom sw.populate() here")
		sw.populate(sw)
	}
	sw.ready = true
}