CLEAN: clean up labels

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2021-10-25 05:41:12 -05:00
parent 9a07e2b2af
commit e907164e17
6 changed files with 56 additions and 43 deletions

35
find.go Normal file
View File

@ -0,0 +1,35 @@
package gui
import (
"log"
// "github.com/andlabs/ui"
// _ "github.com/andlabs/ui/winmanifest"
// "github.com/davecgh/go-spew/spew"
)
func FindWindow(s string) *GuiWindow {
for name, window := range Data.WindowMap {
if name == s {
return window
}
}
log.Printf("COULD NOT FIND WINDOW", s)
return nil
}
func FindBox(s string) *GuiBox {
for name, window := range Data.WindowMap {
if name != s {
continue
}
for name, abox := range window.BoxMap {
log.Printf("gui.DumpBoxes() \tBOX mapname=%-12s abox.Name=%-12s", name, abox.Name)
return abox
}
log.Println("gui.FindBox() NEED TO INIT WINDOW name =", name)
}
log.Println("gui.FindBox() COULD NOT FIND BOX", s)
return nil
}

View File

@ -26,10 +26,13 @@ func main() {
}
func initGUI() {
n := gui.NewWindow("jcarr start", 640, 480)
n.AddDemoTab("up the rabbit hole")
n := gui.NewWindow("WIT GUI Example Window", 640, 480)
n.AddDemoTab("A Simple Tab Demo")
}
// This demonstrates how to properly interact with the GUI
// You can not involke the GUI from external goroutines in most cases.
func watchGUI() {
var i = 1
for {
@ -37,7 +40,7 @@ func watchGUI() {
i += 1
time.Sleep(1 * time.Second)
if i == 4 {
log.Println("Sending ExampleWindow to gui.Queue()")
log.Println("Opening a Debug Window via the gui.Queue()")
gui.Queue(gui.DebugWindow)
}
}

2
gui.go
View File

@ -23,7 +23,7 @@ func init() {
Data.NodeSlice = make([]*Node, 0)
Config.counter = 0
Config.prefix = "jwc"
Config.prefix = "wit"
Config.DebugNode = false
Config.DebugTabs = false
}

14
main.go
View File

@ -40,17 +40,3 @@ func ExampleWindow() {
window.UiWindow.Show()
}
func DebugWindow() {
log.Println("START gui.ExampleWindow()")
title := "Debug Window"
node := InitWindow(nil, nil, title, 0)
box := node.box
window := box.Window
log.Println("box =", box)
log.Println("window =", window)
node.AddDebugTab("jcarr Debug")
window.UiWindow.Show()
}

View File

@ -11,6 +11,20 @@ import (
var names = make([]string, 100)
var nodeNames = make([]string, 100)
func DebugWindow() {
log.Println("START gui.DebugWindow()")
title := "WIT GUI Debug Window"
node := InitWindow(nil, nil, title, 0)
box := node.box
window := box.Window
log.Println("box =", box)
log.Println("window =", window)
node.AddDebugTab("WIT GUI Debug Tab")
window.UiWindow.Show()
}
// TODO: remove this crap
// What does this actually do?
// It populates the nodeNames in a map. No, not a map, an array. What is the difference again?
@ -278,31 +292,6 @@ func addGroup(b *ui.Box, name string) *ui.Box {
return vbox
}
func FindWindow(s string) *GuiWindow {
for name, window := range Data.WindowMap {
if name == s {
return window
}
}
log.Printf("COULD NOT FIND WINDOW", s)
return nil
}
func FindBox(s string) *GuiBox {
for name, window := range Data.WindowMap {
if name != s {
continue
}
for name, abox := range window.BoxMap {
log.Printf("gui.DumpBoxes() \tBOX mapname=%-12s abox.Name=%-12s", name, abox.Name)
return abox
}
log.Println("gui.FindBox() NEED TO INIT WINDOW name =", name)
}
log.Println("gui.FindBox() COULD NOT FIND BOX", s)
return nil
}
func dumpBox(s string) {
var name string
var window *GuiWindow