spash screen works again

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2019-06-01 21:15:55 -07:00
parent 2f3455c8aa
commit d95e62aaea
5 changed files with 54 additions and 34 deletions

21
area.go
View File

@ -9,7 +9,7 @@ import "github.com/davecgh/go-spew/spew"
// THIS IS CLEAN // 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) // make this button just to get the default font (but don't display the button)
// There should be another way to do this (?) // There should be another way to do this (?)
var newB *GuiButton var newB *GuiButton
@ -115,21 +115,10 @@ func ShowTextBox(gw *GuiWindow, newText *ui.AttributedString) *GuiBox {
} }
log.Println("ShowTextBox() START gw =", gw) log.Println("ShowTextBox() START gw =", gw)
// create and setup a new GuiBox box := InitGuiBox(gw, nil, ui.NewVerticalBox(), "SplashArea3")
var gb *GuiBox
gb = new(GuiBox)
// gw.EntryMap = make(map[string]*GuiEntry) makeGenericArea(box, newText)
// gw.EntryMap["test"] = nil box.UiBox.Append(box.Window.Area.UiArea, true)
newbox := ui.NewVerticalBox() return box
newbox.SetPadded(true)
gb.UiBox = newbox
gb.Window = gw
gw.BoxMap["Splash"] = gb
makeSplashArea(gb, newText)
newbox.Append(gw.Area.UiArea, true)
return gb
} }

View File

@ -6,6 +6,7 @@ import "fmt"
import "strings" import "strings"
import "os/exec" import "os/exec"
import "runtime" import "runtime"
import "reflect"
import "github.com/andlabs/ui" import "github.com/andlabs/ui"
import _ "github.com/andlabs/ui/winmanifest" import _ "github.com/andlabs/ui/winmanifest"
@ -148,3 +149,37 @@ func runCommand(cmdArgs []string) {
log.Println("runCommand() OTHERWISE INFORM THE USER") log.Println("runCommand() OTHERWISE INFORM THE USER")
log.Println("runCommand() END") 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)
}
}

18
gui.go
View File

@ -128,31 +128,31 @@ func ErrorWindow(gw *GuiWindow, msg1 string, msg2 string) {
// for the button and then call the function below // for the button and then call the function below
// //
func defaultButtonClick(button *ui.Button) { 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 { for key, foo := range Data.AllButtons {
if (Data.Debug) { if (Data.Debug) {
log.Println("defaultButtonClick() Data.AllButtons =", key, foo) log.Println("gui.defaultButtonClick() Data.AllButtons =", key, foo)
// spew.Dump(foo) // spew.Dump(foo)
} }
if Data.AllButtons[key].B == button { if Data.AllButtons[key].B == button {
log.Println("\tdefaultButtonClick() BUTTON MATCHED") log.Println("\tgui.defaultButtonClick() BUTTON MATCHED")
log.Println("\tdefaultButtonClick() Data.AllButtons[key].Action =", Data.AllButtons[key].Action) log.Println("\tgui.defaultButtonClick() Data.AllButtons[key].Action =", Data.AllButtons[key].Action)
if Data.AllButtons[key].custom != nil { 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]) Data.AllButtons[key].custom(Data.AllButtons[key])
return return
} }
if (Data.MouseClick != nil) { if (Data.MouseClick != nil) {
Data.MouseClick(Data.AllButtons[key]) Data.MouseClick(Data.AllButtons[key])
} else { } else {
log.Println("\tdefaultButtonClick() IGNORING BUTTON. MouseClick() is nil") log.Println("\tgui.defaultButtonClick() IGNORING BUTTON. MouseClick() is nil")
} }
return return
} }
} }
log.Println("\tdefaultButtonClick() BUTTON NOT FOUND") log.Println("\tgui.defaultButtonClick() BUTTON NOT FOUND")
if (Data.Debug) { 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.Action = action
newGB.FB = ui.NewFontButton() newGB.FB = ui.NewFontButton()
newGB.Box = box newGB.Box = box
newGB.Area = box.Window.Area // newGB.Area = box.Window.Area
Data.AllButtons = append(Data.AllButtons, &newGB) Data.AllButtons = append(Data.AllButtons, &newGB)
newGB.FB.OnChanged(func (*ui.FontButton) { newGB.FB.OnChanged(func (*ui.FontButton) {

10
misc.go
View File

@ -146,13 +146,11 @@ func InitTabWindow(gw *GuiWindow) {
// create a 'fake' button entry for the mouse clicks // create a 'fake' button entry for the mouse clicks
var newBM GuiButton var newBM GuiButton
newBM.Action = "QUIT" newBM.Action = "QUIT"
// newBM.W = gw.UiWindow
newBM.GW = gw newBM.GW = gw
Data.AllButtons = append(Data.AllButtons, &newBM) Data.AllButtons = append(Data.AllButtons, &newBM)
gw.UiWindow.OnClosing(func(*ui.Window) bool { gw.UiWindow.OnClosing(func(*ui.Window) bool {
log.Println("InitTabWindow() OnClosing() THIS WINDOW IS CLOSING gw=", gw) log.Println("InitTabWindow() OnClosing() THIS WINDOW IS CLOSING gw=", gw)
// mouseClick(&newBM)
ui.Quit() ui.Quit()
return true return true
}) })
@ -163,12 +161,12 @@ func InitTabWindow(gw *GuiWindow) {
log.Println("InitTabWindow() gw =", gw) log.Println("InitTabWindow() gw =", gw)
abox := gw.MakeWindow(gw) gw.MakeWindow(gw)
gw.UiTab.Append("WIT Splash", abox.UiBox) // abox := gw.MakeWindow(gw)
gw.UiTab.SetMargined(0, true) // gw.UiTab.Append("WIT Splash", abox.UiBox)
// gw.UiTab.SetMargined(0, true)
Data.State = "splash"
gw.UiWindow.Show() gw.UiWindow.Show()
} }

View File

@ -82,8 +82,6 @@ type GuiWindow struct {
Width int Width int
Height int Height int
// mainbox *ui.Box
// the callback function to make the window contents // the callback function to make the window contents
MakeWindow func(*GuiWindow) *GuiBox MakeWindow func(*GuiWindow) *GuiBox
@ -105,7 +103,7 @@ type GuiWindow struct {
type GuiButton struct { type GuiButton struct {
Action string // what type of button Action string // what type of button
Box *GuiBox // what box the button click was in 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?) GW *GuiWindow // what window the button click was in (redundant?)
Account *pb.Account // associated with what account? Account *pb.Account // associated with what account?