this is bad

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2019-06-13 15:30:54 -07:00
parent 17512c10c5
commit 30c49270d1
1 changed files with 15 additions and 23 deletions

View File

@ -9,33 +9,32 @@ import _ "github.com/andlabs/ui/winmanifest"
func StartNewWindow(bg bool, name string, axis int, callback func(*GuiBox) *GuiBox) { func StartNewWindow(bg bool, name string, axis int, callback func(*GuiBox) *GuiBox) {
log.Println("StartNewWindow() Create a new window") log.Println("StartNewWindow() Create a new window")
box := InitWindow(nil, name, axis)
box = callback(box)
window := box.Window
log.Println("StartNewWindow() box =", box)
if (bg) { if (bg) {
log.Println("StartNewWindow() START NEW GOROUTINE for ui.Main()") log.Println("StartNewWindow() START NEW GOROUTINE for ui.Main()")
go ui.Main(func() { go ui.Main(func() {
log.Println("gui.StartNewWindow() inside ui.Main()") log.Println("gui.StartNewWindow() inside ui.Main()")
go runWindow(name, axis, callback) go runWindow(window.UiWindow)
}) })
time.Sleep(2000 * time.Millisecond) // this might make it more stable on windows? time.Sleep(2000 * time.Millisecond) // this might make it more stable on windows?
} else { } else {
log.Println("StartNewWindow() WAITING for ui.Main()") log.Println("StartNewWindow() WAITING for ui.Main()")
ui.Main(func() { ui.Main(func() {
log.Println("gui.StartNewWindow() inside ui.Main()") log.Println("gui.StartNewWindow() inside ui.Main()")
runWindow(name, axis, callback) runWindow(window.UiWindow)
}) })
} }
} }
// This creates the raw andlabs/ui Window // This creates the raw andlabs/ui Window
func runWindow(name string, axis int, callback func(*GuiBox) *GuiBox) { func runWindow(uiWindow *ui.Window) {
log.Println("initTabWindow() START. THIS WINDOW IS NOT YET SHOWN") log.Println("runWindow() START ui.Window.Show()")
log.Println("initTabWindow() START. name =", name) uiWindow.Show()
box := InitWindow(nil, name, axis)
box = callback(box)
window := box.Window
log.Println("initTabWindow() END box =", box)
log.Println("initTabWindow() END gw =", window)
window.UiWindow.Show()
} }
func MessageWindow(gw *GuiWindow, msg1 string, msg2 string) { func MessageWindow(gw *GuiWindow, msg1 string, msg2 string) {
@ -64,13 +63,13 @@ func InitWindow(gw *GuiWindow, name string, axis int) *GuiBox {
var newGuiWindow GuiWindow var newGuiWindow GuiWindow
newGuiWindow.Height = Config.Height newGuiWindow.Height = Config.Height
newGuiWindow.Width = Config.Width newGuiWindow.Width = Config.Width
newGuiWindow.Height = 600 newGuiWindow.Axis = axis
newGuiWindow.Width = 800 newGuiWindow.Name = name
// This is the first window. One must create it here // This is the first window. One must create it here
if (gw == nil) { if (gw == nil) {
log.Println("initWindow() ADDING ui.NewWindow()") log.Println("initWindow() ADDING ui.NewWindow()")
newGuiWindow.UiWindow = ui.NewWindow(newGuiWindow.Name, int(newGuiWindow.Width), int(newGuiWindow.Height), true) newGuiWindow.UiWindow = ui.NewWindow(name, int(newGuiWindow.Width), int(newGuiWindow.Height), true)
newGuiWindow.UiWindow.SetBorderless(false) newGuiWindow.UiWindow.SetBorderless(false)
newGuiWindow.UiWindow.OnClosing(func(*ui.Window) bool { newGuiWindow.UiWindow.OnClosing(func(*ui.Window) bool {
@ -89,12 +88,9 @@ func InitWindow(gw *GuiWindow, name string, axis int) *GuiBox {
newGuiWindow.UiTab = gw.UiTab newGuiWindow.UiTab = gw.UiTab
} }
newGuiWindow.Axis = axis
newGuiWindow.Name = name
newGuiWindow.BoxMap = make(map[string]*GuiBox) newGuiWindow.BoxMap = make(map[string]*GuiBox)
newGuiWindow.EntryMap = make(map[string]*GuiEntry) newGuiWindow.EntryMap = make(map[string]*GuiEntry)
// newGuiWindow.EntryMap["test"] = nil
Data.Windows = append(Data.Windows, &newGuiWindow) Data.Windows = append(Data.Windows, &newGuiWindow)
if (newGuiWindow.UiTab == nil) { if (newGuiWindow.UiTab == nil) {
@ -107,17 +103,13 @@ func InitWindow(gw *GuiWindow, name string, axis int) *GuiBox {
Data.WindowMap[newGuiWindow.Name] = &newGuiWindow Data.WindowMap[newGuiWindow.Name] = &newGuiWindow
// if (Data.buttonMap == nil) {
// GuiInit()
// }
log.Println("InitGuiWindow() END *GuiWindow =", &newGuiWindow)
var box *GuiBox var box *GuiBox
if (axis == Xaxis) { if (axis == Xaxis) {
box = HardBox(&newGuiWindow, Xaxis, name) box = HardBox(&newGuiWindow, Xaxis, name)
} else { } else {
box = HardBox(&newGuiWindow, Yaxis, name) box = HardBox(&newGuiWindow, Yaxis, name)
} }
log.Println("InitGuiWindow() END *GuiWindow =", &newGuiWindow)
return box return box
} }