change around the concept of "Window" and "Box"
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
bd757b60bb
commit
2efce7f0cb
35
gui.go
35
gui.go
|
@ -301,11 +301,46 @@ func AddEntry(box *GuiBox, name string) *GuiEntry {
|
|||
return ge
|
||||
}
|
||||
|
||||
func HardHorizontalBreak(box *GuiBox) {
|
||||
log.Println("HardHorizontalBreak START")
|
||||
gw := box.W
|
||||
mainbox := gw.mainbox
|
||||
|
||||
tmp := ui.NewHorizontalSeparator()
|
||||
mainbox.Append(tmp, false)
|
||||
|
||||
hbox := ui.NewVerticalBox()
|
||||
hbox.SetPadded(true)
|
||||
box.UiBox = hbox
|
||||
mainbox.Append(hbox, true)
|
||||
log.Println("HardHorizontalBreak END")
|
||||
}
|
||||
|
||||
func HardVerticalBreak(box *GuiBox) {
|
||||
log.Println("HardVerticalBreak START")
|
||||
gw := box.W
|
||||
mainbox := gw.mainbox
|
||||
|
||||
tmp := ui.NewVerticalSeparator()
|
||||
mainbox.Append(tmp, false)
|
||||
|
||||
hbox := ui.NewVerticalBox()
|
||||
hbox.SetPadded(true)
|
||||
box.UiBox = hbox
|
||||
mainbox.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)
|
||||
|
|
|
@ -1,91 +0,0 @@
|
|||
package gui
|
||||
|
||||
import "log"
|
||||
|
||||
import "github.com/andlabs/ui"
|
||||
import _ "github.com/andlabs/ui/winmanifest"
|
||||
|
||||
// THIS IS NOT CLEAN
|
||||
|
||||
func makeCloudInfoBox(gw *GuiWindow) *GuiBox {
|
||||
var gb *GuiBox
|
||||
gb = new(GuiBox)
|
||||
gb.W = gw
|
||||
|
||||
gb.EntryMap = make(map[string]*GuiEntry)
|
||||
gb.EntryMap["test"] = nil
|
||||
|
||||
hbox := ui.NewHorizontalBox()
|
||||
hbox.SetPadded(true)
|
||||
gb.UiBox = hbox
|
||||
|
||||
if (Data.Debug) {
|
||||
log.Println("makeCloudInfoBox() add debugging buttons")
|
||||
addDebuggingButtons(gb)
|
||||
hbox.Append(ui.NewVerticalSeparator(), false)
|
||||
}
|
||||
|
||||
vbox := ui.NewVerticalBox()
|
||||
vbox.SetPadded(true)
|
||||
hbox.Append(vbox, true)
|
||||
|
||||
hostnamebox := ui.NewHorizontalBox()
|
||||
hostnamebox.SetPadded(true)
|
||||
vbox.Append(hostnamebox, false)
|
||||
|
||||
entryForm := ui.NewForm()
|
||||
entryForm.SetPadded(true)
|
||||
hostnamebox.Append(entryForm, true)
|
||||
|
||||
hostnameEntry := ui.NewEntry()
|
||||
entryForm.Append("hostname:", hostnameEntry, false)
|
||||
tmp := Data.Hostname + " (" + Data.IPv6 + ")"
|
||||
hostnameEntry.SetText(tmp)
|
||||
hostnameEntry.SetReadOnly(true)
|
||||
|
||||
anew := CreateButton(gb, nil, nil, "Edit", "EDIT", nil)
|
||||
hostnamebox.Append(anew.B, false)
|
||||
|
||||
vbox.Append(ui.NewHorizontalSeparator(), false)
|
||||
|
||||
agrid := ui.NewGrid()
|
||||
agrid.SetPadded(true)
|
||||
|
||||
agrid.Append(ui.NewLabel("Accounts:"), 0, 0, 1, 1, true, ui.AlignFill, false, ui.AlignFill)
|
||||
agrid.Append(ui.NewLabel("Domain Name"), 1, 0, 1, 1, true, ui.AlignFill, false, ui.AlignFill)
|
||||
agrid.Append(ui.NewLabel("Email"), 2, 0, 1, 1, true, ui.AlignFill, false, ui.AlignFill)
|
||||
|
||||
row := 1
|
||||
|
||||
for key, a := range Data.Config.Accounts {
|
||||
log.Println("account = ", key, a)
|
||||
log.Println("Accounts[key] = ", Data.Config.Accounts[key])
|
||||
log.Println("account.Nick = ", Data.Config.Accounts[key].Nick)
|
||||
log.Println("account.Username = ", Data.Config.Accounts[key].Username)
|
||||
log.Println("account.Token = ", Data.Config.Accounts[key].Token)
|
||||
|
||||
agrid.Append(ui.NewLabel(Data.Config.Accounts[key].Domain), 1, row, 1, 1, true, ui.AlignFill, false, ui.AlignFill)
|
||||
agrid.Append(ui.NewLabel(Data.Config.Accounts[key].Email), 2, row, 1, 1, true, ui.AlignFill, false, ui.AlignFill)
|
||||
|
||||
name := "Login " + Data.Config.Accounts[key].Nick
|
||||
l := CreateButton(gb, Data.Config.Accounts[key], nil, name, "LOGIN", nil)
|
||||
agrid.Append(l.B, 3, row, 1, 1, true, ui.AlignFill, false, ui.AlignFill)
|
||||
|
||||
name = "Show " + Data.Config.Accounts[key].Nick
|
||||
b := CreateButton(gb, Data.Config.Accounts[key], nil, name, "SHOW", nil)
|
||||
agrid.Append(b.B, 4, row, 1, 1, true, ui.AlignFill, false, ui.AlignFill)
|
||||
|
||||
row += 1
|
||||
}
|
||||
|
||||
row += 1
|
||||
agrid.Append(ui.NewLabel(""), 1, row, 1, 1, true, ui.AlignFill, false, ui.AlignFill)
|
||||
row += 1
|
||||
a := CreateButton(gb, nil, nil, "Add Account", "ADD TAB", nil)
|
||||
agrid.Append(a.B, 4, row, 1, 1, true, ui.AlignFill, false, ui.AlignFill)
|
||||
q := CreateButton(gb, nil, nil, "Quit", "QUIT", nil)
|
||||
agrid.Append(q.B, 5, row, 1, 1, true, ui.AlignFill, false, ui.AlignFill)
|
||||
|
||||
vbox.Append(agrid, false)
|
||||
return gb
|
||||
}
|
41
misc.go
41
misc.go
|
@ -22,7 +22,7 @@ func ShowTab(gw *GuiWindow, tabname string, title string) {
|
|||
}
|
||||
gw.UiTab.Delete(0)
|
||||
|
||||
abox := gw.MakeTab(gw)
|
||||
abox := gw.MakeWindow(gw)
|
||||
gw.BoxMap[tabname] = abox
|
||||
gw.UiTab.InsertAt(title, 0, abox.UiBox)
|
||||
gw.UiTab.SetMargined(0, true)
|
||||
|
@ -36,17 +36,38 @@ func GuiInit() {
|
|||
})
|
||||
}
|
||||
|
||||
func ShowMainTab(gw *GuiWindow) {
|
||||
func ShowMainTab(gw *GuiWindow) *GuiBox {
|
||||
log.Println("ShowMainTab() gw =", gw)
|
||||
log.Println("ShowMainTab() gw.UiTab =", gw.UiTab)
|
||||
gw.UiTab.Delete(0)
|
||||
|
||||
log.Println("Sleep(200)")
|
||||
time.Sleep(200 * time.Millisecond)
|
||||
var box *GuiBox
|
||||
box = new(GuiBox)
|
||||
box.W = gw
|
||||
|
||||
abox := makeCloudInfoBox(gw)
|
||||
gw.BoxMap["Box3"] = abox
|
||||
gw.UiTab.InsertAt("Main", 0, abox.UiBox)
|
||||
box.EntryMap = make(map[string]*GuiEntry)
|
||||
box.EntryMap["test"] = nil
|
||||
|
||||
hbox := ui.NewHorizontalBox()
|
||||
hbox.SetPadded(true)
|
||||
box.UiBox = hbox
|
||||
gw.mainbox = hbox
|
||||
|
||||
if (Data.Debug) {
|
||||
log.Println("makeCloudInfoBox() add debugging buttons")
|
||||
addDebuggingButtons(box)
|
||||
hbox.Append(ui.NewVerticalSeparator(), false)
|
||||
}
|
||||
|
||||
// box := gw.MakeWindow(gw)
|
||||
// abox := makeCloudInfoBox(gw, box)
|
||||
return box
|
||||
}
|
||||
|
||||
func ShowMainTabShowBox(gw *GuiWindow, box *GuiBox) {
|
||||
log.Println("gui.ShowMainTabShowBox() box =", box)
|
||||
// gw.UiTab.Delete(0)
|
||||
gw.BoxMap["Box3"] = box
|
||||
gw.UiTab.InsertAt("Main", 0, gw.mainbox)
|
||||
gw.UiTab.SetMargined(0, true)
|
||||
}
|
||||
|
||||
|
@ -56,7 +77,7 @@ func StartNewWindow(c *pb.Config, bg bool, action string, maketab func(*GuiWindo
|
|||
newGuiWindow.Width = int(c.Width)
|
||||
newGuiWindow.Height = int(c.Height)
|
||||
newGuiWindow.Action = action
|
||||
newGuiWindow.MakeTab = maketab
|
||||
newGuiWindow.MakeWindow = maketab
|
||||
Data.Windows = append(Data.Windows, &newGuiWindow)
|
||||
|
||||
// make(newGuiWindow.BoxMap)
|
||||
|
@ -108,7 +129,7 @@ func InitTabWindow(gw *GuiWindow) {
|
|||
|
||||
log.Println("InitTabWindow() gw =", gw)
|
||||
|
||||
abox := gw.MakeTab(gw)
|
||||
abox := gw.MakeWindow(gw)
|
||||
|
||||
gw.UiTab.Append("WIT Splash", abox.UiBox)
|
||||
gw.UiTab.SetMargined(0, true)
|
||||
|
|
14
structs.go
14
structs.go
|
@ -73,14 +73,23 @@ type GuiData struct {
|
|||
//
|
||||
type GuiWindow struct {
|
||||
Action string
|
||||
BoxMap map[string]*GuiBox
|
||||
Width int
|
||||
Height int
|
||||
|
||||
mainbox *ui.Box
|
||||
|
||||
// the callback function to make the window contents
|
||||
MakeWindow func(*GuiWindow) *GuiBox
|
||||
|
||||
// the components of the window
|
||||
BoxMap map[string]*GuiBox
|
||||
EntryMap map[string]*GuiEntry
|
||||
Area *GuiArea
|
||||
ButtonMap map[*GuiButton][]func (*GuiButton)
|
||||
|
||||
// andlabs/ui abstraction mapping
|
||||
UiWindow *ui.Window
|
||||
UiTab *ui.Tab // if this != nil, the window is 'tabbed'
|
||||
MakeTab func(*GuiWindow) *GuiBox
|
||||
}
|
||||
|
||||
|
||||
|
@ -122,6 +131,7 @@ type GuiEntry struct {
|
|||
|
||||
B *GuiButton
|
||||
Box *GuiBox
|
||||
|
||||
Account *pb.Account
|
||||
VM *pb.Event_VM
|
||||
|
||||
|
|
Loading…
Reference in New Issue