From d95e62aaea2c1191f5e672ddacad5f9ad55db51d Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sat, 1 Jun 2019 21:15:55 -0700 Subject: [PATCH] spash screen works again Signed-off-by: Jeff Carr --- area.go | 21 +++++---------------- debug.go | 35 +++++++++++++++++++++++++++++++++++ gui.go | 18 +++++++++--------- misc.go | 10 ++++------ structs.go | 4 +--- 5 files changed, 54 insertions(+), 34 deletions(-) diff --git a/area.go b/area.go index c841219..1cd4284 100644 --- a/area.go +++ b/area.go @@ -9,7 +9,7 @@ import "github.com/davecgh/go-spew/spew" // THIS IS CLEAN -func makeSplashArea(gb *GuiBox, newText *ui.AttributedString) { +func makeGenericArea(gb *GuiBox, newText *ui.AttributedString) { // make this button just to get the default font (but don't display the button) // There should be another way to do this (?) var newB *GuiButton @@ -115,21 +115,10 @@ func ShowTextBox(gw *GuiWindow, newText *ui.AttributedString) *GuiBox { } log.Println("ShowTextBox() START gw =", gw) - // create and setup a new GuiBox - var gb *GuiBox - gb = new(GuiBox) + box := InitGuiBox(gw, nil, ui.NewVerticalBox(), "SplashArea3") -// gw.EntryMap = make(map[string]*GuiEntry) -// gw.EntryMap["test"] = nil + makeGenericArea(box, newText) + box.UiBox.Append(box.Window.Area.UiArea, true) - newbox := ui.NewVerticalBox() - newbox.SetPadded(true) - gb.UiBox = newbox - gb.Window = gw - gw.BoxMap["Splash"] = gb - - makeSplashArea(gb, newText) - newbox.Append(gw.Area.UiArea, true) - - return gb + return box } diff --git a/debug.go b/debug.go index 7ea50b8..dfaca26 100644 --- a/debug.go +++ b/debug.go @@ -6,6 +6,7 @@ import "fmt" import "strings" import "os/exec" import "runtime" +import "reflect" import "github.com/andlabs/ui" import _ "github.com/andlabs/ui/winmanifest" @@ -148,3 +149,37 @@ func runCommand(cmdArgs []string) { log.Println("runCommand() OTHERWISE INFORM THE USER") log.Println("runCommand() END") } + +// +// this watches the GUI primarily to process protobuf's +// this is pointless or wrong but I use it for debugging +// +func WatchGUI() { + count := 0 + + for { + if (count > 20) { + log.Println("Sleep() in watchGUI() Data.State =", Data.State) + for i, window := range Data.Windows { + log.Println("watchGUI() Data.Windows i =", i, "Action =", window.Action) + for name, abox := range window.BoxMap { + log.Println("\twatchGUI() BOX name =", name) + if (name == "SplashArea3") { + log.Println("\t\twatchGUI() BOX abox =", reflect.TypeOf(abox)) + win := abox.Window + log.Println("\t\twatchGUI() BOX win =", reflect.TypeOf(win)) + area := win.Area + log.Println("\t\twatchGUI() BOX area =", reflect.TypeOf(area), area.UiArea) + // spew.Dump(area.UiArea) + // area.UiArea.Show() + // time.Sleep(2000 * time.Millisecond) + // os.Exit(0) + } + } + } + count = 0 + } + count += 1 + time.Sleep(200 * time.Millisecond) + } +} diff --git a/gui.go b/gui.go index 49b9ab4..6695b40 100644 --- a/gui.go +++ b/gui.go @@ -128,31 +128,31 @@ func ErrorWindow(gw *GuiWindow, msg1 string, msg2 string) { // for the button and then call the function below // func defaultButtonClick(button *ui.Button) { - log.Println("defaultButtonClick() LOOK FOR BUTTON button =", button) + log.Println("gui.defaultButtonClick() LOOK FOR BUTTON button =", button) for key, foo := range Data.AllButtons { if (Data.Debug) { - log.Println("defaultButtonClick() Data.AllButtons =", key, foo) + log.Println("gui.defaultButtonClick() Data.AllButtons =", key, foo) // spew.Dump(foo) } if Data.AllButtons[key].B == button { - log.Println("\tdefaultButtonClick() BUTTON MATCHED") - log.Println("\tdefaultButtonClick() Data.AllButtons[key].Action =", Data.AllButtons[key].Action) + log.Println("\tgui.defaultButtonClick() BUTTON MATCHED") + log.Println("\tgui.defaultButtonClick() Data.AllButtons[key].Action =", Data.AllButtons[key].Action) if Data.AllButtons[key].custom != nil { - log.Println("\tdefaultButtonClick() DOING CUSTOM FUNCTION") + log.Println("\tgui.defaultButtonClick() DOING CUSTOM FUNCTION") Data.AllButtons[key].custom(Data.AllButtons[key]) return } if (Data.MouseClick != nil) { Data.MouseClick(Data.AllButtons[key]) } else { - log.Println("\tdefaultButtonClick() IGNORING BUTTON. MouseClick() is nil") + log.Println("\tgui.defaultButtonClick() IGNORING BUTTON. MouseClick() is nil") } return } } - log.Println("\tdefaultButtonClick() BUTTON NOT FOUND") + log.Println("\tgui.defaultButtonClick() BUTTON NOT FOUND") if (Data.Debug) { - panic("defaultButtonClick() SHOULD NOT HAVE UNMAPPED BUTTONS") + panic("gui.defaultButtonClick() SHOULD NOT HAVE UNMAPPED BUTTONS") } } @@ -197,7 +197,7 @@ func CreateFontButton(box *GuiBox, action string) *GuiButton { newGB.Action = action newGB.FB = ui.NewFontButton() newGB.Box = box - newGB.Area = box.Window.Area +// newGB.Area = box.Window.Area Data.AllButtons = append(Data.AllButtons, &newGB) newGB.FB.OnChanged(func (*ui.FontButton) { diff --git a/misc.go b/misc.go index 18d1f1a..62b6ac3 100644 --- a/misc.go +++ b/misc.go @@ -146,13 +146,11 @@ func InitTabWindow(gw *GuiWindow) { // create a 'fake' button entry for the mouse clicks var newBM GuiButton newBM.Action = "QUIT" -// newBM.W = gw.UiWindow newBM.GW = gw Data.AllButtons = append(Data.AllButtons, &newBM) gw.UiWindow.OnClosing(func(*ui.Window) bool { log.Println("InitTabWindow() OnClosing() THIS WINDOW IS CLOSING gw=", gw) - // mouseClick(&newBM) ui.Quit() return true }) @@ -163,12 +161,12 @@ func InitTabWindow(gw *GuiWindow) { log.Println("InitTabWindow() gw =", gw) - abox := gw.MakeWindow(gw) + gw.MakeWindow(gw) - gw.UiTab.Append("WIT Splash", abox.UiBox) - gw.UiTab.SetMargined(0, true) +// abox := gw.MakeWindow(gw) +// gw.UiTab.Append("WIT Splash", abox.UiBox) +// gw.UiTab.SetMargined(0, true) - Data.State = "splash" gw.UiWindow.Show() } diff --git a/structs.go b/structs.go index b036d83..360d59d 100644 --- a/structs.go +++ b/structs.go @@ -82,8 +82,6 @@ type GuiWindow struct { Width int Height int -// mainbox *ui.Box - // the callback function to make the window contents MakeWindow func(*GuiWindow) *GuiBox @@ -105,7 +103,7 @@ type GuiWindow struct { type GuiButton struct { Action string // what type of button Box *GuiBox // what box the button click was in - Area *GuiArea // indicates the button click was in an Area +// Area *GuiArea // indicates the button click was in an Area GW *GuiWindow // what window the button click was in (redundant?) Account *pb.Account // associated with what account?