more deletions of old stuff

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2019-06-02 15:49:52 -07:00
parent 1274211f20
commit 1366012bc9
6 changed files with 24 additions and 42 deletions

View File

@ -24,9 +24,9 @@ func makeGenericArea(gb *GuiBox, newText *ui.AttributedString, custom func(*GuiB
gw.Area.UiAttrstr = newText gw.Area.UiAttrstr = newText
gw.Area.UiArea = ui.NewArea(gw.Area) gw.Area.UiArea = ui.NewArea(gw.Area)
if (Data.Debug) { if (Config.Debug) {
spew.Dump(gw.Area.UiArea) spew.Dump(gw.Area.UiArea)
log.Println("DEBUGGING", Data.Debug) log.Println("DEBUGGING", Config.Debug)
} else { } else {
log.Println("NOT DEBUGGING AREA mhAH.Button =", gw.Area.Button) log.Println("NOT DEBUGGING AREA mhAH.Button =", gw.Area.Button)
} }
@ -62,7 +62,7 @@ func (ah GuiArea) Draw(a *ui.Area, p *ui.AreaDrawParams) {
} }
func (ah GuiArea) MouseEvent(a *ui.Area, me *ui.AreaMouseEvent) { func (ah GuiArea) MouseEvent(a *ui.Area, me *ui.AreaMouseEvent) {
if (Data.Debug) { if (Config.Debug) {
log.Println("GOT MouseEvent() ah.Button =", ah.Button) log.Println("GOT MouseEvent() ah.Button =", ah.Button)
spew.Dump(me) spew.Dump(me)
} }

View File

@ -21,7 +21,7 @@ import pb "git.wit.com/wit/witProtobuf"
func defaultButtonClick(button *ui.Button) { func defaultButtonClick(button *ui.Button) {
log.Println("gui.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 (Config.Debug) {
log.Println("gui.defaultButtonClick() Data.AllButtons =", key, foo) log.Println("gui.defaultButtonClick() Data.AllButtons =", key, foo)
// spew.Dump(foo) // spew.Dump(foo)
} }
@ -32,7 +32,7 @@ func defaultButtonClick(button *ui.Button) {
} }
} }
log.Println("\tgui.defaultButtonClick() ERROR: BUTTON NOT FOUND") log.Println("\tgui.defaultButtonClick() ERROR: BUTTON NOT FOUND")
if (Data.Debug) { if (Config.Debug) {
panic("gui.defaultButtonClick() ERROR: UNMAPPED ui.Button") panic("gui.defaultButtonClick() ERROR: UNMAPPED ui.Button")
} }
} }
@ -65,7 +65,6 @@ func CreateButton(box *GuiBox, a *pb.Account, vm *pb.Event_VM, name string, acti
newB.Account = a newB.Account = a
newB.VM = vm newB.VM = vm
newB.Box = box newB.Box = box
// newB.GW = box.Window
newB.Action = action newB.Action = action
newB.Custom = custom newB.Custom = custom
Data.AllButtons = append(Data.AllButtons, newB) Data.AllButtons = append(Data.AllButtons, newB)

View File

@ -105,7 +105,7 @@ func AddEntry(box *GuiBox, name string) *GuiEntry {
func defaultEntryChange(e *ui.Entry) { func defaultEntryChange(e *ui.Entry) {
for key, em := range Data.AllEntries { for key, em := range Data.AllEntries {
if (Data.Debug) { if (Config.Debug) {
log.Println("\tdefaultEntryChange() Data.AllEntries =", key, em) log.Println("\tdefaultEntryChange() Data.AllEntries =", key, em)
} }
if Data.AllEntries[key].UiEntry == e { if Data.AllEntries[key].UiEntry == e {

12
gui.go
View File

@ -8,8 +8,6 @@ import "regexp"
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" // import "github.com/davecgh/go-spew/spew"
const Xaxis = 0 const Xaxis = 0
@ -24,11 +22,11 @@ func GuiInit() {
} }
// func InitGuiWindow(c *pb.Config, action string, maketab func(*GuiWindow) *GuiBox, uiW *ui.Window, uiT *ui.Tab) *GuiWindow { // func InitGuiWindow(c *pb.Config, action string, maketab func(*GuiWindow) *GuiBox, uiW *ui.Window, uiT *ui.Tab) *GuiWindow {
func InitGuiWindow(c *pb.Config, 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
newGuiWindow.Width = int(c.Width) newGuiWindow.Width = Config.Width
newGuiWindow.Height = int(c.Height) newGuiWindow.Height = Config.Height
newGuiWindow.Action = action newGuiWindow.Action = action
newGuiWindow.MakeWindow = gw.MakeWindow newGuiWindow.MakeWindow = gw.MakeWindow
newGuiWindow.UiWindow = gw.UiWindow newGuiWindow.UiWindow = gw.UiWindow
@ -43,11 +41,11 @@ func InitGuiWindow(c *pb.Config, action string, gw *GuiWindow) *GuiWindow {
} }
func StartNewWindow(c *pb.Config, bg bool, action string, callback func(*GuiWindow) *GuiBox) { 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
window := InitGuiWindow(c, 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()")
go ui.Main(func() { go ui.Main(func() {

View File

@ -14,6 +14,14 @@ 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 GuiData var Data GuiData
var Config GuiConfig
type GuiConfig struct {
Width int
Height int
Debug bool
DebugTable bool
}
type GuiData struct { type GuiData struct {
State string // used like a state machine State string // used like a state machine
@ -22,24 +30,6 @@ type GuiData struct {
// if nothing else is defined to handle them // if nothing else is defined to handle them
MouseClick func(*GuiButton) MouseClick func(*GuiButton)
// passes in all the User accounts from the cloud-control-panel config file
Config *pb.Config
// general information on the App
// move all this to Config (?)
Version string
GitCommit string
GoVersion string
Buildtime string
HomeDir string
Debug bool
DebugTable bool
// official hostname and IPv6 address for this box
// also move all this to Config (?)
Hostname string
IPv6 string
// A map of all the entry boxes // A map of all the entry boxes
AllEntries []*GuiEntry AllEntries []*GuiEntry
Windows []*GuiWindow Windows []*GuiWindow
@ -51,10 +41,6 @@ type GuiData struct {
// This has to work this way because of how // This has to work this way because of how
// andlabs/ui & andlabs/libui work // andlabs/ui & andlabs/libui work
AllButtons []*GuiButton AllButtons []*GuiButton
EntryNick *ui.Entry
EntryUser *ui.Entry
EntryPass *ui.Entry
} }
// //
@ -111,7 +97,6 @@ type GuiButton struct {
Name string // field for human readable name Name string // field for human readable name
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
// GW *GuiWindow // what window the button click was in (redundant?)
Account *pb.Account // associated with what account? Account *pb.Account // associated with what account?
VM *pb.Event_VM // associated with which VM? VM *pb.Event_VM // associated with which VM?

View File

@ -15,7 +15,7 @@ import "github.com/andlabs/ui"
import _ "github.com/andlabs/ui/winmanifest" import _ "github.com/andlabs/ui/winmanifest"
func (mh *TableData) NumRows(m *ui.TableModel) int { func (mh *TableData) NumRows(m *ui.TableModel) int {
if (Data.Debug) { if (Config.Debug) {
log.Println("NumRows = mh.RowCount = ", mh.RowCount, "(last Row & Column =", mh.lastRow, mh.lastColumn, ")") log.Println("NumRows = mh.RowCount = ", mh.RowCount, "(last Row & Column =", mh.lastRow, mh.lastColumn, ")")
} }
return mh.RowCount return mh.RowCount
@ -23,7 +23,7 @@ func (mh *TableData) NumRows(m *ui.TableModel) int {
// FYI: this routine seems to be called around 10 to 100 times a second for each table // FYI: this routine seems to be called around 10 to 100 times a second for each table
func (mh *TableData) ColumnTypes(m *ui.TableModel) []ui.TableValue { func (mh *TableData) ColumnTypes(m *ui.TableModel) []ui.TableValue {
if (Data.DebugTable) { if (Config.DebugTable) {
log.Println("ColumnTypes = ", mh.generatedColumnTypes) log.Println("ColumnTypes = ", mh.generatedColumnTypes)
} }
return mh.generatedColumnTypes return mh.generatedColumnTypes
@ -44,7 +44,7 @@ func libuiColorToGOlangColor(rgba color.RGBA) ui.TableColor {
// TODO: Figure out why this is being called 1000 times a second (10 times for each row & column) // TODO: Figure out why this is being called 1000 times a second (10 times for each row & column)
// Nevermind this TODO. Who gives a shit. This is a really smart way to treat the OS toolkits // Nevermind this TODO. Who gives a shit. This is a really smart way to treat the OS toolkits
func (mh *TableData) CellValue(m *ui.TableModel, row, column int) ui.TableValue { func (mh *TableData) CellValue(m *ui.TableModel, row, column int) ui.TableValue {
if (Data.DebugTable) { if (Config.DebugTable) {
log.Println("CellValue() row, column =", row, column) log.Println("CellValue() row, column =", row, column)
} }
mh.lastRow = row mh.lastRow = row
@ -68,7 +68,7 @@ func (mh *TableData) CellValue(m *ui.TableModel, row, column int) ui.TableValue
} }
bgcolor := libuiColorToGOlangColor(mh.Rows[row].HumanData[humanID].Color) bgcolor := libuiColorToGOlangColor(mh.Rows[row].HumanData[humanID].Color)
if (Data.Debug) { if (Config.Debug) {
log.Println("CellValue() BGCOLOR =", bgcolor) log.Println("CellValue() BGCOLOR =", bgcolor)
} }
return bgcolor return bgcolor
@ -112,7 +112,7 @@ func defaultSetCellValue(mh *TableData, row int, column int) {
return return
} }
log.Println("defaultSetCellValue() ERROR: UNKNOWN BUTTON IN TABLE") log.Println("defaultSetCellValue() ERROR: UNKNOWN BUTTON IN TABLE")
if (Data.Debug) { if (Config.Debug) {
panic("defaultSetCellValue() GOT AN UNKNOWN BUTTON CLICK IN TABLE") panic("defaultSetCellValue() GOT AN UNKNOWN BUTTON CLICK IN TABLE")
} }
} }