summaryrefslogtreecommitdiff
path: root/toolkit/andlabs/common.go
blob: 31b73e6cc15d37999d537172d7e819bf1d976f27 (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
package main

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

// This is important. This sets the defaults for the gui. Without this, there isn't correct padding, etc
func init() {
	// Can you pass values to a plugin init() ? Otherwise, there is no way to safely print
	// log(debugToolkit, "gui/toolkit init() Setting defaultBehavior = true")
	setDefaultBehavior(true)
}

func (t andlabsT) commonChange(tw *toolkit.Widget) {
	log(debugChange, "commonChange() START widget   =", t.Name, t.Type)
	if (tw == nil) {
		log(true, "commonChange() What the fuck. there is no widget t.tw == nil")
		return
	}
	if (tw.Custom == nil) {
		log(debugChange, "commonChange() END    Widget.Custom() = nil", t.tw.Name, t.tw.Type)
		return
	}
	tw.Custom()
	log(debugChange, "commonChange() END   Widget.Custom()", t.tw.Name, t.tw.Type)
}

// does some sanity checks on the internal structs of the binary tree
// TODO: probably this should not panic unless it's running in devel mode (?)
// TODO: redo this now that WidgetType is used and send() is used to package plugins
func (t *andlabsT) broken() bool {
	if (t.parent != nil) {
		return false
	}
	if (t.uiBox == nil) {
		if (t.uiWindow != nil) {
			log(debugToolkit, "UiBox == nil. This is an empty window. Try to add a box")
			t.NewBox()
			return false
		}
		log(true, "UiBox == nil. I can't add a widget without a place to put it")
		// log(debugToolkit, "probably could just make a box here?")
		// corruption or something horrible?
		t.Dump(true)
		panic("wit/gui toolkit/andlabs func broken() invalid goroutine access into this toolkit?")
		panic("wit/gui toolkit/andlabs func broken() this probably should not cause the app to panic here (?)")
		return true
	}
	if (t.uiWindow == nil) {
		log(debugToolkit, "UiWindow == nil. I can't add a widget without a place to put it (IGNORING FOR NOW)")
		t.Dump(debugToolkit)
		return false
	}
	return false
}
func broken(w *toolkit.Widget) bool {
	if (w == nil) {
		log(true, "widget == nil. I can't do anything widget")
		return true
	}
	return false
}