2021-10-05 05:52:50 -05:00
|
|
|
package gui
|
|
|
|
|
|
|
|
import "log"
|
|
|
|
import "github.com/andlabs/ui"
|
|
|
|
import _ "github.com/andlabs/ui/winmanifest"
|
|
|
|
|
2021-10-05 06:25:32 -05:00
|
|
|
import "github.com/davecgh/go-spew/spew"
|
|
|
|
|
2021-10-05 05:52:50 -05:00
|
|
|
var names = make([]string, 100)
|
|
|
|
|
|
|
|
func makeWindowDebug() ui.Control {
|
|
|
|
hbox := ui.NewHorizontalBox()
|
|
|
|
hbox.SetPadded(true)
|
|
|
|
|
2021-10-05 06:25:32 -05:00
|
|
|
/////////////////////////////////////////////////////
|
|
|
|
vbox := addGroup(hbox, "Numbers")
|
|
|
|
pbar := ui.NewProgressBar()
|
2021-10-05 05:52:50 -05:00
|
|
|
vbox.Append(pbar, false)
|
|
|
|
|
2021-10-05 06:25:32 -05:00
|
|
|
/////////////////////////////////////////////////////
|
|
|
|
vbox = addGroup(hbox, "WindowMap")
|
|
|
|
cbox := ui.NewCombobox()
|
2021-10-05 05:52:50 -05:00
|
|
|
|
2021-10-05 06:25:32 -05:00
|
|
|
for name, _ := range Data.WindowMap {
|
|
|
|
log.Println("range Data.WindowMap() name =", name)
|
|
|
|
addName(cbox, name)
|
|
|
|
}
|
2021-10-05 05:52:50 -05:00
|
|
|
|
|
|
|
vbox.Append(cbox, false)
|
|
|
|
|
|
|
|
cbox.OnSelected(func(*ui.Combobox) {
|
2021-10-05 06:25:32 -05:00
|
|
|
x := cbox.Selected()
|
|
|
|
log.Println("x =", x)
|
|
|
|
log.Println("names[x] =", names[x])
|
|
|
|
dumpBox(names[x])
|
2021-10-05 05:52:50 -05:00
|
|
|
})
|
|
|
|
|
2021-10-05 06:46:46 -05:00
|
|
|
/////////////////////////////////////////////////////
|
|
|
|
vbox = addGroup(hbox, "Buttons")
|
|
|
|
b1 := addButton(vbox, "dumpBox(name)")
|
|
|
|
b1.OnClicked(func(*ui.Button) {
|
|
|
|
x := cbox.Selected()
|
|
|
|
log.Println("x =", x)
|
|
|
|
log.Println("names[x] =", names[x])
|
|
|
|
dumpBox(names[x])
|
|
|
|
})
|
|
|
|
b2 := addButton(vbox, "something 2")
|
|
|
|
b2.OnClicked(func(*ui.Button) {
|
|
|
|
log.Println("Should do something here b2")
|
|
|
|
})
|
|
|
|
|
2021-10-05 05:52:50 -05:00
|
|
|
return hbox
|
|
|
|
}
|
|
|
|
|
|
|
|
var x int = 0
|
|
|
|
|
|
|
|
func addName(c *ui.Combobox, s string) {
|
|
|
|
c.Append(s)
|
|
|
|
names[x] = s
|
|
|
|
x = x + 1
|
|
|
|
}
|
2021-10-05 06:25:32 -05:00
|
|
|
|
2021-10-05 06:46:46 -05:00
|
|
|
func addGroup(b *ui.Box, name string) *ui.Box {
|
2021-10-05 06:25:32 -05:00
|
|
|
group := ui.NewGroup(name)
|
|
|
|
group.SetMargined(true)
|
2021-10-05 06:46:46 -05:00
|
|
|
b.Append(group, true)
|
2021-10-05 06:25:32 -05:00
|
|
|
|
|
|
|
vbox := ui.NewVerticalBox()
|
|
|
|
vbox.SetPadded(true)
|
|
|
|
group.SetChild(vbox)
|
|
|
|
|
|
|
|
return vbox
|
|
|
|
}
|
|
|
|
|
|
|
|
func dumpBox(s string) {
|
|
|
|
for name, window := range Data.WindowMap {
|
|
|
|
if (name != s) {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
log.Println("gui.DumpBoxes() MAP: ", name)
|
|
|
|
if (window.TabNumber == nil) {
|
|
|
|
log.Println("gui.DumpBoxes() \tWindows.TabNumber = nil")
|
|
|
|
} else {
|
|
|
|
log.Println("gui.DumpBoxes() \tWindows.TabNumber =", *window.TabNumber)
|
|
|
|
}
|
|
|
|
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)
|
|
|
|
for name, abox := range window.BoxMap {
|
|
|
|
log.Printf("gui.DumpBoxes() \tBOX mapname=%-12s abox.Name=%-12s", name, abox.Name)
|
|
|
|
if (name == "MAINBOX") {
|
|
|
|
if (Config.Debug) {
|
|
|
|
scs := spew.ConfigState{MaxDepth: 1}
|
|
|
|
scs.Dump(abox.UiBox)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (window.UiTab != nil) {
|
|
|
|
pages := window.UiTab.NumPages()
|
|
|
|
log.Println("gui.DumpBoxes()\tWindow.UiTab.NumPages() =", pages)
|
|
|
|
tabSetMargined(window.UiTab)
|
|
|
|
if (Config.Debug) {
|
|
|
|
scs := spew.ConfigState{MaxDepth: 2}
|
|
|
|
scs.Dump(window.UiTab)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-10-05 06:46:46 -05:00
|
|
|
|
|
|
|
func addButton(box *ui.Box, name string) *ui.Button {
|
|
|
|
button := ui.NewButton(name)
|
|
|
|
|
|
|
|
button.OnClicked(func(*ui.Button) {
|
|
|
|
log.Println("Should do something here")
|
|
|
|
})
|
|
|
|
|
|
|
|
box.Append(button, false)
|
|
|
|
return button
|
|
|
|
}
|