see if an interface can store the outside values

also finally fixed the splash area logic

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2019-06-02 19:49:17 -07:00
parent 1366012bc9
commit 5536e659ae
7 changed files with 47 additions and 39 deletions

20
area.go
View File

@ -14,7 +14,6 @@ func makeGenericArea(gb *GuiBox, newText *ui.AttributedString, custom func(*GuiB
newB = CreateFontButton(gb, "AREA") newB = CreateFontButton(gb, "AREA")
newB.Box = gb newB.Box = gb
newB.Custom = custom newB.Custom = custom
// newB.GW = gb.Window
gw := gb.Window gw := gb.Window
// initialize the GuiArea{} // initialize the GuiArea{}
@ -116,10 +115,21 @@ func ShowTextBox(gw *GuiWindow, newText *ui.AttributedString, custom func(*GuiBu
} }
log.Println("ShowTextBox() START gw =", gw) log.Println("ShowTextBox() START gw =", gw)
box := InitGuiBox(gw, nil, ui.NewVerticalBox(), "SplashArea3") var newbox *GuiBox
newbox = new(GuiBox)
newbox.Window = gw
newbox.Name = "Hbox1"
hbox := ui.NewVerticalBox()
newbox.UiBox = hbox
makeGenericArea(box, newText, custom) // TODO: allow padded & axis here
box.UiBox.Append(box.Window.Area.UiArea, true) hbox.SetPadded(true)
return box add(gw.BoxMap["MAINBOX"], newbox)
// box := InitGuiBox(gw, nil, ui.NewVerticalBox(), "SplashArea3")
makeGenericArea(newbox, newText, custom)
newbox.UiBox.Append(newbox.Window.Area.UiArea, true)
return newbox
} }

3
box.go
View File

@ -5,9 +5,6 @@ import "log"
import "github.com/andlabs/ui" import "github.com/andlabs/ui"
import _ "github.com/andlabs/ui/winmanifest" import _ "github.com/andlabs/ui/winmanifest"
// import pb "git.wit.com/wit/witProtobuf"
// import "github.com/davecgh/go-spew/spew"
// add(nil, newbox, "") // use this when the Window is created. Always called 'MAINBOX' // add(nil, newbox, "") // use this when the Window is created. Always called 'MAINBOX'
// add(gw.BoxMap["MAINBOX"], newbox, name) // use this to add a box off the main box // add(gw.BoxMap["MAINBOX"], newbox, name) // use this to add a box off the main box
// add(gw.BoxMap["BUTTONBOX"], newbox, name) // use this to add something to the box called 'BUTTONBOX' // add(gw.BoxMap["BUTTONBOX"], newbox, name) // use this to add something to the box called 'BUTTONBOX'

View File

