summaryrefslogtreecommitdiff
path: root/common.go
blob: c70356e29b471c1f8314c339be518fd253427a59 (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
package repostatus

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

// reports externally if something has changed
// since the last time it was asked about it
func (ls *RepoStatus) Changed() bool {
	if ! ls.Ready() {return false}
	if ls.changed {
		ls.changed = false
		return true
	}
	return false
}

func (ls *RepoStatus) Make() {
	if ! ls.Ready() {return}
	log.Log(CHANGE, "Make() window ready =", ls.ready)
	ls.window.Make()
	ls.ready = true
}
func (ls *RepoStatus) Draw() {
	if ! ls.Ready() {return}
	log.Log(CHANGE, "Draw() window ready =", ls.ready)
	ls.window.Draw()
	ls.ready = true
}
func (ls *RepoStatus) Draw2() {
	if ! ls.Ready() {return}
	log.Log(CHANGE, "draw(ls) ready =", ls.ready)
	draw(ls)
}

func (ls *RepoStatus) Show() {
	if ! ls.Ready() {return}
	log.Log(CHANGE, "Show() window ready =", ls.ready)
	ls.window.Show()
	ls.hidden = false
}

func (ls *RepoStatus) Hide() {
	if ! ls.Ready() {return}
	log.Log(CHANGE, "Hide() window ready =", ls.ready)
	ls.window.Hide()
	ls.hidden = true
}

func (ls *RepoStatus) Toggle() {
	if ! ls.Ready() {return}
	log.Log(CHANGE, "Toggle() window ready =", ls.ready)
	if ls.hidden {
		ls.Show()
	} else {
		ls.Hide()
	}
}

func (ls *RepoStatus) Ready() bool {
	log.Log(SPEW, "Ready() maybe not ready? ls =", ls)
	if ls == nil {return false}
	if ls.window == nil {return false}
	return ls.ready
}

func (ls *RepoStatus) Initialized() bool {
	log.Log(CHANGE, "checking Initialized()")
	if ls == nil {return false}
	if ls.parent == nil {return false}
	return true
}

func (ls *RepoStatus) SetParent(p *gui.Node) {
	log.Log(CHANGE, "Attempting SetParent")
	if ls == nil {return}
	if ls.parent == nil {
		log.Log(CHANGE, "SetParent =", p)
		ls.parent = p
		return
	} else {
		log.Log(CHANGE, "SetParent was already set to =", ls.parent)
	}
}