parent
f00e40d649
commit
b57b12549e
|
@ -0,0 +1,174 @@
|
||||||
|
package gui
|
||||||
|
|
||||||
|
import "log"
|
||||||
|
|
||||||
|
import "github.com/andlabs/ui"
|
||||||
|
import _ "github.com/andlabs/ui/winmanifest"
|
||||||
|
|
||||||
|
// import pb "git.wit.com/wit/witProtobuf"
|
||||||
|
// import "github.com/davecgh/go-spew/spew"
|
||||||
|
|
||||||
|
// THIS IS CLEAN
|
||||||
|
|
||||||
|
// 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["BUTTONBOX"], newbox, name) // use this to add something to the box called 'BUTTONBOX'
|
||||||
|
// add(box, newbox, name) // add 'newbox' to 'box' and call it 'name'
|
||||||
|
func add(box *GuiBox, newbox *GuiBox) {
|
||||||
|
log.Println("gui.add() START box =", box)
|
||||||
|
log.Println("gui.add() START newbox =", newbox)
|
||||||
|
if (box == nil) {
|
||||||
|
log.Println("\tgui.add() add to Window as MAINBOX")
|
||||||
|
newbox.Window.BoxMap["MAINBOX"] = newbox
|
||||||
|
if (newbox.Window.UiTab != nil) {
|
||||||
|
log.Println("\tgui.add() add to Window as a UiTab")
|
||||||
|
newbox.Window.UiTab.InsertAt(newbox.Name, 0, newbox.UiBox)
|
||||||
|
newbox.Window.UiTab.SetMargined(0, true)
|
||||||
|
// create a new tab here
|
||||||
|
// add the box to it as MAINBOX
|
||||||
|
} else {
|
||||||
|
log.Println("\tgui.add() DONT KNOW HOW TO ADD TO A RAW WINDOW YET")
|
||||||
|
// add this to the window
|
||||||
|
}
|
||||||
|
log.Println("\tgui.add() add to Window as MAINBOX DONE")
|
||||||
|
log.Println("gui.add() END")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
log.Println("gui.add() adding", newbox.Name, "to", box.Name)
|
||||||
|
// copy the box settings over
|
||||||
|
newbox.Window = box.Window
|
||||||
|
box.UiBox.Append(newbox.UiBox, false)
|
||||||
|
|
||||||
|
// add the newbox to the Window.BoxMap[]
|
||||||
|
box.Window.BoxMap[newbox.Name] = newbox
|
||||||
|
log.Println("gui.add() END")
|
||||||
|
}
|
||||||
|
|
||||||
|
func HardHorizontalBox(gw *GuiWindow) *GuiBox {
|
||||||
|
log.Println("HardHorizontalBreak START")
|
||||||
|
var newbox *GuiBox
|
||||||
|
newbox = new(GuiBox)
|
||||||
|
newbox.Window = gw
|
||||||
|
|
||||||
|
box := gw.BoxMap["MAINBOX"]
|
||||||
|
if (box != nil) {
|
||||||
|
// There is already a box. Add a Seperator
|
||||||
|
tmp := ui.NewHorizontalSeparator()
|
||||||
|
box.UiBox.Append(tmp, true)
|
||||||
|
add(gw.BoxMap["MAINBOX"], newbox)
|
||||||
|
}
|
||||||
|
|
||||||
|
hbox := ui.NewVerticalBox()
|
||||||
|
hbox.SetPadded(true)
|
||||||
|
newbox.UiBox = hbox
|
||||||
|
newbox.Name = "Hbox1"
|
||||||
|
add(gw.BoxMap["MAINBOX"], newbox)
|
||||||
|
log.Println("HardHorizontalBreak END")
|
||||||
|
return newbox
|
||||||
|
}
|
||||||
|
|
||||||
|
func HardVerticalBreak(box *GuiBox) {
|
||||||
|
log.Println("HardVerticalBreak START")
|
||||||
|
gw := box.Window
|
||||||
|
mainbox := gw.BoxMap["MAIN"]
|
||||||
|
if (mainbox == nil) {
|
||||||
|
log.Println("HardHorizontalBreak ERROR MAIN box == nil")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
tmp := ui.NewVerticalSeparator()
|
||||||
|
mainbox.UiBox.Append(tmp, false)
|
||||||
|
|
||||||
|
hbox := ui.NewVerticalBox()
|
||||||
|
hbox.SetPadded(true)
|
||||||
|
box.UiBox = hbox
|
||||||
|
mainbox.UiBox.Append(hbox, false)
|
||||||
|
log.Println("HardVerticalBreak END")
|
||||||
|
}
|
||||||
|
|
||||||
|
func HorizontalBreak(box *GuiBox) {
|
||||||
|
tmp := ui.NewHorizontalSeparator()
|
||||||
|
box.UiBox.Append(tmp, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
func VerticalBreak(box *GuiBox) {
|
||||||
|
tmp := ui.NewVerticalSeparator()
|
||||||
|
box.UiBox.Append(tmp, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
func AddGenericBox(gw *GuiWindow, name string) *GuiBox {
|
||||||
|
log.Println("AddGenericBox() START name =", name)
|
||||||
|
// create a new vertical box off of the mainbox
|
||||||
|
vbox := ui.NewVerticalBox()
|
||||||
|
vbox.SetPadded(true)
|
||||||
|
|
||||||
|
var newbox *GuiBox
|
||||||
|
newbox = new(GuiBox)
|
||||||
|
newbox.UiBox = vbox
|
||||||
|
newbox.Window = gw
|
||||||
|
newbox.Name = name
|
||||||
|
add(gw.BoxMap["MAINBOX"], newbox)
|
||||||
|
|
||||||
|
// create a new horizonal box off of the vertical box
|
||||||
|
hbox := ui.NewHorizontalBox()
|
||||||
|
hbox.SetPadded(true)
|
||||||
|
|
||||||
|
var newhbox *GuiBox
|
||||||
|
newhbox = new(GuiBox)
|
||||||
|
newhbox.UiBox = hbox
|
||||||
|
newhbox.Window = gw
|
||||||
|
newhbox.Name = "Hbox1"
|
||||||
|
add(newbox, newhbox)
|
||||||
|
|
||||||
|
return newbox
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateGenericBox(gw *GuiWindow, b *GuiButton, name string) *GuiBox{
|
||||||
|
log.Println("CreateAddVmBox() START name =", name)
|
||||||
|
|
||||||
|
var box *GuiBox
|
||||||
|
box = new(GuiBox)
|
||||||
|
|
||||||
|
vbox := ui.NewVerticalBox()
|
||||||
|
vbox.SetPadded(true)
|
||||||
|
box.UiBox = vbox
|
||||||
|
box.Window = gw
|
||||||
|
gw.BoxMap["ADD VM" + name] = box
|
||||||
|
|
||||||
|
hbox := ui.NewHorizontalBox()
|
||||||
|
hbox.SetPadded(true)
|
||||||
|
vbox.Append(hbox, false)
|
||||||
|
|
||||||
|
AddBoxToTab(name, gw.UiTab, vbox)
|
||||||
|
|
||||||
|
return box
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateBox(gw *GuiWindow, name string) *GuiBox {
|
||||||
|
log.Println("CreateVmBox() START")
|
||||||
|
log.Println("CreateVmBox() vm.Name =", name)
|
||||||
|
log.Println("CreateVmBox() gw =", gw)
|
||||||
|
|
||||||
|
var box *GuiBox
|
||||||
|
box = new(GuiBox)
|
||||||
|
|
||||||
|
vbox := ui.NewVerticalBox()
|
||||||
|
vbox.SetPadded(true)
|
||||||
|
log.Println("CreateVmBox() vbox =", vbox)
|
||||||
|
log.Println("CreateVmBox() box.UiBox =", box.UiBox)
|
||||||
|
box.UiBox = vbox
|
||||||
|
log.Println("CreateVmBox() box.Window =", box.Window)
|
||||||
|
box.Window = gw
|
||||||
|
log.Println("CreateVmBox() gw.BoxMap =", gw.BoxMap)
|
||||||
|
gw.BoxMap[name] = box
|
||||||
|
|
||||||
|
hboxAccount := ui.NewHorizontalBox()
|
||||||
|
hboxAccount.SetPadded(true)
|
||||||
|
vbox.Append(hboxAccount, false)
|
||||||
|
|
||||||
|
box.UiBox = hboxAccount
|
||||||
|
|
||||||
|
AddBoxToTab(name, gw.UiTab, vbox)
|
||||||
|
|
||||||
|
return box
|
||||||
|
}
|
2
debug.go
2
debug.go
|
@ -137,7 +137,7 @@ func WatchGUI() {
|
||||||
if (count > 20) {
|
if (count > 20) {
|
||||||
log.Println("Sleep() in watchGUI() Data.State =", Data.State)
|
log.Println("Sleep() in watchGUI() Data.State =", Data.State)
|
||||||
for i, window := range Data.Windows {
|
for i, window := range Data.Windows {
|
||||||
log.Println("watchGUI() Data.Windows i =", i, "Action =", window.Action)
|
log.Println("watchGUI() Data.Windows", i, "Action =", window.Action)
|
||||||
for name, abox := range window.BoxMap {
|
for name, abox := range window.BoxMap {
|
||||||
log.Println("\twatchGUI() BOX name =", name)
|
log.Println("\twatchGUI() BOX name =", name)
|
||||||
if (name == "SplashArea3") {
|
if (name == "SplashArea3") {
|
||||||
|
|
127
gui.go
127
gui.go
|
@ -208,6 +208,10 @@ func CreateFontButton(box *GuiBox, action string) *GuiButton {
|
||||||
return &newGB
|
return &newGB
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewLabel(box *GuiBox, text string) {
|
||||||
|
box.UiBox.Append(ui.NewLabel(text), false)
|
||||||
|
}
|
||||||
|
|
||||||
func GetText(box *GuiBox, name string) string {
|
func GetText(box *GuiBox, name string) string {
|
||||||
if (box == nil) {
|
if (box == nil) {
|
||||||
log.Println("gui.GetText() ERROR box == nil")
|
log.Println("gui.GetText() ERROR box == nil")
|
||||||
|
@ -278,10 +282,6 @@ func MakeEntryHbox(box *GuiBox, a string, startValue string, edit bool, action s
|
||||||
return e
|
return e
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewLabel(box *GuiBox, text string) {
|
|
||||||
box.UiBox.Append(ui.NewLabel(text), false)
|
|
||||||
}
|
|
||||||
|
|
||||||
func AddEntry(box *GuiBox, name string) *GuiEntry {
|
func AddEntry(box *GuiBox, name string) *GuiEntry {
|
||||||
var ge *GuiEntry
|
var ge *GuiEntry
|
||||||
ge = new(GuiEntry)
|
ge = new(GuiEntry)
|
||||||
|
@ -298,122 +298,3 @@ func AddEntry(box *GuiBox, name string) *GuiEntry {
|
||||||
|
|
||||||
return ge
|
return ge
|
||||||
}
|
}
|
||||||
|
|
||||||
func HardHorizontalBreak(box *GuiBox) {
|
|
||||||
log.Println("HardHorizontalBreak START")
|
|
||||||
gw := box.Window
|
|
||||||
mainbox := gw.BoxMap["MAIN"]
|
|
||||||
if (mainbox == nil) {
|
|
||||||
log.Println("HardHorizontalBreak ERROR MAIN box == nil")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
uibox := mainbox.UiBox
|
|
||||||
|
|
||||||
tmp := ui.NewHorizontalSeparator()
|
|
||||||
uibox.Append(tmp, false)
|
|
||||||
|
|
||||||
hbox := ui.NewVerticalBox()
|
|
||||||
hbox.SetPadded(true)
|
|
||||||
box.UiBox = hbox
|
|
||||||
uibox.Append(hbox, true)
|
|
||||||
log.Println("HardHorizontalBreak END")
|
|
||||||
}
|
|
||||||
|
|
||||||
func HardVerticalBreak(box *GuiBox) {
|
|
||||||
log.Println("HardVerticalBreak START")
|
|
||||||
gw := box.Window
|
|
||||||
mainbox := gw.BoxMap["MAIN"]
|
|
||||||
if (mainbox == nil) {
|
|
||||||
log.Println("HardHorizontalBreak ERROR MAIN box == nil")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
tmp := ui.NewVerticalSeparator()
|
|
||||||
mainbox.UiBox.Append(tmp, false)
|
|
||||||
|
|
||||||
hbox := ui.NewVerticalBox()
|
|
||||||
hbox.SetPadded(true)
|
|
||||||
box.UiBox = hbox
|
|
||||||
mainbox.UiBox.Append(hbox, false)
|
|
||||||
log.Println("HardVerticalBreak END")
|
|
||||||
}
|
|
||||||
|
|
||||||
func HorizontalBreak(box *GuiBox) {
|
|
||||||
tmp := ui.NewHorizontalSeparator()
|
|
||||||
box.UiBox.Append(tmp, false)
|
|
||||||
}
|
|
||||||
|
|
||||||
func VerticalBreak(box *GuiBox) {
|
|
||||||
tmp := ui.NewVerticalSeparator()
|
|
||||||
box.UiBox.Append(tmp, false)
|
|
||||||
}
|
|
||||||
|
|
||||||
func AddGenericBox(gw *GuiWindow) *GuiBox {
|
|
||||||
var gb *GuiBox
|
|
||||||
gb = new(GuiBox)
|
|
||||||
|
|
||||||
// gb.EntryMap = make(map[string]*GuiEntry)
|
|
||||||
// gb.EntryMap["test"] = nil
|
|
||||||
|
|
||||||
vbox := ui.NewVerticalBox()
|
|
||||||
vbox.SetPadded(true)
|
|
||||||
// gw.Box1 = vbox
|
|
||||||
gb.UiBox = vbox
|
|
||||||
gb.Window = gw
|
|
||||||
|
|
||||||
hbox := ui.NewHorizontalBox()
|
|
||||||
hbox.SetPadded(true)
|
|
||||||
vbox.Append(hbox, false)
|
|
||||||
|
|
||||||
return gb
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateGenericBox(gw *GuiWindow, b *GuiButton, name string) *GuiBox{
|
|
||||||
log.Println("CreateAddVmBox() START name =", name)
|
|
||||||
|
|
||||||
var box *GuiBox
|
|
||||||
box = new(GuiBox)
|
|
||||||
|
|
||||||
vbox := ui.NewVerticalBox()
|
|
||||||
vbox.SetPadded(true)
|
|
||||||
box.UiBox = vbox
|
|
||||||
box.Window = gw
|
|
||||||
gw.BoxMap["ADD VM" + name] = box
|
|
||||||
|
|
||||||
hbox := ui.NewHorizontalBox()
|
|
||||||
hbox.SetPadded(true)
|
|
||||||
vbox.Append(hbox, false)
|
|
||||||
|
|
||||||
AddBoxToTab(name, gw.UiTab, vbox)
|
|
||||||
|
|
||||||
return box
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateBox(gw *GuiWindow, name string) *GuiBox {
|
|
||||||
log.Println("CreateVmBox() START")
|
|
||||||
log.Println("CreateVmBox() vm.Name =", name)
|
|
||||||
log.Println("CreateVmBox() gw =", gw)
|
|
||||||
|
|
||||||
var box *GuiBox
|
|
||||||
box = new(GuiBox)
|
|
||||||
|
|
||||||
vbox := ui.NewVerticalBox()
|
|
||||||
vbox.SetPadded(true)
|
|
||||||
log.Println("CreateVmBox() vbox =", vbox)
|
|
||||||
log.Println("CreateVmBox() box.UiBox =", box.UiBox)
|
|
||||||
box.UiBox = vbox
|
|
||||||
log.Println("CreateVmBox() box.Window =", box.Window)
|
|
||||||
box.Window = gw
|
|
||||||
log.Println("CreateVmBox() gw.BoxMap =", gw.BoxMap)
|
|
||||||
gw.BoxMap[name] = box
|
|
||||||
|
|
||||||
hboxAccount := ui.NewHorizontalBox()
|
|
||||||
hboxAccount.SetPadded(true)
|
|
||||||
vbox.Append(hboxAccount, false)
|
|
||||||
|
|
||||||
box.UiBox = hboxAccount
|
|
||||||
|
|
||||||
AddBoxToTab(name, gw.UiTab, vbox)
|
|
||||||
|
|
||||||
return box
|
|
||||||
}
|
|
||||||
|
|
11
misc.go
11
misc.go
|
@ -24,9 +24,14 @@ func ShowTab(gw *GuiWindow, tabname string, title string) *GuiWindow {
|
||||||
window.UiTab.Delete(0)
|
window.UiTab.Delete(0)
|
||||||
|
|
||||||
abox := window.MakeWindow(window)
|
abox := window.MakeWindow(window)
|
||||||
window.BoxMap[tabname] = abox
|
// add(nil, abox)
|
||||||
window.UiTab.InsertAt(title, 0, abox.UiBox)
|
log.Println("ShowTab() NOT INSERTING TAB abox =", abox)
|
||||||
window.UiTab.SetMargined(0, true)
|
log.Println("ShowTab() NOT INSERTING TAB")
|
||||||
|
log.Println("ShowTab() NOT INSERTING TAB")
|
||||||
|
log.Println("ShowTab() NOT INSERTING TAB")
|
||||||
|
// window.BoxMap[tabname] = abox
|
||||||
|
// window.UiTab.InsertAt(title, 0, abox.UiBox)
|
||||||
|
// window.UiTab.SetMargined(0, true)
|
||||||
return window
|
return window
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
21
structs.go
21
structs.go
|
@ -95,6 +95,15 @@ type GuiWindow struct {
|
||||||
UiTab *ui.Tab // if this != nil, the window is 'tabbed'
|
UiTab *ui.Tab // if this != nil, the window is 'tabbed'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GuiBox is any type of ui.Hbox or ui.Vbox
|
||||||
|
// There can be lots of these for each GuiWindow
|
||||||
|
type GuiBox struct {
|
||||||
|
Window *GuiWindow
|
||||||
|
Name string
|
||||||
|
|
||||||
|
// andlabs/ui abstraction mapping
|
||||||
|
UiBox *ui.Box
|
||||||
|
}
|
||||||
|
|
||||||
// Note: every mouse click is handled
|
// Note: every mouse click is handled
|
||||||
// as a 'Button' regardless of where
|
// as a 'Button' regardless of where
|
||||||
|
@ -103,7 +112,6 @@ type GuiWindow struct {
|
||||||
type GuiButton struct {
|
type GuiButton struct {
|
||||||
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
|
||||||
// Area *GuiArea // indicates the button click was in an Area
|
|
||||||
GW *GuiWindow // what window the button click was in (redundant?)
|
GW *GuiWindow // what window the button click was in (redundant?)
|
||||||
|
|
||||||
Account *pb.Account // associated with what account?
|
Account *pb.Account // associated with what account?
|
||||||
|
@ -117,16 +125,7 @@ type GuiButton struct {
|
||||||
FB *ui.FontButton
|
FB *ui.FontButton
|
||||||
}
|
}
|
||||||
|
|
||||||
// GuiBox is any type of ui.Hbox or ui.Vbox
|
// text entry fields
|
||||||
// There can be lots of these for each GuiWindow
|
|
||||||
type GuiBox struct {
|
|
||||||
Window *GuiWindow
|
|
||||||
// EntryMap map[string]*GuiEntry
|
|
||||||
|
|
||||||
// andlabs/ui abstraction mapping
|
|
||||||
UiBox *ui.Box
|
|
||||||
}
|
|
||||||
|
|
||||||
type GuiEntry struct {
|
type GuiEntry struct {
|
||||||
Action string // what type of button
|
Action string // what type of button
|
||||||
Edit bool
|
Edit bool
|
||||||
|
|
Loading…
Reference in New Issue