TAB: correctly lookup and add tabs to blank windows
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
c58dee3d01
commit
908615c038
6
debug.go
6
debug.go
|
@ -33,8 +33,12 @@ func WatchGUI() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func DumpMap() {
|
func DumpMap() {
|
||||||
for name, _ := range Data.WindowMap {
|
for name, window := range Data.WindowMap {
|
||||||
log.Println("gui.DumpBoxes() MAP: ", name)
|
log.Println("gui.DumpBoxes() MAP: ", name)
|
||||||
|
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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
62
structs.go
62
structs.go
|
@ -1,11 +1,14 @@
|
||||||
package gui
|
package gui
|
||||||
|
|
||||||
import "log"
|
import (
|
||||||
import "image/color"
|
"image/color"
|
||||||
import "golang.org/x/image/font"
|
"log"
|
||||||
|
|
||||||
import "github.com/andlabs/ui"
|
"github.com/andlabs/ui"
|
||||||
import _ "github.com/andlabs/ui/winmanifest"
|
"golang.org/x/image/font"
|
||||||
|
|
||||||
|
_ "github.com/andlabs/ui/winmanifest"
|
||||||
|
)
|
||||||
|
|
||||||
//
|
//
|
||||||
// All GUI Data Structures and functions that are external
|
// All GUI Data Structures and functions that are external
|
||||||
|
@ -102,10 +105,10 @@ type GuiBox struct {
|
||||||
|
|
||||||
func (s GuiBox) SetTitle(title string) {
|
func (s GuiBox) SetTitle(title string) {
|
||||||
log.Println("DID IT!", title)
|
log.Println("DID IT!", title)
|
||||||
if (s.Window == nil) {
|
if s.Window == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (s.Window.UiWindow == nil) {
|
if s.Window.UiWindow == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
s.Window.UiWindow.SetTitle(title)
|
s.Window.UiWindow.SetTitle(title)
|
||||||
|
@ -113,17 +116,33 @@ func (s GuiBox) SetTitle(title string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s GuiBox) Append(child ui.Control, x bool) {
|
func (s GuiBox) Append(child ui.Control, x bool) {
|
||||||
if (s.UiBox == nil) {
|
if s.UiBox == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
s.UiBox.Append(child, x)
|
s.UiBox.Append(child, x)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s GuiBox) InitTab(title string) *ui.Tab {
|
func (w GuiWindow) InitBox(title string) *GuiBox {
|
||||||
if (s.Window == nil) {
|
if w.UiWindow == nil {
|
||||||
|
log.Println("gui.InitBox() THIS SHOULD NEVER HAPPEN. Window doesn't exist", w)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if (s.Window.UiWindow == nil) {
|
tab := ui.NewTab()
|
||||||
|
w.UiWindow.SetChild(tab)
|
||||||
|
w.UiWindow.SetMargined(true)
|
||||||
|
|
||||||
|
tab.Append(title, initBlankWindow())
|
||||||
|
tab.SetMargined(0, true)
|
||||||
|
|
||||||
|
w.UiTab = tab
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s GuiBox) InitTab(title string) *ui.Tab {
|
||||||
|
if s.Window == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if s.Window.UiWindow == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,10 +160,10 @@ func (s GuiBox) InitTab(title string) *ui.Tab {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s GuiBox) AddTab(title string, custom ui.Control) *ui.Tab {
|
func (s GuiBox) AddTab(title string, custom ui.Control) *ui.Tab {
|
||||||
if (s.Window == nil) {
|
if s.Window == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if (s.Window.UiTab == nil) {
|
if s.Window.UiTab == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,10 +174,10 @@ func (s GuiBox) AddTab(title string, custom ui.Control) *ui.Tab {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s GuiBox) AddTab2(title string, custom ui.Control) *ui.Tab {
|
func (s GuiBox) AddTab2(title string, custom ui.Control) *ui.Tab {
|
||||||
if (s.Window == nil) {
|
if s.Window == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if (s.Window.UiTab == nil) {
|
if s.Window.UiTab == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,8 +223,8 @@ type GuiButton struct {
|
||||||
Box *GuiBox // what box the button click was in
|
Box *GuiBox // what box the button click was in
|
||||||
|
|
||||||
// a callback function for the main application
|
// a callback function for the main application
|
||||||
Custom func (*GuiButton)
|
Custom func(*GuiButton)
|
||||||
Values interface {}
|
Values interface{}
|
||||||
Color color.RGBA
|
Color color.RGBA
|
||||||
|
|
||||||
// andlabs/ui abstraction mapping
|
// andlabs/ui abstraction mapping
|
||||||
|
@ -219,7 +238,7 @@ type GuiEntry struct {
|
||||||
Name string // field for human readable name
|
Name string // field for human readable name
|
||||||
Edit bool
|
Edit bool
|
||||||
Last string // the last value
|
Last string // the last value
|
||||||
Normalize func (string) string // function to 'normalize' the data
|
Normalize func(string) string // function to 'normalize' the data
|
||||||
|
|
||||||
B *GuiButton
|
B *GuiButton
|
||||||
Box *GuiBox
|
Box *GuiBox
|
||||||
|
@ -233,7 +252,7 @@ type GuiEntry struct {
|
||||||
// AREA STRUCTURES START
|
// AREA STRUCTURES START
|
||||||
// AREA STRUCTURES START
|
// AREA STRUCTURES START
|
||||||
//
|
//
|
||||||
type GuiArea struct{
|
type GuiArea struct {
|
||||||
Button *GuiButton // what button handles mouse events
|
Button *GuiButton // what button handles mouse events
|
||||||
Box *GuiBox
|
Box *GuiBox
|
||||||
|
|
||||||
|
@ -247,6 +266,7 @@ type FontString struct {
|
||||||
F font.Face
|
F font.Face
|
||||||
W font.Weight
|
W font.Weight
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// AREA STRUCTURES END
|
// AREA STRUCTURES END
|
||||||
// AREA STRUCTURES END
|
// AREA STRUCTURES END
|
||||||
|
@ -325,12 +345,12 @@ type CellData struct {
|
||||||
type RowData struct {
|
type RowData struct {
|
||||||
Name string // what kind of row is this?
|
Name string // what kind of row is this?
|
||||||
Status string // status of the row?
|
Status string // status of the row?
|
||||||
/*
|
/*
|
||||||
// TODO: These may or may not be implementable
|
// TODO: These may or may not be implementable
|
||||||
// depending on if it's possible to detect the bgcolor or what row is selected
|
// depending on if it's possible to detect the bgcolor or what row is selected
|
||||||
click func() // what function to call if the user clicks on it
|
click func() // what function to call if the user clicks on it
|
||||||
doubleclick func() // what function to call if the user double clicks on it
|
doubleclick func() // what function to call if the user double clicks on it
|
||||||
*/
|
*/
|
||||||
HumanData [20]HumanCellData
|
HumanData [20]HumanCellData
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ func makeWindowDebug() ui.Control {
|
||||||
vbox.Append(pbar, false)
|
vbox.Append(pbar, false)
|
||||||
|
|
||||||
/////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////
|
||||||
vbox = addGroup(hbox, "WindowMap 2")
|
vbox = addGroup(hbox, "Window")
|
||||||
cbox := ui.NewCombobox()
|
cbox := ui.NewCombobox()
|
||||||
|
|
||||||
for name, _ := range Data.WindowMap {
|
for name, _ := range Data.WindowMap {
|
||||||
|
@ -39,9 +39,9 @@ func makeWindowDebug() ui.Control {
|
||||||
})
|
})
|
||||||
|
|
||||||
/////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////
|
||||||
vbox = addGroup(hbox, "Buttons")
|
vbox = addGroup(hbox, "Debug Window")
|
||||||
|
|
||||||
b1 := addButton(vbox, "dumpBox(name)")
|
b1 := addButton(vbox, "dumpBox(window)")
|
||||||
b1.OnClicked(func(*ui.Button) {
|
b1.OnClicked(func(*ui.Button) {
|
||||||
x := cbox.Selected()
|
x := cbox.Selected()
|
||||||
log.Println("x =", x)
|
log.Println("x =", x)
|
||||||
|
@ -49,23 +49,12 @@ func makeWindowDebug() ui.Control {
|
||||||
dumpBox(names[x])
|
dumpBox(names[x])
|
||||||
})
|
})
|
||||||
|
|
||||||
dump2 := addButton(vbox, "Dump Boxes")
|
b2 := addButton(vbox, "SetMargined(tab)")
|
||||||
dump2.OnClicked(func(*ui.Button) {
|
|
||||||
DumpBoxes()
|
|
||||||
})
|
|
||||||
|
|
||||||
dump1 := addButton(vbox, "Dump MAP")
|
|
||||||
dump1.OnClicked(func(*ui.Button) {
|
|
||||||
DumpMap()
|
|
||||||
})
|
|
||||||
|
|
||||||
b2 := addButton(vbox, "SetMargined()")
|
|
||||||
b2.OnClicked(func(*ui.Button) {
|
b2.OnClicked(func(*ui.Button) {
|
||||||
x := cbox.Selected()
|
x := cbox.Selected()
|
||||||
log.Println("x =", x)
|
log.Println("x =", x)
|
||||||
log.Println("findBox; names[x] =", names[x])
|
log.Println("FindWindow; names[x] =", names[x])
|
||||||
findBox(names[x])
|
gw := FindWindow(names[x])
|
||||||
gw := findBox(names[x])
|
|
||||||
if gw == nil {
|
if gw == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -82,13 +71,12 @@ func makeWindowDebug() ui.Control {
|
||||||
gw.UiTab.SetMargined(*gw.TabNumber, true)
|
gw.UiTab.SetMargined(*gw.TabNumber, true)
|
||||||
})
|
})
|
||||||
|
|
||||||
b3 := addButton(vbox, "Hide()")
|
b3 := addButton(vbox, "Hide(tab)")
|
||||||
b3.OnClicked(func(*ui.Button) {
|
b3.OnClicked(func(*ui.Button) {
|
||||||
x := cbox.Selected()
|
x := cbox.Selected()
|
||||||
log.Println("x =", x)
|
log.Println("x =", x)
|
||||||
log.Println("findBox; names[x] =", names[x])
|
log.Println("FindWindow; names[x] =", names[x])
|
||||||
findBox(names[x])
|
gw := FindWindow(names[x])
|
||||||
gw := findBox(names[x])
|
|
||||||
if gw == nil {
|
if gw == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -98,13 +86,12 @@ func makeWindowDebug() ui.Control {
|
||||||
gw.UiTab.Hide()
|
gw.UiTab.Hide()
|
||||||
})
|
})
|
||||||
|
|
||||||
b4 := addButton(vbox, "Show()")
|
b4 := addButton(vbox, "Show(tab)")
|
||||||
b4.OnClicked(func(*ui.Button) {
|
b4.OnClicked(func(*ui.Button) {
|
||||||
x := cbox.Selected()
|
x := cbox.Selected()
|
||||||
log.Println("x =", x)
|
log.Println("x =", x)
|
||||||
log.Println("findBox; names[x] =", names[x])
|
log.Println("FindWindow; names[x] =", names[x])
|
||||||
findBox(names[x])
|
gw := FindWindow(names[x])
|
||||||
gw := findBox(names[x])
|
|
||||||
if gw == nil {
|
if gw == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -114,13 +101,12 @@ func makeWindowDebug() ui.Control {
|
||||||
gw.UiTab.Show()
|
gw.UiTab.Show()
|
||||||
})
|
})
|
||||||
|
|
||||||
b5 := addButton(vbox, "Delete()")
|
b5 := addButton(vbox, "Delete(tab)")
|
||||||
b5.OnClicked(func(*ui.Button) {
|
b5.OnClicked(func(*ui.Button) {
|
||||||
x := cbox.Selected()
|
x := cbox.Selected()
|
||||||
log.Println("x =", x)
|
log.Println("x =", x)
|
||||||
log.Println("findBox; names[x] =", names[x])
|
log.Println("FindWindow; names[x] =", names[x])
|
||||||
findBox(names[x])
|
gw := FindWindow(names[x])
|
||||||
gw := findBox(names[x])
|
|
||||||
if gw == nil {
|
if gw == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -133,6 +119,19 @@ func makeWindowDebug() ui.Control {
|
||||||
gw.UiTab.Delete(*gw.TabNumber)
|
gw.UiTab.Delete(*gw.TabNumber)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////
|
||||||
|
vbox = addGroup(hbox, "Global Debug")
|
||||||
|
|
||||||
|
dump2 := addButton(vbox, "Dump Boxes")
|
||||||
|
dump2.OnClicked(func(*ui.Button) {
|
||||||
|
DumpBoxes()
|
||||||
|
})
|
||||||
|
|
||||||
|
dump1 := addButton(vbox, "Dump MAP")
|
||||||
|
dump1.OnClicked(func(*ui.Button) {
|
||||||
|
DumpMap()
|
||||||
|
})
|
||||||
|
|
||||||
return hbox
|
return hbox
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,12 +155,28 @@ func addGroup(b *ui.Box, name string) *ui.Box {
|
||||||
return vbox
|
return vbox
|
||||||
}
|
}
|
||||||
|
|
||||||
func findBox(s string) *GuiWindow {
|
func FindWindow(s string) *GuiWindow {
|
||||||
for name, window := range Data.WindowMap {
|
for name, window := range Data.WindowMap {
|
||||||
if name == s {
|
if name == s {
|
||||||
return window
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,6 +195,7 @@ func dumpBox(s string) {
|
||||||
// log.Println("gui.DumpBoxes()\tWindow.UiWindow type =", reflect.TypeOf(window.UiWindow))
|
// log.Println("gui.DumpBoxes()\tWindow.UiWindow type =", reflect.TypeOf(window.UiWindow))
|
||||||
log.Println("gui.DumpBoxes()\tWindow.UiWindow =", window.UiWindow)
|
log.Println("gui.DumpBoxes()\tWindow.UiWindow =", window.UiWindow)
|
||||||
log.Println("gui.DumpBoxes()\tWindow.UiTab =", window.UiTab)
|
log.Println("gui.DumpBoxes()\tWindow.UiTab =", window.UiTab)
|
||||||
|
log.Println("gui.dumpBox() BoxMap START")
|
||||||
for name, abox := range window.BoxMap {
|
for name, abox := range window.BoxMap {
|
||||||
log.Printf("gui.DumpBoxes() \tBOX mapname=%-12s abox.Name=%-12s", name, abox.Name)
|
log.Printf("gui.DumpBoxes() \tBOX mapname=%-12s abox.Name=%-12s", name, abox.Name)
|
||||||
if name == "MAINBOX" {
|
if name == "MAINBOX" {
|
||||||
|
@ -189,6 +205,7 @@ func dumpBox(s string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
log.Println("gui.dumpBox() BoxMap END")
|
||||||
if window.UiTab != nil {
|
if window.UiTab != nil {
|
||||||
pages := window.UiTab.NumPages()
|
pages := window.UiTab.NumPages()
|
||||||
log.Println("gui.DumpBoxes()\tWindow.UiTab.NumPages() =", pages)
|
log.Println("gui.DumpBoxes()\tWindow.UiTab.NumPages() =", pages)
|
||||||
|
|
Loading…
Reference in New Issue