summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--box.go10
-rw-r--r--debug.go13
-rw-r--r--gui.go2
-rw-r--r--new-structs.go14
-rw-r--r--structs.go2
-rw-r--r--tableCallbacks.go3
-rw-r--r--window.go30
7 files changed, 53 insertions, 21 deletions
diff --git a/box.go b/box.go
index 6b77912..51da1c5 100644
--- a/box.go
+++ b/box.go
@@ -35,6 +35,7 @@ func add(box *GuiBox, newbox *GuiBox) {
newbox.Window.BoxMap["MAINBOX"] = newbox
log.Println("gui.add() END")
+ panic("gui.add() MAINBOX gui.add() END")
return
} else {
log.Println("\tgui.add() ERROR DONT KNOW HOW TO ADD TO A RAW WINDOW YET")
@@ -42,6 +43,7 @@ func add(box *GuiBox, newbox *GuiBox) {
}
log.Println("\tgui.add() ERROR DON'T KNOW HOW TO add to Window as MAINBOX DONE")
log.Println("gui.add() END")
+ panic("gui.add() gui.add() END")
return
}
log.Println("\tgui.add() adding", newbox.Name, "to", box.Name)
@@ -57,15 +59,14 @@ func add(box *GuiBox, newbox *GuiBox) {
}
if (box.UiBox == nil) {
- }
-
- if (box.UiBox == nil) {
box.Dump()
+ // panic("gui.add() ERROR box.UiBox == nil")
return
// TODO: fix this whole add() function // Oct 9
- panic("gui.add() ERROR box.UiBox == nil")
}
box.UiBox.Append(newbox.UiBox, false)
+ box.Dump()
+ panic("gui.add()")
// add the newbox to the Window.BoxMap[]
box.Window.BoxMap[newbox.Name] = newbox
@@ -123,6 +124,7 @@ func NewBox(box *GuiBox, axis int, name string) *GuiBox {
uiBox.SetPadded(true)
newbox.UiBox = uiBox
add(box, newbox)
+ // panic("gui.NewBox")
return newbox
}
diff --git a/debug.go b/debug.go
index ce18b2d..e548b98 100644
--- a/debug.go
+++ b/debug.go
@@ -9,14 +9,13 @@ import (
"github.com/davecgh/go-spew/spew"
)
-// import "reflect"
-
-// import "github.com/andlabs/ui"
-// import _ "github.com/andlabs/ui/winmanifest"
-
-//
-// Dump out debugging information every 4 seconds
+// WatchGUI() opens a goroutine
//
+// From that goroutine, it dumps out debugging information every 4 seconds
+/*
+ TODO: add configuration triggers on what to dump out
+ TODO: allow this to be sent to /var/log, syslogd, systemd's journalctl, etc
+*/
func WatchGUI() {
count := 0
diff --git a/gui.go b/gui.go
index ccefa00..0c903b4 100644
--- a/gui.go
+++ b/gui.go
@@ -20,6 +20,8 @@ func init() {
Data.WindowMap = make(map[string]*GuiWindow)
Data.NodeMap = make(map[string]*Node)
+ Data.NodeSlice = make([]*Node, 0)
+
Config.counter = 0
Config.prefix = "jwc"
}
diff --git a/new-structs.go b/new-structs.go
index 397372c..d1ed875 100644
--- a/new-structs.go
+++ b/new-structs.go
@@ -130,10 +130,12 @@ func (n *Node) Append(child *Node) {
// return
// }
n.children = append(n.children, child)
- log.Println("child node:")
- child.Dump()
- log.Println("parent node:")
- n.Dump()
+ if (Config.Debug) {
+ log.Println("child node:")
+ child.Dump()
+ log.Println("parent node:")
+ n.Dump()
+ }
// time.Sleep(3 * time.Second)
}
@@ -275,7 +277,7 @@ func (parent *Node) AddTab(title string, uiC ui.Control) *Node {
parent.uiWindow.SetMargined(true)
parent.uiTab = inittab
- parent.Dump()
+ // parent.Dump()
// panic("gui.AddTab() ERROR uiTab == nil")
}
@@ -288,7 +290,9 @@ func (parent *Node) AddTab(title string, uiC ui.Control) *Node {
tab.Append(title, uiC)
tab.SetMargined(0, true)
+ // panic("gui.AddTab() before makeNode()")
newNode := parent.makeNode(title, 555, 600 + Config.counter)
newNode.uiTab = tab
+ // panic("gui.AddTab() after makeNode()")
return newNode
}
diff --git a/structs.go b/structs.go
index b7520d1..dca855f 100644
--- a/structs.go
+++ b/structs.go
@@ -42,6 +42,8 @@ type GuiData struct {
// Store access to everything via binary tree's
NodeMap map[string]*Node
+ NodeArray []*Node
+ NodeSlice []*Node
// A map of all buttons everywhere on all
// windows, all tabs, across all goroutines
diff --git a/tableCallbacks.go b/tableCallbacks.go
index 966f173..6eefd8d 100644
--- a/tableCallbacks.go
+++ b/tableCallbacks.go
@@ -30,7 +30,8 @@ func (mh *TableData) ColumnTypes(m *ui.TableModel) []ui.TableValue {
}
// TODO: Figure out why this is being called 1000 times a second (10 times for each row & column)
-// Nevermind this TODO. Who gives a shit. This is a really smart way to treat the OS toolkits
+//
+// Nevermind that TODO. Who gives a shit. This is a really smart way to treat the OS toolkits
func (mh *TableData) CellValue(m *ui.TableModel, row, column int) ui.TableValue {
if (Config.DebugTable) {
log.Println("CellValue() row, column =", row, column)
diff --git a/window.go b/window.go
index 3543b2b..4940e35 100644
--- a/window.go
+++ b/window.go
@@ -2,6 +2,7 @@ package gui
import (
"log"
+ "fmt"
"strconv"
"time"
@@ -257,16 +258,24 @@ func makeNode(parent *Node, title string, x int, y int) *Node {
Config.counter += 1
node.id = id
+ // panic("gui.makeNode() START")
if (parent == nil) {
if (Data.NodeMap[title] != nil) {
log.Println("Duplicate uiNewWindow() name =", title)
// TODO: just change the 'title' to something unique
+ panic(fmt.Sprintf("Duplicate uiNewWindow() name = %s\n", title))
return nil
}
+ // panic("gui.makeNode() before NodeMap()")
Data.NodeMap[title] = &node
+ Data.NodeArray = append(Data.NodeArray, &node)
+ Data.NodeSlice = append(Data.NodeSlice, &node)
+ // panic("gui.makeNode() after NodeMap()")
return &node
} else {
+ panic("gui.makeNode() before Append()")
parent.Append(&node)
+ panic("gui.makeNode() after Append()")
}
node.parent = parent
return &node
@@ -326,14 +335,28 @@ func (n *Node) initBlankWindow() ui.Control {
return hbox
}
-var master = 0
+func makeBlankNode(title string) *Node {
+ log.Println("gui.makeBlankNode() title =", title)
+ if Data.NodeMap[title] != nil {
+ log.Println("gui.makeBlankNode() already exists title =", title)
+ title = title + Config.prefix + strconv.Itoa(Config.counter)
+ Config.counter += 1
+ }
+ if Data.NodeMap[title] != nil {
+ panic("gui.makeBlankNode() already exists")
+ return nil
+ }
+
+ node := makeNode(nil, title, x, y)
+ return node
+}
func mapWindow(parent *Node, window *ui.Window, title string, x int, y int) *Node {
log.Println("gui.WindowMap START title =", title)
if Data.WindowMap[title] != nil {
log.Println("Data.WindowMap[title] already exists title =", title)
- master = master + 1
- title = title + " jcarr " + strconv.Itoa(master)
+ title = title + Config.prefix + strconv.Itoa(Config.counter)
+ Config.counter += 1
}
if Data.WindowMap[title] != nil {
log.Println("Data.WindowMap[title] already exists title =", title)
@@ -357,7 +380,6 @@ func mapWindow(parent *Node, window *ui.Window, title string, x int, y int) *Nod
box.Window = &newGuiWindow
box.Name = title
- // func makeNode(parent *Node, title string, x int, y int) *Node {
node := makeNode(parent, title, x, y)
node.box = &box
node.uiWindow = window