more work on stability
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
cf74635790
commit
c634315046
10
area.go
10
area.go
|
@ -20,17 +20,17 @@ func findFB(button *ButtonMap) *ButtonMap {
|
||||||
return a
|
return a
|
||||||
}
|
}
|
||||||
|
|
||||||
func makeSplashArea(ah *AreaHandler) {
|
func makeSplashArea(wm *WindowMap, ah *AreaHandler) {
|
||||||
// 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 (?)
|
||||||
wm := ah.WM
|
newB := CreateFontButton(wm, "AREA")
|
||||||
newB := CreateFontButton(wm, "AREA")
|
|
||||||
|
|
||||||
// ah.Attrstr = makeAttributedString()
|
// ah.Attrstr = makeAttributedString()
|
||||||
ah.Area = ui.NewArea(ah)
|
ah.Area = ui.NewArea(ah)
|
||||||
newB.A = ah.Area
|
newB.A = ah.Area
|
||||||
Data.AllButtons[1].A = ah.Area
|
// Data.AllButtons[1].A = ah.Area
|
||||||
ah.Button = &Data.AllButtons[1]
|
// ah.Button = &Data.AllButtons[1]
|
||||||
|
ah.Button = newB
|
||||||
|
|
||||||
if (Data.Debug) {
|
if (Data.Debug) {
|
||||||
spew.Dump(ah.Area)
|
spew.Dump(ah.Area)
|
||||||
|
|
|
@ -3,7 +3,7 @@ package gui
|
||||||
import "log"
|
import "log"
|
||||||
import "time"
|
import "time"
|
||||||
import "regexp"
|
import "regexp"
|
||||||
import "reflect"
|
// import "reflect"
|
||||||
|
|
||||||
import "github.com/andlabs/ui"
|
import "github.com/andlabs/ui"
|
||||||
import _ "github.com/andlabs/ui/winmanifest"
|
import _ "github.com/andlabs/ui/winmanifest"
|
||||||
|
@ -224,79 +224,68 @@ func StartNewWindow(c *pb.Config, bg bool, action string) {
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
|
|
||||||
for i, aWM := range(Data.Windows) {
|
if (bg) {
|
||||||
log.Println(aWM)
|
log.Println("ShowWindow() IN NEW GOROUTINE")
|
||||||
if (aWM.W == nil) {
|
go ui.Main(func() {
|
||||||
log.Println("ShowWindow() THIS WINDOW IS NOT YET SHOWN i=", i)
|
InitWindow(&newWindowMap)
|
||||||
log.Println("ShowWindow() THIS WINDOW IS NOT YET SHOWN aWM=", reflect.TypeOf(aWM))
|
})
|
||||||
// Data.NewWindow = &aWM
|
time.Sleep(2000 * time.Millisecond)
|
||||||
// Data.NewWindow = i
|
} else {
|
||||||
// ui.Main(InitWindow)
|
log.Println("ShowWindow() WAITING for ui.Main()")
|
||||||
time.Sleep(200 * time.Millisecond)
|
ui.Main(func() {
|
||||||
if (bg) {
|
InitWindow(&newWindowMap)
|
||||||
ui.Main(func() {
|
})
|
||||||
InitWindow(Data.Windows[i], i)
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
ui.Main(func() {
|
|
||||||
InitWindow(Data.Windows[i], i)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getSplashText() *ui.AttributedString {
|
func getSplashText(a string) *ui.AttributedString {
|
||||||
var aText *ui.AttributedString
|
var aText *ui.AttributedString
|
||||||
aText = ui.NewAttributedString("Click to continue")
|
aText = ui.NewAttributedString(a)
|
||||||
return aText
|
return aText
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func InitWindow(wm *WindowMap, i int) {
|
func InitWindow(wm *WindowMap) {
|
||||||
log.Println("InitWindow() THIS WINDOW IS NOT YET SHOWN")
|
log.Println("InitWindow() THIS WINDOW IS NOT YET SHOWN")
|
||||||
// i := Data.NewWindow
|
|
||||||
log.Println("InitWindow() THIS WINDOW IS NOT YET SHOWN i=", i)
|
|
||||||
|
|
||||||
c := Data.Windows[i].C
|
c := wm.C
|
||||||
Data.Windows[i].W = ui.NewWindow("", int(c.Width), int(c.Height), true)
|
wm.W = ui.NewWindow("", int(c.Width), int(c.Height), true)
|
||||||
Data.Windows[i].W.SetBorderless(false)
|
wm.W.SetBorderless(false)
|
||||||
|
|
||||||
// create a 'fake' button entry for the mouse clicks
|
// create a 'fake' button entry for the mouse clicks
|
||||||
var newBM ButtonMap
|
var newBM ButtonMap
|
||||||
newBM.Action = "QUIT"
|
newBM.Action = "QUIT"
|
||||||
newBM.W = Data.Windows[i].W
|
newBM.W = wm.W
|
||||||
newBM.WM = Data.Windows[i]
|
newBM.WM = wm
|
||||||
Data.AllButtons = append(Data.AllButtons, newBM)
|
Data.AllButtons = append(Data.AllButtons, newBM)
|
||||||
|
|
||||||
Data.Windows[i].W.OnClosing(func(*ui.Window) bool {
|
wm.W.OnClosing(func(*ui.Window) bool {
|
||||||
log.Println("InitWindow() OnClosing() THIS WINDOW IS CLOSING i=", i)
|
log.Println("InitWindow() OnClosing() THIS WINDOW IS CLOSING wm=", wm)
|
||||||
// mouseClick(&newBM)
|
// mouseClick(&newBM)
|
||||||
ui.Quit()
|
ui.Quit()
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
|
|
||||||
Data.Windows[i].T = ui.NewTab()
|
wm.T = ui.NewTab()
|
||||||
Data.Windows[i].W.SetChild(Data.Windows[i].T)
|
wm.W.SetChild(wm.T)
|
||||||
Data.Windows[i].W.SetMargined(true)
|
wm.W.SetMargined(true)
|
||||||
|
|
||||||
log.Println("InitWindow() i =", i)
|
log.Println("InitWindow() wm =", wm)
|
||||||
log.Println("InitWindow() Data.Windows[i] =", Data.Windows[i])
|
log.Println("InitWindow() wm.Action =", wm.Action)
|
||||||
log.Println("InitWindow() Data.Windows[i].Action =", Data.Windows[i].Action)
|
|
||||||
|
|
||||||
if (Data.Windows[i].Action == "SPLASH") {
|
if (wm.Action == "SPLASH") {
|
||||||
log.Println("InitWindow() TRYING SPLASH")
|
log.Println("InitWindow() TRYING SPLASH")
|
||||||
tmp := getSplashText()
|
damnit := "click" + string(c.Hostname)
|
||||||
|
tmp := getSplashText(damnit)
|
||||||
log.Println("InitWindow() TRYING SPLASH tmp =", tmp)
|
log.Println("InitWindow() TRYING SPLASH tmp =", tmp)
|
||||||
Data.Windows[i].Box1 = ShowSplashBox(Data.Windows[i], i, tmp)
|
wm.Box1 = ShowSplashBox(wm, tmp)
|
||||||
|
|
||||||
Data.Windows[i].T.Append("WIT Splash", Data.Windows[i].Box1)
|
wm.T.Append("WIT Splash", wm.Box1)
|
||||||
Data.Windows[i].T.SetMargined(0, true)
|
wm.T.SetMargined(0, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
Data.Windows[i].W.Show()
|
|
||||||
Data.State = "splash"
|
Data.State = "splash"
|
||||||
|
wm.W.Show()
|
||||||
}
|
}
|
||||||
|
|
||||||
// makeEntryBox(box, "hostname:", "blah.foo.org") {
|
// makeEntryBox(box, "hostname:", "blah.foo.org") {
|
||||||
|
|
12
splash.go
12
splash.go
|
@ -11,7 +11,7 @@ import "runtime"
|
||||||
import "github.com/andlabs/ui"
|
import "github.com/andlabs/ui"
|
||||||
import _ "github.com/andlabs/ui/winmanifest"
|
import _ "github.com/andlabs/ui/winmanifest"
|
||||||
|
|
||||||
func ShowSplashBox(wm *WindowMap, i int, newText *ui.AttributedString) *ui.Box {
|
func ShowSplashBox(wm *WindowMap, newText *ui.AttributedString) *ui.Box {
|
||||||
log.Println("ShowSplashBox() START")
|
log.Println("ShowSplashBox() START")
|
||||||
log.Println("ShowSplashBox() START wm =", wm)
|
log.Println("ShowSplashBox() START wm =", wm)
|
||||||
if (wm == nil) {
|
if (wm == nil) {
|
||||||
|
@ -23,12 +23,12 @@ func ShowSplashBox(wm *WindowMap, i int, newText *ui.AttributedString) *ui.Box {
|
||||||
newbox.SetPadded(true)
|
newbox.SetPadded(true)
|
||||||
|
|
||||||
// initialize the AreaHandler{}
|
// initialize the AreaHandler{}
|
||||||
Data.Windows[i].AH = new(AreaHandler)
|
wm.AH = new(AreaHandler)
|
||||||
Data.Windows[i].AH.WM = wm
|
wm.AH.WM = wm
|
||||||
Data.Windows[i].AH.Attrstr = newText
|
wm.AH.Attrstr = newText
|
||||||
makeSplashArea(Data.Windows[i].AH)
|
makeSplashArea(wm, wm.AH)
|
||||||
|
|
||||||
newbox.Append(Data.Windows[i].AH.Area, true)
|
newbox.Append(wm.AH.Area, true)
|
||||||
|
|
||||||
if runtime.GOOS == "linux" {
|
if runtime.GOOS == "linux" {
|
||||||
newbox.Append(ui.NewLabel("OS: Linux"), false)
|
newbox.Append(ui.NewLabel("OS: Linux"), false)
|
||||||
|
|
|
@ -17,8 +17,8 @@ var Data GuiData
|
||||||
|
|
||||||
type GuiData struct {
|
type GuiData struct {
|
||||||
State string
|
State string
|
||||||
Width int
|
// Width int
|
||||||
Height int
|
// Height int
|
||||||
|
|
||||||
// a fallback default function to handle mouse events
|
// a fallback default function to handle mouse events
|
||||||
// if nothing else is defined to handle them
|
// if nothing else is defined to handle them
|
||||||
|
|
Loading…
Reference in New Issue