start an Entries map
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
7ada34f221
commit
9453772d63
8
area.go
8
area.go
|
@ -13,24 +13,20 @@ func makeSplashArea() *ui.Area {
|
||||||
Data.fontButton = CreateFontButton("SplashFont", "DONE")
|
Data.fontButton = CreateFontButton("SplashFont", "DONE")
|
||||||
|
|
||||||
makeAttributedString()
|
makeAttributedString()
|
||||||
splashArea := ui.NewArea(myAH)
|
Data.splashArea = ui.NewArea(myAH)
|
||||||
|
|
||||||
// create a 'fake' button entry for the mouse clicks
|
// create a 'fake' button entry for the mouse clicks
|
||||||
var newmap ButtonMap
|
var newmap ButtonMap
|
||||||
newmap.Action = "AREA"
|
newmap.Action = "AREA"
|
||||||
newmap.A = splashArea
|
newmap.A = Data.splashArea
|
||||||
|
|
||||||
myAH.button = &newmap
|
myAH.button = &newmap
|
||||||
Data.AllButtons = append(Data.AllButtons, newmap)
|
Data.AllButtons = append(Data.AllButtons, newmap)
|
||||||
Data.splashArea = splashArea
|
|
||||||
|
|
||||||
if (Data.Debug) {
|
if (Data.Debug) {
|
||||||
spew.Dump(Data.splashArea)
|
spew.Dump(Data.splashArea)
|
||||||
log.Println("DEBUGGING", Data.Debug)
|
log.Println("DEBUGGING", Data.Debug)
|
||||||
} else {
|
} else {
|
||||||
log.Println("NOT DEBUGGING AREA mhAH.button =", myAH.button)
|
log.Println("NOT DEBUGGING AREA mhAH.button =", myAH.button)
|
||||||
log.Println("NOT DEBUGGING AREA mhAH.button =", myAH.button)
|
|
||||||
log.Println("NOT DEBUGGING AREA mhAH.button =", myAH.button)
|
|
||||||
}
|
}
|
||||||
return Data.splashArea
|
return Data.splashArea
|
||||||
}
|
}
|
||||||
|
|
|
@ -279,46 +279,59 @@ func AddVmConfigureTab(name string, pbVM *pb.Event_VM) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// makeEntryBox(box, "hostname:", "blah.foo.org") {
|
// makeEntryBox(box, "hostname:", "blah.foo.org") {
|
||||||
func makeEntryVbox(hbox *ui.Box, a string, b string, edit bool) {
|
func makeEntryVbox(hbox *ui.Box, a string, startValue string, edit bool, action string) {
|
||||||
// Start 'Nickname' vertical box
|
// Start 'Nickname' vertical box
|
||||||
vboxN := ui.NewVerticalBox()
|
vboxN := ui.NewVerticalBox()
|
||||||
vboxN.SetPadded(true)
|
vboxN.SetPadded(true)
|
||||||
vboxN.Append(ui.NewLabel(a), false)
|
vboxN.Append(ui.NewLabel(a), false)
|
||||||
|
|
||||||
entryNick := ui.NewEntry()
|
entryNick := defaultMakeEntry(startValue, edit, action)
|
||||||
entryNick.SetText(b)
|
|
||||||
if (edit == false) {
|
|
||||||
entryNick.SetReadOnly(true)
|
|
||||||
}
|
|
||||||
|
|
||||||
vboxN.Append(entryNick, false)
|
vboxN.Append(entryNick, false)
|
||||||
|
|
||||||
entryNick.OnChanged(func(*ui.Entry) {
|
|
||||||
log.Println("OK. TEXT WAS CHANGED TO =", entryNick.Text())
|
|
||||||
// Data.AccNick = entryNick.Text()
|
|
||||||
})
|
|
||||||
hbox.Append(vboxN, false)
|
hbox.Append(vboxN, false)
|
||||||
// End 'Nickname' vertical box
|
// End 'Nickname' vertical box
|
||||||
}
|
}
|
||||||
|
|
||||||
func makeEntryHbox(hbox *ui.Box, a string, b string, edit bool) {
|
func defaultEntryChange(e *ui.Entry) {
|
||||||
|
for key, foo := range Data.AllEntries {
|
||||||
|
if (Data.Debug) {
|
||||||
|
log.Println("\tdefaultEntryChange() Data.AllEntries =", key, foo)
|
||||||
|
}
|
||||||
|
if Data.AllEntries[key].E == e {
|
||||||
|
log.Println("defaultEntryChange() FOUND", "action =", Data.AllEntries[key].Action, "e.Text() =", e.Text())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log.Println("defaultEntryChange() ERROR. MISSING ENTRY MAP. e.Text() =", e.Text())
|
||||||
|
}
|
||||||
|
|
||||||
|
func defaultMakeEntry(startValue string, edit bool, action string) *ui.Entry {
|
||||||
|
e := ui.NewEntry()
|
||||||
|
e.SetText(startValue)
|
||||||
|
if (edit == false) {
|
||||||
|
e.SetReadOnly(true)
|
||||||
|
}
|
||||||
|
e.OnChanged(defaultEntryChange)
|
||||||
|
|
||||||
|
// add the entry field to the global map
|
||||||
|
var newEntryMap EntryMap
|
||||||
|
newEntryMap.E = e
|
||||||
|
newEntryMap.Edit = edit
|
||||||
|
newEntryMap.Action = action
|
||||||
|
Data.AllEntries = append(Data.AllEntries, newEntryMap)
|
||||||
|
|
||||||
|
return e
|
||||||
|
}
|
||||||
|
|
||||||
|
func makeEntryHbox(hbox *ui.Box, a string, startValue string, edit bool, action string) {
|
||||||
// Start 'Nickname' vertical box
|
// Start 'Nickname' vertical box
|
||||||
hboxN := ui.NewHorizontalBox()
|
hboxN := ui.NewHorizontalBox()
|
||||||
hboxN.SetPadded(true)
|
hboxN.SetPadded(true)
|
||||||
hboxN.Append(ui.NewLabel(a), false)
|
hboxN.Append(ui.NewLabel(a), false)
|
||||||
|
|
||||||
entryNick := ui.NewEntry()
|
entryNick := defaultMakeEntry(startValue, edit, action)
|
||||||
entryNick.SetText(b)
|
|
||||||
if (edit == false) {
|
|
||||||
entryNick.SetReadOnly(true)
|
|
||||||
}
|
|
||||||
|
|
||||||
hboxN.Append(entryNick, false)
|
hboxN.Append(entryNick, false)
|
||||||
|
|
||||||
entryNick.OnChanged(func(*ui.Entry) {
|
|
||||||
log.Println("OK. TEXT WAS CHANGED TO =", entryNick.Text())
|
|
||||||
// Data.AccNick = entryNick.Text()
|
|
||||||
})
|
|
||||||
hbox.Append(hboxN, false)
|
hbox.Append(hboxN, false)
|
||||||
// End 'Nickname' vertical box
|
// End 'Nickname' vertical box
|
||||||
}
|
}
|
||||||
|
@ -343,12 +356,12 @@ func CreateVmBox(tab *ui.Tab, vm *pb.Event_VM) {
|
||||||
vbox.Append(hboxAccount, false)
|
vbox.Append(hboxAccount, false)
|
||||||
|
|
||||||
// Add hostname entry box
|
// Add hostname entry box
|
||||||
makeEntryVbox(hboxAccount, "hostname:", vm.Hostname, true)
|
makeEntryVbox(hboxAccount, "hostname:", vm.Hostname, true, "Hostname")
|
||||||
makeEntryVbox(hboxAccount, "IPv6:", vm.IPv6, true)
|
makeEntryVbox(hboxAccount, "IPv6:", vm.IPv6, true, "IPv6")
|
||||||
makeEntryVbox(hboxAccount, "RAM:", fmt.Sprintf("%d",vm.Memory), true)
|
makeEntryVbox(hboxAccount, "RAM:", fmt.Sprintf("%d",vm.Memory), true, "Memory")
|
||||||
makeEntryVbox(hboxAccount, "CPU:", fmt.Sprintf("%d",vm.Cpus), true)
|
makeEntryVbox(hboxAccount, "CPU:", fmt.Sprintf("%d",vm.Cpus), true, "Cpus")
|
||||||
makeEntryVbox(hboxAccount, "Disk (GB):", fmt.Sprintf("%d",vm.Disk), true)
|
makeEntryVbox(hboxAccount, "Disk (GB):",fmt.Sprintf("%d",vm.Disk), true, "Disk")
|
||||||
makeEntryVbox(hboxAccount, "OS Image:", vm.BaseImage, true)
|
makeEntryVbox(hboxAccount, "OS Image:", vm.BaseImage, true, "BaseImage")
|
||||||
|
|
||||||
vbox.Append(ui.NewHorizontalSeparator(), false)
|
vbox.Append(ui.NewHorizontalSeparator(), false)
|
||||||
|
|
||||||
|
@ -379,7 +392,7 @@ func createAddVmBox(tab *ui.Tab, name string, b *ButtonMap) {
|
||||||
vbox.Append(hboxAccount, false)
|
vbox.Append(hboxAccount, false)
|
||||||
|
|
||||||
// Add hostname entry box
|
// Add hostname entry box
|
||||||
makeEntryHbox(hboxAccount, "hostname:", "", true)
|
makeEntryHbox(hboxAccount, "hostname:", "", true, "Hostname")
|
||||||
|
|
||||||
vbox.Append(ui.NewHorizontalSeparator(), false)
|
vbox.Append(ui.NewHorizontalSeparator(), false)
|
||||||
|
|
||||||
|
|
55
structs.go
55
structs.go
|
@ -15,24 +15,6 @@ import pb "git.wit.com/wit/witProtobuf"
|
||||||
var Data GuiDataStructure
|
var Data GuiDataStructure
|
||||||
var myAH areaHandler
|
var myAH areaHandler
|
||||||
|
|
||||||
/*
|
|
||||||
type GuiTabStructure struct {
|
|
||||||
me *ui.Tab
|
|
||||||
parentWindow *ui.Window
|
|
||||||
firstBox *ui.Box
|
|
||||||
tabOffset int
|
|
||||||
|
|
||||||
// this means only one table per tab
|
|
||||||
mh *TableData
|
|
||||||
|
|
||||||
// stuff for the 'area'
|
|
||||||
// this means only one area per tab
|
|
||||||
fontButton *ui.FontButton
|
|
||||||
attrstr *ui.AttributedString
|
|
||||||
splashArea *ui.Area
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
type GuiDataStructure struct {
|
type GuiDataStructure struct {
|
||||||
State string
|
State string
|
||||||
Width int
|
Width int
|
||||||
|
@ -42,7 +24,10 @@ type GuiDataStructure struct {
|
||||||
// if nothing else is defined to handle them
|
// if nothing else is defined to handle them
|
||||||
MouseClick func(*ButtonMap)
|
MouseClick func(*ButtonMap)
|
||||||
|
|
||||||
// general information
|
// account entry textboxes
|
||||||
|
Config *pb.Config
|
||||||
|
|
||||||
|
// general information on the App
|
||||||
Version string
|
Version string
|
||||||
GitCommit string
|
GitCommit string
|
||||||
GoVersion string
|
GoVersion string
|
||||||
|
@ -55,22 +40,19 @@ type GuiDataStructure struct {
|
||||||
Hostname string
|
Hostname string
|
||||||
IPv6 string
|
IPv6 string
|
||||||
|
|
||||||
// account entry textboxes
|
|
||||||
Config *pb.Config
|
|
||||||
|
|
||||||
// A map of all buttons everywhere on all
|
// A map of all buttons everywhere on all
|
||||||
// windows, all tabs, across all goroutines
|
// windows, all tabs, across all goroutines
|
||||||
// This is "GLOBAL"
|
// This is "GLOBAL"
|
||||||
AllButtons []ButtonMap
|
AllButtons []ButtonMap
|
||||||
|
|
||||||
|
// A map of all the entry boxes
|
||||||
|
AllEntries []EntryMap
|
||||||
|
|
||||||
// a VM (maybe the one the user is playing with?)
|
// a VM (maybe the one the user is playing with?)
|
||||||
// if opening a new window, this is a trick to
|
// if opening a new window, this is a trick to
|
||||||
// pass it in
|
// pass it in
|
||||||
CurrentVM *pb.Event_VM
|
CurrentVM *pb.Event_VM
|
||||||
|
|
||||||
// All the tabs
|
|
||||||
// Tabs []GuiTabStructure
|
|
||||||
|
|
||||||
EntryNick *ui.Entry
|
EntryNick *ui.Entry
|
||||||
EntryUser *ui.Entry
|
EntryUser *ui.Entry
|
||||||
EntryPass *ui.Entry
|
EntryPass *ui.Entry
|
||||||
|
@ -81,8 +63,8 @@ type GuiDataStructure struct {
|
||||||
cloudBox *ui.Box
|
cloudBox *ui.Box
|
||||||
smallBox *ui.Box
|
smallBox *ui.Box
|
||||||
|
|
||||||
mainwin *ui.Window
|
// mainwin *ui.Window
|
||||||
maintab *ui.Tab
|
// maintab *ui.Tab
|
||||||
tabcount int
|
tabcount int
|
||||||
|
|
||||||
// stuff for the 'area'
|
// stuff for the 'area'
|
||||||
|
@ -99,6 +81,25 @@ type TableColumnData struct {
|
||||||
Color string
|
Color string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type EntryMap struct {
|
||||||
|
E *ui.Entry
|
||||||
|
Edit bool
|
||||||
|
|
||||||
|
Account *pb.Account
|
||||||
|
VM *pb.Event_VM
|
||||||
|
|
||||||
|
B *ui.Button
|
||||||
|
FB *ui.FontButton
|
||||||
|
A *ui.Area
|
||||||
|
W *ui.Window
|
||||||
|
T *ui.Tab
|
||||||
|
|
||||||
|
Action string // what type of button
|
||||||
|
|
||||||
|
// custom callback function to your main application
|
||||||
|
custom func (*EntryMap)
|
||||||
|
}
|
||||||
|
|
||||||
type ButtonMap struct {
|
type ButtonMap struct {
|
||||||
B *ui.Button
|
B *ui.Button
|
||||||
FB *ui.FontButton
|
FB *ui.FontButton
|
||||||
|
|
Loading…
Reference in New Issue