finally fix the window and tab names

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2019-06-04 00:56:58 -07:00
parent fc6bde460c
commit d86d25390d
2 changed files with 12 additions and 7 deletions

View File

@ -63,6 +63,7 @@ type GuiWindow struct {
Name string // field for human readable name Name string // field for human readable name
Width int Width int
Height int Height int
Axis int // does it add items to the X or Y axis
// the callback function to make the window contents // the callback function to make the window contents
MakeWindow func(*GuiWindow) *GuiBox MakeWindow func(*GuiWindow) *GuiBox

View File

@ -7,15 +7,18 @@ import "time"
import "github.com/andlabs/ui" import "github.com/andlabs/ui"
import _ "github.com/andlabs/ui/winmanifest" import _ "github.com/andlabs/ui/winmanifest"
func InitGuiWindow(name string, gw *GuiWindow) *GuiWindow { func InitGuiWindow(gw *GuiWindow) *GuiWindow {
log.Println("InitGuiWindow() START") log.Println("InitGuiWindow() START")
var newGuiWindow GuiWindow var newGuiWindow GuiWindow
newGuiWindow.Width = Config.Width newGuiWindow.Width = Config.Width
newGuiWindow.Height = Config.Height newGuiWindow.Height = Config.Height
newGuiWindow.Name = name
newGuiWindow.Axis = gw.Axis
newGuiWindow.MakeWindow = gw.MakeWindow newGuiWindow.MakeWindow = gw.MakeWindow
newGuiWindow.UiWindow = gw.UiWindow newGuiWindow.UiWindow = gw.UiWindow
newGuiWindow.UiTab = gw.UiTab newGuiWindow.UiTab = gw.UiTab
newGuiWindow.Name = gw.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 newGuiWindow.EntryMap["test"] = nil
@ -25,7 +28,7 @@ func InitGuiWindow(name string, gw *GuiWindow) *GuiWindow {
log.Println("gui.InitGuiWindow() making the Data.WindowMap here") log.Println("gui.InitGuiWindow() making the Data.WindowMap here")
Data.WindowMap = make(map[string]*GuiWindow) Data.WindowMap = make(map[string]*GuiWindow)
} }
Data.WindowMap[name] = &newGuiWindow Data.WindowMap[newGuiWindow.Name] = &newGuiWindow
if (Data.buttonMap == nil) { if (Data.buttonMap == nil) {
GuiInit() GuiInit()
@ -35,11 +38,13 @@ func InitGuiWindow(name string, gw *GuiWindow) *GuiWindow {
} }
func StartNewWindow(bg bool, name string, callback func(*GuiWindow) *GuiBox) { func StartNewWindow(bg bool, name string, axis int, callback func(*GuiWindow) *GuiBox) {
log.Println("StartNewWindow() Create a new window") log.Println("StartNewWindow() Create a new window")
var junk GuiWindow var junk GuiWindow
junk.MakeWindow = callback junk.MakeWindow = callback
window := InitGuiWindow(name, &junk) junk.Name = name
junk.Axis = axis
window := InitGuiWindow(&junk)
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() {
@ -59,7 +64,7 @@ func StartNewWindow(bg bool, name string, callback func(*GuiWindow) *GuiBox) {
func InitTabWindow(gw *GuiWindow) { func InitTabWindow(gw *GuiWindow) {
log.Println("InitTabWindow() START. THIS WINDOW IS NOT YET SHOWN") log.Println("InitTabWindow() START. THIS WINDOW IS NOT YET SHOWN")
gw.UiWindow = ui.NewWindow("InitTabWindow()", int(gw.Width), int(gw.Height), true) gw.UiWindow = ui.NewWindow(gw.Name, int(gw.Width), int(gw.Height), true)
gw.UiWindow.SetBorderless(false) gw.UiWindow.SetBorderless(false)
gw.UiWindow.OnClosing(func(*ui.Window) bool { gw.UiWindow.OnClosing(func(*ui.Window) bool {
@ -72,7 +77,6 @@ func InitTabWindow(gw *GuiWindow) {
gw.UiWindow.SetChild(gw.UiTab) gw.UiWindow.SetChild(gw.UiTab)
gw.UiWindow.SetMargined(true) gw.UiWindow.SetMargined(true)
box := gw.MakeWindow(gw) box := gw.MakeWindow(gw)
log.Println("InitTabWindow() END box =", box) log.Println("InitTabWindow() END box =", box)
log.Println("InitTabWindow() END gw =", gw) log.Println("InitTabWindow() END gw =", gw)