summaryrefslogtreecommitdiff
path: root/toolkit/andlabs2/box.go
blob: bb9945e629fa0f202a5e2bc1c3bd605045f8ca7e (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
package main

import "log"

import "github.com/andlabs/ui"
import _ "github.com/andlabs/ui/winmanifest"

// create a new box
func (t *andlabsT) GetBox() *ui.Box {
	return t.uiBox
}

// create a new box
func (t *andlabsT) NewBox() *andlabsT {
	if (DebugToolkit) {
		log.Println("gui.Toolbox.NewBox() START create default")
	}
	t.Dump()
	if (t.uiGroup != nil) {
		if (DebugToolkit) {
			log.Println("\tgui.Toolbox.NewBox() is a Group")
		}
		var newTK andlabsT

		vbox := ui.NewVerticalBox()
		vbox.SetPadded(padded)
		t.uiGroup.SetChild(vbox)
		newTK.uiBox = vbox

		return &newTK
	}
	if (t.uiBox != nil) {
		if (DebugToolkit) {
			log.Println("\tgui.Toolbox.NewBox() is a Box")
		}
		var newTK andlabsT

		vbox := ui.NewVerticalBox()
		vbox.SetPadded(padded)
		t.uiBox.Append(vbox, stretchy)
		newTK.uiBox = vbox
		newTK.Name = t.Name

		return &newTK
	}
	if (t.uiWindow != nil) {
		if (DebugToolkit) {
			log.Println("\tgui.Toolbox.NewBox() is a Window")
		}
		var newT andlabsT

		vbox := ui.NewVerticalBox()
		vbox.SetPadded(padded)
		t.uiWindow.SetChild(vbox)
		newT.uiBox = vbox
		newT.Name = t.Name

		// panic("WTF")
		return &newT
	}
	if (DebugToolkit) {
		log.Println("\tgui.Toolbox.NewBox() FAILED. Couldn't figure out where to make a box")
	}
	t.Dump()
	return nil
}