summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--area.go29
-rw-r--r--gui.go8
-rw-r--r--mainCloudBox.go67
-rw-r--r--splash.go79
-rw-r--r--structs.go4
-rw-r--r--table.go2
-rw-r--r--tableCallbacks.go2
7 files changed, 53 insertions, 138 deletions
diff --git a/area.go b/area.go
index 1a0b9c9..3582900 100644
--- a/area.go
+++ b/area.go
@@ -101,7 +101,32 @@ func (ah GuiArea) KeyEvent(a *ui.Area, ke *ui.AreaKeyEvent) (handled bool) {
log.Println("GOT ENTER")
}
spew.Dump(ke)
- // splashWin.Destroy()
- // ui.Quit()
return false
}
+
+func ShowTextBox(gw *GuiWindow, newText *ui.AttributedString) *GuiBox {
+ log.Println("ShowTextBox() START")
+ if (gw == nil) {
+ log.Println("ShowTextBox() ERROR gw = nil")
+ return nil
+ }
+ log.Println("ShowTextBox() START gw =", gw)
+
+ // create and setup a new GuiBox
+ var gb *GuiBox
+ gb = new(GuiBox)
+
+ gb.EntryMap = make(map[string]*GuiEntry)
+ gb.EntryMap["test"] = nil
+
+ newbox := ui.NewVerticalBox()
+ newbox.SetPadded(true)
+ gb.UiBox = newbox
+ gb.W = gw
+ gw.BoxMap["Splash"] = gb
+
+ makeSplashArea(gb, newText)
+ newbox.Append(gb.Area.UiArea, true)
+
+ return gb
+}
diff --git a/gui.go b/gui.go
index 45b61f3..c78439b 100644
--- a/gui.go
+++ b/gui.go
@@ -209,6 +209,10 @@ func AddButton(b *GuiButton, name string) *ui.Button {
return newB
}
+func AddButtonToBox(box *GuiBox, button *GuiButton) {
+ box.UiBox.Append(button.B, false)
+}
+
func CreateButton(box *GuiBox, a *pb.Account, vm *pb.Event_VM, name string, action string, custom func(*GuiButton)) *GuiButton {
newUiB := ui.NewButton(name)
newUiB.OnClicked(defaultButtonClick)
@@ -317,3 +321,7 @@ func MakeEntryHbox(box *GuiBox, a string, startValue string, edit bool, action s
return e
}
+
+func NewLabel(box *GuiBox, text string) {
+ box.UiBox.Append(ui.NewLabel(text), false)
+}
diff --git a/mainCloudBox.go b/mainCloudBox.go
index 86a04cd..7971445 100644
--- a/mainCloudBox.go
+++ b/mainCloudBox.go
@@ -170,13 +170,13 @@ func GuiInit() {
})
}
-func StartNewWindow(c *pb.Config, bg bool, action string, text func() *ui.AttributedString) {
+func StartNewWindow(c *pb.Config, bg bool, action string, maketab func(*GuiWindow) *GuiBox) {
log.Println("InitNewWindow() Create a new window")
var newGuiWindow GuiWindow
newGuiWindow.Width = int(c.Width)
newGuiWindow.Height = int(c.Height)
newGuiWindow.Action = action
- newGuiWindow.GetText = text
+ newGuiWindow.MakeTab = maketab
Data.Windows = append(Data.Windows, &newGuiWindow)
// make(newGuiWindow.BoxMap)
@@ -185,13 +185,13 @@ func StartNewWindow(c *pb.Config, bg bool, action string, text func() *ui.Attrib
if (bg) {
log.Println("ShowWindow() IN NEW GOROUTINE")
go ui.Main(func() {
- InitWindow(&newGuiWindow)
+ InitTabWindow(&newGuiWindow)
})
time.Sleep(2000 * time.Millisecond)
} else {
log.Println("ShowWindow() WAITING for ui.Main()")
ui.Main(func() {
- InitWindow(&newGuiWindow)
+ InitTabWindow(&newGuiWindow)
})
}
}
@@ -202,8 +202,8 @@ func getSplashText(a string) *ui.AttributedString {
return aText
}
-func InitWindow(gw *GuiWindow) {
- log.Println("InitWindow() THIS WINDOW IS NOT YET SHOWN")
+func InitTabWindow(gw *GuiWindow) {
+ log.Println("InitTabWindow() THIS WINDOW IS NOT YET SHOWN")
gw.UiWindow = ui.NewWindow("", int(gw.Width), int(gw.Height), true)
gw.UiWindow.SetBorderless(false)
@@ -216,7 +216,7 @@ func InitWindow(gw *GuiWindow) {
Data.AllButtons = append(Data.AllButtons, &newBM)
gw.UiWindow.OnClosing(func(*ui.Window) bool {
- log.Println("InitWindow() OnClosing() THIS WINDOW IS CLOSING gw=", gw)
+ log.Println("InitTabWindow() OnClosing() THIS WINDOW IS CLOSING gw=", gw)
// mouseClick(&newBM)
ui.Quit()
return true
@@ -226,24 +226,12 @@ func InitWindow(gw *GuiWindow) {
gw.UiWindow.SetChild(gw.UiTab)
gw.UiWindow.SetMargined(true)
- log.Println("InitWindow() gw =", gw)
- log.Println("InitWindow() gw.Action =", gw.Action)
+ log.Println("InitTabWindow() gw =", gw)
- if (gw.Action == "SPLASH") {
- log.Println("InitWindow() TRYING SPLASH")
- damnit := "click" + string(Data.Config.Hostname)
- var tmp *ui.AttributedString
- if (gw.GetText == nil) {
- tmp = getSplashText(damnit)
- } else {
- tmp = gw.GetText()
- }
- log.Println("InitWindow() TRYING SPLASH tmp =", tmp)
- abox := ShowSplashBox(gw, tmp)
+ abox := gw.MakeTab(gw)
- gw.UiTab.Append("WIT Splash", abox.UiBox)
- gw.UiTab.SetMargined(0, true)
- }
+ gw.UiTab.Append("WIT Splash", abox.UiBox)
+ gw.UiTab.SetMargined(0, true)
Data.State = "splash"
gw.UiWindow.Show()
@@ -329,36 +317,3 @@ func defaultMakeEntry(startValue string, edit bool, action string) *GuiEntry {
return &newEntry
}
-
-/*
-// makeEntryBox(box, "hostname:", "blah.foo.org") {
-func makeEntryVbox(box *GuiBox, a string, startValue string, edit bool, action string) *GuiEntry {
- // Start 'Nickname' vertical box
- vboxN := ui.NewVerticalBox()
- vboxN.SetPadded(true)
- vboxN.Append(ui.NewLabel(a), false)
-
- e := defaultMakeEntry(startValue, edit, action)
-
- vboxN.Append(e.UiEntry, false)
- box.UiBox.Append(vboxN, false)
- // End 'Nickname' vertical box
-
- return e
-}
-
-func makeEntryHbox(box *GuiBox, a string, startValue string, edit bool, action string) *GuiEntry {
- // Start 'Nickname' vertical box
- hboxN := ui.NewHorizontalBox()
- hboxN.SetPadded(true)
- hboxN.Append(ui.NewLabel(a), false)
-
- e := defaultMakeEntry(startValue, edit, action)
- hboxN.Append(e.UiEntry, false)
-
- box.UiBox.Append(hboxN, false)
- // End 'Nickname' vertical box
-
- return e
-}
-*/
diff --git a/splash.go b/splash.go
deleted file mode 100644
index da03f3d..0000000
--- a/splash.go
+++ /dev/null
@@ -1,79 +0,0 @@
-package gui
-
-// import "github.com/davecgh/go-spew/spew"
-// import "time"
-// import "fmt"
-
-import "os"
-import "log"
-import "runtime"
-
-import "github.com/andlabs/ui"
-import _ "github.com/andlabs/ui/winmanifest"
-
-func ShowSplashBox(gw *GuiWindow, newText *ui.AttributedString) *GuiBox {
- log.Println("ShowSplashBox() START")
- log.Println("ShowSplashBox() START gw =", gw)
- if (gw == nil) {
- log.Println("ShowSplashBox() WE ARE FUCKED BECAUSE WE DON'T KNOW WHAT WINDOW TO DO THIS IN")
- os.Exit(0)
- return nil
- }
- var gb *GuiBox
- gb = new(GuiBox)
-
- gb.EntryMap = make(map[string]*GuiEntry)
- gb.EntryMap["test"] = nil
-
- newbox := ui.NewVerticalBox()
- newbox.SetPadded(true)
- // gw.Box1 = hbox
- gb.UiBox = newbox
- gb.W = gw
- gw.BoxMap["Splash"] = gb
-
- /*
- // initialize the GuiArea{}
- gb.Area = new(GuiArea)
- gb.Area.Window = gw
- gb.Area.UiAttrstr = newText
- */
-
- makeSplashArea(gb, newText)
-
- newbox.Append(gb.Area.UiArea, true)
-
- if runtime.GOOS == "linux" {
- newbox.Append(ui.NewLabel("OS: Linux"), false)
- } else if runtime.GOOS == "windows" {
- newbox.Append(ui.NewLabel("OS: Windows"), false)
- } else {
- newbox.Append(ui.NewLabel("OS: " + runtime.GOOS), false)
- }
-
- version := "Version: " + Data.Version
- newbox.Append(ui.NewLabel(version), false)
-
- if (Data.Debug) {
- if (Data.GitCommit != "") {
- tmp := "git rev-list: " + Data.GitCommit
- newbox.Append(ui.NewLabel(tmp), false)
- }
- if (Data.GoVersion != "") {
- tmp := "go build version: " + Data.GoVersion
- newbox.Append(ui.NewLabel(tmp), false)
- }
- if (Data.Buildtime != "") {
- tmp := "build date: " + Data.Buildtime
- newbox.Append(ui.NewLabel(tmp), false)
- }
- }
-
- log.Println("ShowSplashBox() START gb =", gb)
-
- okButton := CreateButton(gb, nil, nil, "OK", "AREA", nil)
- newbox.Append(okButton.B, false)
-
- // os.Exit(0)
- return gb
-}
diff --git a/structs.go b/structs.go
index 89057b9..430f136 100644
--- a/structs.go
+++ b/structs.go
@@ -8,6 +8,8 @@ import _ "github.com/andlabs/ui/winmanifest"
import pb "git.wit.com/wit/witProtobuf"
+// THIS IS CLEAN
+
//
// All GUI Data Structures and functions that are external
// If you need cross platform support, these might only
@@ -78,7 +80,7 @@ type GuiWindow struct {
// andlabs/ui abstraction mapping
UiWindow *ui.Window
UiTab *ui.Tab // if this != nil, the window is 'tabbed'
- GetText func() *ui.AttributedString
+ MakeTab func(*GuiWindow) *GuiBox
}
diff --git a/table.go b/table.go
index 4e65b35..c6dbcdf 100644
--- a/table.go
+++ b/table.go
@@ -9,6 +9,8 @@ import _ "github.com/andlabs/ui/winmanifest"
// import "github.com/davecgh/go-spew/spew"
+// THIS IS CLEAN
+
func initRowBTcolor(mh *TableData, intBG int, cell TableColumnData) {
humanInt := cell.Index
diff --git a/tableCallbacks.go b/tableCallbacks.go
index e63c5b3..df9c408 100644
--- a/tableCallbacks.go
+++ b/tableCallbacks.go
@@ -14,6 +14,8 @@ import "runtime"
import "github.com/andlabs/ui"
import _ "github.com/andlabs/ui/winmanifest"
+// THIS IS CLEAN
+
func (mh *TableData) NumRows(m *ui.TableModel) int {
if (Data.Debug) {
log.Println("NumRows = mh.RowCount = ", mh.RowCount, "(last Row & Column =", mh.lastRow, mh.lastColumn, ")")