remove the myAH stand alone variable

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2019-05-29 11:25:25 -07:00
parent 64eada2638
commit bde27292ea
5 changed files with 25 additions and 14 deletions

View File

@ -63,6 +63,15 @@ func makeSplashArea(ah *AreaHandler) {
}
}
func AreaAppendText(newText *ui.AttributedString, what string, attrs ...ui.Attribute) {
start := len(newText.String())
end := start + len(what)
newText.AppendUnattributed(what)
for _, a := range attrs {
newText.SetAttribute(a, start, end)
}
}
func appendWithAttributes(newText *ui.AttributedString, what string, attrs ...ui.Attribute) {
start := len(newText.String())
end := start + len(what)

2
gui.go
View File

@ -232,7 +232,7 @@ func CreateFontButton(action string) *ButtonMap {
var newBM ButtonMap
newBM.Action = action
newBM.FB = newB
newBM.AH = myAH
newBM.AH = Data.myAH
Data.AllButtons = append(Data.AllButtons, newBM)
newB.OnChanged(func (*ui.FontButton) {

View File

@ -215,16 +215,17 @@ func makeCloudWindow() {
// cloudWindow.SetBorderless(true)
// create a 'fake' button entry for the mouse clicks
var newButtonMap ButtonMap
newButtonMap.Action = "QUIT"
Data.AllButtons = append(Data.AllButtons, newButtonMap)
var newBM ButtonMap
newBM.Action = "QUIT"
newBM.W = Data.cloudWindow
Data.AllButtons = append(Data.AllButtons, newBM)
Data.cloudWindow.OnClosing(func(*ui.Window) bool {
mouseClick(&newButtonMap)
mouseClick(&newBM)
return true
})
ui.OnShouldQuit(func() bool {
mouseClick(&newButtonMap)
mouseClick(&newBM)
return true
})
@ -232,7 +233,8 @@ func makeCloudWindow() {
Data.cloudWindow.SetChild(Data.cloudTab)
Data.cloudWindow.SetMargined(true)
Data.cloudBox = ShowSplashBox()
text := makeAttributedString()
Data.cloudBox = ShowSplashBox(text)
Data.cloudTab.Append("WIT Splash", Data.cloudBox)
Data.cloudTab.SetMargined(0, true)

View File

@ -10,17 +10,16 @@ import "runtime"
import "github.com/andlabs/ui"
import _ "github.com/andlabs/ui/winmanifest"
func ShowSplashBox() *ui.Box {
func ShowSplashBox(newText *ui.AttributedString) *ui.Box {
newbox := ui.NewVerticalBox()
newbox.SetPadded(true)
// initialize the AreaHandler{}
myAH = new(AreaHandler)
newText := makeAttributedString()
myAH.Attrstr = newText
makeSplashArea(myAH)
Data.myAH = new(AreaHandler)
Data.myAH.Attrstr = newText
makeSplashArea(Data.myAH)
newbox.Append(myAH.Area, true)
newbox.Append(Data.myAH.Area, true)
if runtime.GOOS == "linux" {
newbox.Append(ui.NewLabel("OS: Linux"), false)

View File

@ -13,7 +13,7 @@ import pb "git.wit.com/wit/witProtobuf"
// be the safe way to interact with the GUI
//
var Data GuiDataStructure
var myAH *AreaHandler
// var myAH *AreaHandler
type GuiDataStructure struct {
State string
@ -62,6 +62,7 @@ type GuiDataStructure struct {
cloudTab *ui.Tab
cloudBox *ui.Box
smallBox *ui.Box
myAH *AreaHandler
tabcount int