DEBUG: gui to debug windows

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2021-10-05 05:52:50 -05:00
parent 90d8111ada
commit 6f88d8fbf5
2 changed files with 99 additions and 8 deletions

View File

@ -105,12 +105,12 @@ func (s GuiBox) SetTitle(title string) {
return
}
func (s GuiBox) InitTab(title string) {
func (s GuiBox) InitTab(title string) *ui.Tab {
if (s.Window == nil) {
return
return nil
}
if (s.Window.UiWindow == nil) {
return
return nil
}
window := s.Window.UiWindow
@ -123,19 +123,21 @@ func (s GuiBox) InitTab(title string) {
// tab.SetMargined(1, true)
s.Window.UiTab = tab
return tab
}
func (s GuiBox) AddTab(title string, custom ui.Control) {
func (s GuiBox) AddTab(title string, custom ui.Control) *ui.Tab {
if (s.Window == nil) {
return
return nil
}
if (s.Window.UiTab == nil) {
return
return nil
}
tab := s.Window.UiTab
tab.Append(title, custom)
return tab
}
func (s GuiBox) AddTab2(title string, custom ui.Control) *ui.Tab {
@ -153,8 +155,8 @@ func (s GuiBox) AddTab2(title string, custom ui.Control) *ui.Tab {
func (s GuiBox) AddBoxTab(title string) *GuiBox {
uiTab := s.AddTab2(title, InitBlankWindow())
tabSetMargined(uiTab)
var box *GuiBox
box = HardBox(s.Window, Xaxis, "jcarrAddBoxTab")
box.Window.UiTab = uiTab
@ -162,7 +164,13 @@ func (s GuiBox) AddBoxTab(title string) *GuiBox {
}
func (s GuiBox) AddDemoTab(title string) {
s.AddTab(title, makeWindowTemplate())
uiTab := s.AddTab(title, makeWindowTemplate())
tabSetMargined(uiTab)
}
func (s GuiBox) AddDebugTab(title string) {
uiTab := s.AddTab(title, makeWindowDebug())
tabSetMargined(uiTab)
}
func tabSetMargined(tab *ui.Tab) {

83
window-debug.go Normal file
View File

@ -0,0 +1,83 @@
package gui
import "log"
import "github.com/andlabs/ui"
import _ "github.com/andlabs/ui/winmanifest"
var names = make([]string, 100)
func makeWindowDebug() ui.Control {
hbox := ui.NewHorizontalBox()
hbox.SetPadded(true)
group := ui.NewGroup("Numbers")
group.SetMargined(true)
hbox.Append(group, true)
vbox := ui.NewVerticalBox()
vbox.SetPadded(true)
group.SetChild(vbox)
spinbox := ui.NewSpinbox(22, 44)
slider := ui.NewSlider(22, 44)
pbar := ui.NewProgressBar()
spinbox.OnChanged(func(*ui.Spinbox) {
slider.SetValue(spinbox.Value())
pbar.SetValue(spinbox.Value())
})
slider.OnChanged(func(*ui.Slider) {
spinbox.SetValue(slider.Value())
pbar.SetValue(slider.Value())
})
vbox.Append(spinbox, false)
vbox.Append(slider, false)
vbox.Append(pbar, false)
ip := ui.NewProgressBar()
ip.SetValue(-1)
vbox.Append(ip, false)
group = ui.NewGroup("WindowMap")
group.SetMargined(true)
hbox.Append(group, true)
vbox = ui.NewVerticalBox()
vbox.SetPadded(true)
group.SetChild(vbox)
cbox := ui.NewCombobox()
addName(cbox, "Window 1")
addName(cbox, "Window 2")
addName(cbox, "Combobox Item 3")
vbox.Append(cbox, false)
cbox.OnSelected(func(*ui.Combobox) {
log.Println("test")
test := cbox.Selected()
log.Println("test=", test)
log.Println("names[test] =", names[test])
// for name := range names {
// log.Println("gui.DumpBoxes() name: ", name)
// }
// if (names[test] != nil) {
// }
})
for name, _ := range Data.WindowMap {
log.Println("gui.DumpBoxes() name: ", name)
addName(cbox, name)
}
return hbox
}
var x int = 0
func addName(c *ui.Combobox, s string) {
c.Append(s)
names[x] = s
x = x + 1
}