@ -73,6 +73,27 @@ func CreateButton(box *GuiBox, a *pb.Account, vm *pb.Event_VM, name string, acti
return newB return newB
} }
func NewCreateButton(box *GuiBox, custom func(*GuiButton), name string, values interface {}) *GuiButton {
newUiB := ui.NewButton(name)
newUiB.OnClicked(defaultButtonClick)
var newB *GuiButton
newB = new(GuiButton)
newB.B = newUiB
if (box.Window == nil) {
log.Println("CreateButton() box.Window == nil")
panic("crap")
}
newB.Box = box
newB.Custom = custom
newB.Values = values
Data.AllButtons = append(Data.AllButtons, newB)
box.UiBox.Append(newB.B, false)
return newB
}
func CreateFontButton(box *GuiBox, action string) *GuiButton { func CreateFontButton(box *GuiBox, action string) *GuiButton {
// create a 'fake' button entry for the mouse clicks // create a 'fake' button entry for the mouse clicks
var newGB GuiButton var newGB GuiButton

View File

@ -6,7 +6,6 @@ import "fmt"
import "github.com/andlabs/ui" import "github.com/andlabs/ui"
import _ "github.com/andlabs/ui/winmanifest" import _ "github.com/andlabs/ui/winmanifest"
import "github.com/davecgh/go-spew/spew" import "github.com/davecgh/go-spew/spew"
// import pb "git.wit.com/wit/witProtobuf"
// THIS IS CLEAN (except the 'Memory' normalization example) // THIS IS CLEAN (except the 'Memory' normalization example)

23
gui.go
View File

@ -3,25 +3,20 @@ package gui
import "log" import "log"
import "time" import "time"
import "regexp" import "regexp"
// import "os"
import "github.com/andlabs/ui" import "github.com/andlabs/ui"
import _ "github.com/andlabs/ui/winmanifest" import _ "github.com/andlabs/ui/winmanifest"
// import "github.com/davecgh/go-spew/spew"
const Xaxis = 0 const Xaxis = 0
const Yaxis = 1 const Yaxis = 1
func GuiInit() { func GuiInit() {
ui.OnShouldQuit(func() bool { ui.OnShouldQuit(func() bool {
// mouseClick(&newBM)
ui.Quit() ui.Quit()
return true return true
}) })
} }
// func InitGuiWindow(c *pb.Config, action string, maketab func(*GuiWindow) *GuiBox, uiW *ui.Window, uiT *ui.Tab) *GuiWindow {
func InitGuiWindow(action string, gw *GuiWindow) *GuiWindow { func InitGuiWindow(action string, gw *GuiWindow) *GuiWindow {
log.Println("InitGuiWindow() START") log.Println("InitGuiWindow() START")
var newGuiWindow GuiWindow var newGuiWindow GuiWindow
@ -45,6 +40,7 @@ func StartNewWindow(bg bool, action string, callback func(*GuiWindow) *GuiBox) {
log.Println("StartNewWindow() Create a new window") log.Println("StartNewWindow() Create a new window")
var junk GuiWindow var junk GuiWindow
junk.MakeWindow = callback junk.MakeWindow = callback
junk.Action = action
window := InitGuiWindow(action, &junk) window := InitGuiWindow(action, &junk)
if (bg) { if (bg) {
log.Println("StartNewWindow() START NEW GOROUTINE for ui.Main()") log.Println("StartNewWindow() START NEW GOROUTINE for ui.Main()")
@ -63,19 +59,11 @@ func StartNewWindow(bg bool, action string, callback func(*GuiWindow) *GuiBox) {
} }
func InitTabWindow(gw *GuiWindow) { func InitTabWindow(gw *GuiWindow) {
log.Println("InitTabWindow() THIS WINDOW IS NOT YET SHOWN") log.Println("InitTabWindow() START. THIS WINDOW IS NOT YET SHOWN")
gw.UiWindow = ui.NewWindow("", int(gw.Width), int(gw.Height), true) gw.UiWindow = ui.NewWindow("InitTabWindow()", int(gw.Width), int(gw.Height), true)
gw.UiWindow.SetBorderless(false) gw.UiWindow.SetBorderless(false)
// create a 'fake' button entry for the mouse clicks
/*
var newBM GuiButton
newBM.Action = "QUIT"
newBM.GW = gw
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)
ui.Quit() ui.Quit()
@ -86,9 +74,10 @@ func InitTabWindow(gw *GuiWindow) {
gw.UiWindow.SetChild(gw.UiTab) gw.UiWindow.SetChild(gw.UiTab)
gw.UiWindow.SetMargined(true) gw.UiWindow.SetMargined(true)
log.Println("InitTabWindow() gw =", gw)
gw.MakeWindow(gw) box := gw.MakeWindow(gw)
log.Println("InitTabWindow() END box =", box)
log.Println("InitTabWindow() END gw =", gw)
gw.UiWindow.Show() gw.UiWindow.Show()
} }

View File

@ -95,14 +95,15 @@ type GuiBox struct {
// call this 'GuiMouseClick' // call this 'GuiMouseClick'
type GuiButton struct { type GuiButton struct {
Name string // field for human readable name Name string // field for human readable name
Action string // what type of button
Box *GuiBox // what box the button click was in Box *GuiBox // what box the button click was in
Account *pb.Account // associated with what account?
VM *pb.Event_VM // associated with which VM?
// a callback function for the main application // a callback function for the main application
Custom func (*GuiButton) Custom func (*GuiButton)
Values interface {}
Action string // what type of button
Account *pb.Account // associated with what account?
VM *pb.Event_VM // associated with which VM?
// andlabs/ui abstraction mapping // andlabs/ui abstraction mapping
B *ui.Button B *ui.Button
@ -119,9 +120,6 @@ type GuiEntry struct {
B *GuiButton B *GuiButton
Box *GuiBox Box *GuiBox
Account *pb.Account
VM *pb.Event_VM
// andlabs/ui abstraction mapping // andlabs/ui abstraction mapping
UiEntry *ui.Entry UiEntry *ui.Entry
} }
@ -170,7 +168,6 @@ type TableData struct {
Cells [20]CellData Cells [20]CellData
Human [20]HumanMap Human [20]HumanMap
Account *pb.Account // what account this table is for
Box *GuiBox Box *GuiBox
lastRow int lastRow int
@ -198,7 +195,6 @@ type HumanCellData struct {
TextID int TextID int
Color color.RGBA Color color.RGBA
ColorID int ColorID int
VM *pb.Event_VM
Button *GuiButton Button *GuiButton
} }
@ -232,9 +228,6 @@ type RowData struct {
doubleclick func() // what function to call if the user double clicks on it doubleclick func() // what function to call if the user double clicks on it
*/ */
HumanData [20]HumanCellData HumanData [20]HumanCellData
// The VM from the protobuf
VM *pb.Event_VM
} }
// //

View File

@ -97,7 +97,6 @@ func InitColumns(mh *TableData, parts []TableColumnData) {
} }
} }
// func AddTableTab(gw *GuiWindow, name string, rowcount int, parts []TableColumnData, account *pb.Account) *TableData {
func AddTableTab(gw *GuiWindow, name string, rowcount int, parts []TableColumnData) *TableData { func AddTableTab(gw *GuiWindow, name string, rowcount int, parts []TableColumnData) *TableData {
mh := new(TableData) mh := new(TableData)