summaryrefslogtreecommitdiff
path: root/tab.go
blob: 72dcd17e9f1ac447cfe1c9a0fe877156aebb9377 (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
package gui

import (
	"log"
	"os"

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

// import toolkit "git.wit.org/wit/gui/toolkit/andlabs"

// This function should make a new node with the parent and
// the 'tab' as a child

func (n *Node) NewTab(title string) *Node {
	log.Println("gui.Node.AddTab() START name =", title)

	return n.AddTabNew(title)
}

func (n *Node) AddTabNew(title string) *Node {
	log.Println("gui.Node.AddTab() START name =", title)

	if (n.Toolkit == nil) {
		log.Println("FUCK TOOLKIT nil uiWindow =", n.uiWindow)
		log.Println("FUCK TOOLKIT nil uiTab =", n.uiTab)
		log.Println("FUCK TOOLKIT nil Toolkit =", n.Toolkit)
		// return n.AddTab(title) // need to make a toolkit here
		n.Dump()
		os.Exit(0)
	}
	log.Println("Make new node")
	newN := n.New(title)
	log.Println("Add tab to window")
	t := n.Toolkit.AddTab(title)
	newN.Toolkit = t

	n.Append(newN)
	return newN
}

func (n *Node) AddTab(title string, uiC *ui.Box) *Node {
	return n.AddTabNew(title)
}
/*
func (n *Node) AddTabBAD(title string, uiC *ui.Box) *Node {
	parent := n
	log.Println("gui.Node.AddTab() START name =", title)
	if parent.uiWindow == nil {
		parent.Dump()
		log.Println("gui.Node.AddTab() ERROR ui.Window == nil")
		return nil
	}
	if parent.uiTab == nil {
		inittab := ui.NewTab() // no, not that 'inittab'
		parent.uiWindow.SetChild(inittab)
		parent.uiWindow.SetMargined(true)
		parent.uiTab = inittab
	}
	tab := parent.uiTab
	parent.uiWindow.SetMargined(true)

	if (uiC == nil) {
		hbox := ui.NewHorizontalBox()
		hbox.SetPadded(true)
		uiC = hbox
	}
	tab.Append(title, uiC)

	newNode := n.New(title)
	newNode.uiTab = tab
	newNode.uiBox = uiC
	// tabSetMargined(newNode.uiTab)
	return newNode
}
*/