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
Width int
Height int
Axis int // does it add items to the X or Y axis
// the callback function to make the window contents
MakeWindow func(*GuiWindow) *GuiBox

View File

@ -7,15 +7,18 @@ import "time"
import "github.com/andlabs/ui"
import _ "github.com/andlabs/ui/winmanifest"
func InitGuiWindow(name string, gw *GuiWindow) *GuiWindow {
func InitGuiWindow(gw *GuiWindow) *GuiWindow {
log.Println("InitGuiWindow() START")
var newGuiWindow GuiWindow
newGuiWindow.Width = Config.Width
newGuiWindow.Height = Config.Height
newGuiWindow.Name = name
newGuiWindow.Axis = gw.Axis
newGuiWindow.MakeWindow = gw.MakeWindow
newGuiWindow.UiWindow = gw.UiWindow
newGuiWindow.UiTab = gw.UiTab
newGuiWindow.Name = gw.Name
newGuiWindow.BoxMap = make(map[string]*GuiBox)
newGuiWindow.EntryMap = make(map[string]*GuiEntry)
newGuiWindow.EntryMap["test"] = nil
@ -25,7 +28,7 @@ func InitGuiWindow(name string, gw *GuiWindow) *GuiWindow {
log.Println("gui.InitGuiWindow() making the Data.WindowMap here")
Data.WindowMap = make(map[string]*GuiWindow)
}
Data.WindowMap[name] = &newGuiWindow
Data.WindowMap[newGuiWindow.Name] = &newGuiWindow
if (Data.buttonMap == nil) {
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")
var junk GuiWindow
junk.MakeWindow = callback
window := InitGuiWindow(name, &junk)
junk.Name = name
junk.Axis = axis
window := InitGuiWindow(&junk)
if (bg) {
log.Println("StartNewWindow() START NEW GOROUTINE for ui.Main()")
go ui.Main(func() {
@ -59,7 +64,7 @@ func StartNewWindow(bg bool, name string, callback func(*GuiWindow) *GuiBox) {
func InitTabWindow(gw *GuiWindow) {
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.OnClosing(func(*ui.Window) bool {
@ -72,7 +77,6 @@ func InitTabWindow(gw *GuiWindow) {
gw.UiWindow.SetChild(gw.UiTab)
gw.UiWindow.SetMargined(true)
box := gw.MakeWindow(gw)
log.Println("InitTabWindow() END box =", box)
log.Println("InitTabWindow() END gw =", gw)