2019-05-24 02:53:34 -05:00
|
|
|
package gui
|
|
|
|
|
2021-10-06 11:50:35 -05:00
|
|
|
import (
|
|
|
|
"fmt"
|
2021-10-07 12:04:48 -05:00
|
|
|
"os"
|
2021-10-06 11:50:35 -05:00
|
|
|
"log"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/davecgh/go-spew/spew"
|
|
|
|
)
|
|
|
|
|
2019-06-13 14:08:47 -05:00
|
|
|
// import "reflect"
|
2019-05-24 02:53:34 -05:00
|
|
|
|
2019-06-02 08:39:48 -05:00
|
|
|
// import "github.com/andlabs/ui"
|
|
|
|
// import _ "github.com/andlabs/ui/winmanifest"
|
2019-05-24 02:53:34 -05:00
|
|
|
|
2019-06-01 23:15:55 -05:00
|
|
|
//
|
2021-10-06 11:50:35 -05:00
|
|
|
// Dump out debugging information every 4 seconds
|
2019-06-01 23:15:55 -05:00
|
|
|
//
|
|
|
|
func WatchGUI() {
|
|
|
|
count := 0
|
|
|
|
|
|
|
|
for {
|
2021-10-06 11:50:35 -05:00
|
|
|
if count > 20 {
|
2019-06-03 00:22:04 -05:00
|
|
|
log.Println("Sleep() in watchGUI()")
|
2021-10-06 11:50:35 -05:00
|
|
|
if Config.Debug {
|
2019-06-03 14:56:33 -05:00
|
|
|
DumpBoxes()
|
2019-06-01 23:15:55 -05:00
|
|
|
}
|
|
|
|
count = 0
|
|
|
|
}
|
|
|
|
count += 1
|
|
|
|
time.Sleep(200 * time.Millisecond)
|
|
|
|
}
|
|
|
|
}
|
2019-06-02 14:08:53 -05:00
|
|
|
|
2021-10-07 01:37:37 -05:00
|
|
|
func DumpWindows() {
|
|
|
|
for name, _ := range Data.WindowMap {
|
|
|
|
log.Println("gui.DumpWindows() window =", name)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-05 10:37:53 -05:00
|
|
|
func DumpMap() {
|
2021-10-06 13:23:00 -05:00
|
|
|
for name, window := range Data.WindowMap {
|
2021-10-05 10:37:53 -05:00
|
|
|
log.Println("gui.DumpBoxes() MAP: ", name)
|
2021-10-06 13:23:00 -05:00
|
|
|
log.Println("gui.DumpBoxes() BOXES:", name)
|
|
|
|
for name, abox := range window.BoxMap {
|
|
|
|
log.Printf("gui.DumpBoxes() \tBOX mapname=%-12s abox.Name=%-12s", name, abox.Name)
|
|
|
|
}
|
2021-10-05 10:37:53 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-03 14:56:33 -05:00
|
|
|
func DumpBoxes() {
|
2019-06-03 17:45:40 -05:00
|
|
|
for name, window := range Data.WindowMap {
|
2019-06-13 14:08:47 -05:00
|
|
|
log.Println("gui.DumpBoxes() MAP: ", name)
|
2021-10-06 11:50:35 -05:00
|
|
|
if window.TabNumber == nil {
|
2019-06-13 14:08:47 -05:00
|
|
|
log.Println("gui.DumpBoxes() \tWindows.TabNumber = nil")
|
|
|
|
} else {
|
|
|
|
log.Println("gui.DumpBoxes() \tWindows.TabNumber =", *window.TabNumber)
|
|
|
|
}
|
2019-06-13 16:17:05 -05:00
|
|
|
log.Println("gui.DumpBoxes()\tWindow.name =", window.Name)
|
|
|
|
// log.Println("gui.DumpBoxes()\tWindow.UiWindow type =", reflect.TypeOf(window.UiWindow))
|
|
|
|
log.Println("gui.DumpBoxes()\tWindow.UiWindow =", window.UiWindow)
|
2021-10-05 07:13:24 -05:00
|
|
|
log.Println("gui.DumpBoxes()\tWindow.UiTab =", window.UiTab)
|
2019-06-13 14:08:47 -05:00
|
|
|
for name, abox := range window.BoxMap {
|
|
|
|
log.Printf("gui.DumpBoxes() \tBOX mapname=%-12s abox.Name=%-12s", name, abox.Name)
|
2021-10-06 11:50:35 -05:00
|
|
|
if name == "MAINBOX" {
|
|
|
|
if Config.Debug {
|
2019-06-13 14:08:47 -05:00
|
|
|
scs := spew.ConfigState{MaxDepth: 1}
|
|
|
|
scs.Dump(abox.UiBox)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-10-06 11:50:35 -05:00
|
|
|
if window.UiTab != nil {
|
2019-06-13 14:08:47 -05:00
|
|
|
// log.Println("gui.DumpBoxes()\tWindow.UiTab type =", reflect.TypeOf(window.UiTab))
|
|
|
|
// log.Println("gui.DumpBoxes()\tWindow.UiTab =", window.UiTab)
|
2019-06-04 14:04:59 -05:00
|
|
|
pages := window.UiTab.NumPages()
|
|
|
|
log.Println("gui.DumpBoxes()\tWindow.UiTab.NumPages() =", pages)
|
2019-06-05 12:01:36 -05:00
|
|
|
// for i := 0; i < pages; i++ {
|
|
|
|
// log.Println("gui.DumpBoxes()\t\tWindow.UiTab.Margined(", i, ") =", window.UiTab.Margined(i))
|
|
|
|
// }
|
2019-06-03 19:25:07 -05:00
|
|
|
// tmp := spew.NewDefaultConfig()
|
|
|
|
// tmp.MaxDepth = 2
|
|
|
|
// tmp.Dump(window.UiTab)
|
2021-10-06 11:50:35 -05:00
|
|
|
if Config.Debug {
|
2019-06-03 19:25:07 -05:00
|
|
|
scs := spew.ConfigState{MaxDepth: 2}
|
|
|
|
scs.Dump(window.UiTab)
|
|
|
|
}
|
2019-06-03 19:05:50 -05:00
|
|
|
}
|
2019-06-03 17:45:40 -05:00
|
|
|
}
|
2019-06-14 17:41:30 -05:00
|
|
|
/*
|
2021-10-06 11:50:35 -05:00
|
|
|
for i, window := range Data.Windows {
|
|
|
|
if (window.TabNumber == nil) {
|
|
|
|
log.Println("gui.DumpBoxes() Data.Windows", i, "Name =", window.Name, "TabNumber = nil")
|
|
|
|
} else {
|
|
|
|
log.Println("gui.DumpBoxes() Data.Windows", i, "Name =", window.Name, "TabNumber =", *window.TabNumber)
|
|
|
|
}
|
2019-06-03 14:56:33 -05:00
|
|
|
}
|
2019-06-14 17:41:30 -05:00
|
|
|
*/
|
2019-06-03 14:56:33 -05:00
|
|
|
}
|
|
|
|
|
2019-06-02 14:08:53 -05:00
|
|
|
func addTableTab() {
|
|
|
|
var parts []TableColumnData
|
|
|
|
|
|
|
|
for key, foo := range []string{"BG", "TEXTCOLOR", "BUTTON", "TEXTCOLOR", "TEXTCOLOR", "TEXT", "BUTTON", "TEXT", "BUTTON"} {
|
|
|
|
log.Println(key, foo)
|
|
|
|
|
|
|
|
var b TableColumnData
|
|
|
|
b.CellType = foo
|
2021-10-06 11:50:35 -05:00
|
|
|
b.Heading = fmt.Sprintf("heading%d", key)
|
2019-06-02 14:08:53 -05:00
|
|
|
parts = append(parts, b)
|
|
|
|
}
|
|
|
|
|
2019-06-17 12:28:40 -05:00
|
|
|
log.Println("Sleep for 1 second, then try to add new tabs")
|
|
|
|
time.Sleep(1 * time.Second)
|
2019-06-02 14:08:53 -05:00
|
|
|
}
|
2021-10-07 12:04:48 -05:00
|
|
|
|
|
|
|
func DebugDataNodeMap() {
|
|
|
|
if Data.NodeMap == nil {
|
2021-10-07 21:56:16 -05:00
|
|
|
log.Println("DebugDataNodeMap() NodeMap == nil")
|
2021-10-07 12:04:48 -05:00
|
|
|
return
|
|
|
|
}
|
2021-10-07 21:56:16 -05:00
|
|
|
log.Println("DebugDataNodeMap():")
|
2021-10-07 12:04:48 -05:00
|
|
|
for name, node := range Data.NodeMap {
|
2021-10-07 21:56:16 -05:00
|
|
|
log.Println("\tNode name =", node.Width, node.Height, name)
|
2021-10-07 21:31:15 -05:00
|
|
|
if (node.children == nil) {
|
|
|
|
log.Println("\t\tNo children")
|
|
|
|
} else {
|
|
|
|
log.Println("\t\tHas children:", node.children)
|
|
|
|
}
|
2021-10-07 12:04:48 -05:00
|
|
|
// node.SetName("yahoo")
|
|
|
|
// log.Println("\tData.NodeMap node =", node)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-07 21:56:16 -05:00
|
|
|
func DebugDataNodeChildren() {
|
|
|
|
if Data.NodeMap == nil {
|
|
|
|
log.Println("DebugDataNodeChildren() NodeMap == nil")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
log.Println("DebugDataNodeChildren():")
|
|
|
|
for name, node := range Data.NodeMap {
|
|
|
|
log.Println("\tNode name =", node.Width, node.Height, name)
|
|
|
|
if (node.children == nil) {
|
|
|
|
log.Println("\t\tNo children")
|
|
|
|
break
|
|
|
|
}
|
|
|
|
log.Println("\t\tHas children:", node.children)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-07 12:04:48 -05:00
|
|
|
func FindNode(name string) *Node {
|
|
|
|
if Data.NodeMap == nil {
|
|
|
|
log.Println("gui.FindNode() gui.Data.NodeMap == nil")
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
log.Println("gui.FindNode() searching Data.NodeMap:")
|
|
|
|
for id, node := range Data.NodeMap {
|
|
|
|
log.Println("\tData.NodeMap name =", node.Width, node.Height, id)
|
|
|
|
node.Dump()
|
|
|
|
if (name == node.Name) {
|
|
|
|
return node
|
|
|
|
}
|
|
|
|
newNode := findByName(node, name)
|
|
|
|
if (newNode != nil) {
|
|
|
|
return newNode
|
|
|
|
}
|
|
|
|
log.Println("gui.FindNode() could not find node name =", name)
|
|
|
|
os.Exit(-1)
|
|
|
|
}
|
|
|
|
log.Println("gui.FindNode() could not find node name =", name)
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func DebugNodeChildren() {
|
|
|
|
if Data.NodeMap == nil {
|
|
|
|
log.Println("Data.NodeMap == nil")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
log.Println("Dumping Data.NodeMap:")
|
|
|
|
for name, node := range Data.NodeMap {
|
2021-10-08 07:36:53 -05:00
|
|
|
log.Println("\tData.NodeMap name =", node.id, node.Width, node.Height, name)
|
2021-10-07 21:56:16 -05:00
|
|
|
// node.Dump()
|
|
|
|
node.ListChildren()
|
2021-10-07 12:04:48 -05:00
|
|
|
// node.SetName("yahoo")
|
|
|
|
// log.Println("\tData.NodeMap node =", node)
|
|
|
|
}
|
|
|
|
}
|