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) { func appendWithAttributes(newText *ui.AttributedString, what string, attrs ...ui.Attribute) {
start := len(newText.String()) start := len(newText.String())
end := start + len(what) end := start + len(what)

2
gui.go
View File

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

View File

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

View File

@ -10,17 +10,16 @@ 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() *ui.Box { func ShowSplashBox(newText *ui.AttributedString) *ui.Box {
newbox := ui.NewVerticalBox() newbox := ui.NewVerticalBox()
newbox.SetPadded(true) newbox.SetPadded(true)
// initialize the AreaHandler{} // initialize the AreaHandler{}
myAH = new(AreaHandler) Data.myAH = new(AreaHandler)
newText := makeAttributedString() Data.myAH.Attrstr = newText
myAH.Attrstr = newText makeSplashArea(Data.myAH)
makeSplashArea(myAH)
newbox.Append(myAH.Area, true) newbox.Append(Data.myAH.Area, true)
if runtime.GOOS == "linux" { if runtime.GOOS == "linux" {
newbox.Append(ui.NewLabel("OS: Linux"), false) 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 // be the safe way to interact with the GUI
// //
var Data GuiDataStructure var Data GuiDataStructure
var myAH *AreaHandler // var myAH *AreaHandler
type GuiDataStructure struct { type GuiDataStructure struct {
State string State string
@ -62,6 +62,7 @@ type GuiDataStructure struct {
cloudTab *ui.Tab cloudTab *ui.Tab
cloudBox *ui.Box cloudBox *ui.Box
smallBox *ui.Box smallBox *ui.Box
myAH *AreaHandler
tabcount int tabcount int