2021-10-05 05:52:50 -05:00
|
|
|
package gui
|
|
|
|
|
2021-10-06 11:17:43 -05:00
|
|
|
import (
|
|
|
|
"log"
|
2021-10-05 05:52:50 -05:00
|
|
|
|
2021-10-06 11:17:43 -05:00
|
|
|
"github.com/andlabs/ui"
|
|
|
|
_ "github.com/andlabs/ui/winmanifest"
|
|
|
|
"github.com/davecgh/go-spew/spew"
|
|
|
|
)
|
2021-10-05 06:25:32 -05:00
|
|
|
|
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-06 11:17:43 -05:00
|
|
|
/////////////////////////////////////////////////////
|
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-06 11:17:43 -05:00
|
|
|
/////////////////////////////////////////////////////
|
2021-10-06 08:36:28 -05:00
|
|
|
vbox = addGroup(hbox, "WindowMap 2")
|
2021-10-05 06:25:32 -05:00
|
|
|
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-06 11:50:35 -05:00
|
|
|
cbox.SetSelected(0)
|
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-06 11:17:43 -05:00
|
|
|
/////////////////////////////////////////////////////
|
2021-10-05 06:46:46 -05:00
|
|
|
vbox = addGroup(hbox, "Buttons")
|
2021-10-05 07:13:24 -05:00
|
|
|
|
2021-10-05 06:46:46 -05:00
|
|
|
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])
|
|
|
|
})
|
2021-10-05 07:13:24 -05:00
|
|
|
|
2021-10-06 11:17:43 -05:00
|
|
|
dump2 := addButton(vbox, "Dump Boxes")
|
|
|
|
dump2.OnClicked(func(*ui.Button) {
|
|
|
|
DumpBoxes()
|
|
|
|
})
|
|
|
|
|
|
|
|
dump1 := addButton(vbox, "Dump MAP")
|
|
|
|
dump1.OnClicked(func(*ui.Button) {
|
|
|
|
DumpMap()
|
|
|
|
})
|
|
|
|
|
2021-10-05 07:13:24 -05:00
|
|
|
b2 := addButton(vbox, "SetMargined()")
|
2021-10-05 06:46:46 -05:00
|
|
|
b2.OnClicked(func(*ui.Button) {
|
2021-10-05 07:13:24 -05:00
|
|
|
x := cbox.Selected()
|
|
|
|
log.Println("x =", x)
|
|
|
|
log.Println("findBox; names[x] =", names[x])
|
|
|
|
findBox(names[x])
|
|
|
|
gw := findBox(names[x])
|
2021-10-06 11:17:43 -05:00
|
|
|
if gw == nil {
|
2021-10-05 07:13:24 -05:00
|
|
|
return
|
|
|
|
}
|
2021-10-06 11:17:43 -05:00
|
|
|
if gw.UiTab == nil {
|
2021-10-05 07:13:24 -05:00
|
|
|
return
|
|
|
|
}
|
2021-10-06 11:17:43 -05:00
|
|
|
if gw.TabNumber == nil {
|
2021-10-05 07:13:24 -05:00
|
|
|
return
|
|
|
|
}
|
|
|
|
scs := spew.ConfigState{MaxDepth: 1}
|
|
|
|
scs.Dump(gw)
|
|
|
|
log.Println("gui.DumpBoxes()\tWindow.UiTab =", gw.UiTab)
|
|
|
|
log.Println("gui.DumpBoxes()\tWindow.TabNumber =", *gw.TabNumber)
|
|
|
|
gw.UiTab.SetMargined(*gw.TabNumber, true)
|
2021-10-05 06:46:46 -05:00
|
|
|
})
|
|
|
|
|
2021-10-05 09:42:30 -05:00
|
|
|
b3 := addButton(vbox, "Hide()")
|
|
|
|
b3.OnClicked(func(*ui.Button) {
|
|
|
|
x := cbox.Selected()
|
|
|
|
log.Println("x =", x)
|
|
|
|
log.Println("findBox; names[x] =", names[x])
|
|
|
|
findBox(names[x])
|
|
|
|
gw := findBox(names[x])
|
2021-10-06 11:17:43 -05:00
|
|
|
if gw == nil {
|
2021-10-05 09:42:30 -05:00
|
|
|
return
|
|
|
|
}
|
2021-10-06 11:17:43 -05:00
|
|
|
if gw.UiTab == nil {
|
2021-10-05 09:42:30 -05:00
|
|
|
return
|
|
|
|
}
|
|
|
|
gw.UiTab.Hide()
|
|
|
|
})
|
|
|
|
|
|
|
|
b4 := addButton(vbox, "Show()")
|
|
|
|
b4.OnClicked(func(*ui.Button) {
|
|
|
|
x := cbox.Selected()
|
|
|
|
log.Println("x =", x)
|
|
|
|
log.Println("findBox; names[x] =", names[x])
|
|
|
|
findBox(names[x])
|
|
|
|
gw := findBox(names[x])
|
2021-10-06 11:17:43 -05:00
|
|
|
if gw == nil {
|
2021-10-05 09:42:30 -05:00
|
|
|
return
|
|
|
|
}
|
2021-10-06 11:17:43 -05:00
|
|
|
if gw.UiTab == nil {
|
2021-10-05 09:42:30 -05:00
|
|
|
return
|
|
|
|
}
|
|
|
|
gw.UiTab.Show()
|
|
|
|
})
|
|
|
|
|
|
|
|
b5 := addButton(vbox, "Delete()")
|
|
|
|
b5.OnClicked(func(*ui.Button) {
|
|
|
|
x := cbox.Selected()
|
|
|
|
log.Println("x =", x)
|
|
|
|
log.Println("findBox; names[x] =", names[x])
|
|
|
|
findBox(names[x])
|
|
|
|
gw := findBox(names[x])
|
2021-10-06 11:17:43 -05:00
|
|
|
if gw == nil {
|
2021-10-05 09:42:30 -05:00
|
|
|
return
|
|
|
|
}
|
2021-10-06 11:17:43 -05:00
|
|
|
if gw.UiTab == nil {
|
2021-10-05 09:42:30 -05:00
|
|
|
return
|
|
|
|
}
|
2021-10-06 11:17:43 -05:00
|
|
|
if gw.TabNumber == nil {
|
2021-10-05 09:42:30 -05:00
|
|
|
return
|
|
|
|
}
|
|
|
|
gw.UiTab.Delete(*gw.TabNumber)
|
|
|
|
})
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2021-10-05 07:13:24 -05:00
|
|
|
func findBox(s string) *GuiWindow {
|
|
|
|
for name, window := range Data.WindowMap {
|
2021-10-06 11:17:43 -05:00
|
|
|
if name == s {
|
2021-10-05 07:13:24 -05:00
|
|
|
return window
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-10-05 06:25:32 -05:00
|
|
|
func dumpBox(s string) {
|
|
|
|
for name, window := range Data.WindowMap {
|
2021-10-06 11:17:43 -05:00
|
|
|
if name != s {
|
2021-10-05 06:25:32 -05:00
|
|
|
continue
|
|
|
|
}
|
|
|
|
log.Println("gui.DumpBoxes() MAP: ", name)
|
2021-10-06 11:17:43 -05:00
|
|
|
if window.TabNumber == nil {
|
2021-10-05 06:25:32 -05:00
|
|
|
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)
|
2021-10-05 07:13:24 -05:00
|
|
|
log.Println("gui.DumpBoxes()\tWindow.UiTab =", window.UiTab)
|
2021-10-05 06:25:32 -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:17:43 -05:00
|
|
|
if name == "MAINBOX" {
|
|
|
|
if Config.Debug {
|
2021-10-05 06:25:32 -05:00
|
|
|
scs := spew.ConfigState{MaxDepth: 1}
|
|
|
|
scs.Dump(abox.UiBox)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-10-06 11:17:43 -05:00
|
|
|
if window.UiTab != nil {
|
2021-10-05 06:25:32 -05:00
|
|
|
pages := window.UiTab.NumPages()
|
|
|
|
log.Println("gui.DumpBoxes()\tWindow.UiTab.NumPages() =", pages)
|
|
|
|
tabSetMargined(window.UiTab)
|
2021-10-06 11:17:43 -05:00
|
|
|
if Config.Debug {
|
2021-10-05 06:25:32 -05:00
|
|
|
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
|
|
|
|
}
|