REFACTOR: remove GuiWindow & GuiBox
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
d6980daa81
commit
db6c60decc
14
area.go
14
area.go
|
@ -12,22 +12,24 @@ func makeGenericArea(n *Node, newText *ui.AttributedString, custom func(*GuiButt
|
||||||
// There should be another way to do this (?)
|
// There should be another way to do this (?)
|
||||||
var newB *GuiButton
|
var newB *GuiButton
|
||||||
newB = CreateFontButton(n, "AREA")
|
newB = CreateFontButton(n, "AREA")
|
||||||
// newB.Box = gb
|
|
||||||
newB.Custom = custom
|
newB.Custom = custom
|
||||||
|
|
||||||
|
/*
|
||||||
gw := n.window
|
gw := n.window
|
||||||
// initialize the GuiArea{}
|
// initialize the GuiArea{}
|
||||||
gw.Area = new(GuiArea)
|
|
||||||
gw.Area.Button = newB
|
gw.Area.Button = newB
|
||||||
|
*/
|
||||||
|
area := new(GuiArea)
|
||||||
|
|
||||||
// gw.Area.Box = gb
|
// gw.Area.Box = gb
|
||||||
gw.Area.UiAttrstr = newText
|
n.uiAttrstr = newText
|
||||||
gw.Area.UiArea = ui.NewArea(gw.Area)
|
n.uiArea = ui.NewArea(area)
|
||||||
|
|
||||||
if (Config.Debug) {
|
if (Config.Debug) {
|
||||||
spew.Dump(gw.Area.UiArea)
|
spew.Dump(n.uiArea)
|
||||||
log.Println("DEBUGGING", Config.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 =", n.uiButton)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ import (
|
||||||
|
|
||||||
"github.com/andlabs/ui"
|
"github.com/andlabs/ui"
|
||||||
_ "github.com/andlabs/ui/winmanifest"
|
_ "github.com/andlabs/ui/winmanifest"
|
||||||
"github.com/davecgh/go-spew/spew"
|
// "github.com/davecgh/go-spew/spew"
|
||||||
)
|
)
|
||||||
|
|
||||||
var names = make([]string, 100)
|
var names = make([]string, 100)
|
||||||
|
@ -33,6 +33,7 @@ func makeWindowDebug() *ui.Box {
|
||||||
hbox := ui.NewHorizontalBox()
|
hbox := ui.NewHorizontalBox()
|
||||||
hbox.SetPadded(true)
|
hbox.SetPadded(true)
|
||||||
|
|
||||||
|
/*
|
||||||
/////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////
|
||||||
vbox := addGroup(hbox, "range Data.WindowMap")
|
vbox := addGroup(hbox, "range Data.WindowMap")
|
||||||
cbox := ui.NewCombobox()
|
cbox := ui.NewCombobox()
|
||||||
|
@ -44,7 +45,6 @@ func makeWindowDebug() *ui.Box {
|
||||||
addName(cbox, name)
|
addName(cbox, name)
|
||||||
}
|
}
|
||||||
cbox.SetSelected(0)
|
cbox.SetSelected(0)
|
||||||
|
|
||||||
vbox.Append(cbox, false)
|
vbox.Append(cbox, false)
|
||||||
|
|
||||||
cbox.OnSelected(func(*ui.Combobox) {
|
cbox.OnSelected(func(*ui.Combobox) {
|
||||||
|
@ -65,76 +65,6 @@ func makeWindowDebug() *ui.Box {
|
||||||
dumpBox(names[x])
|
dumpBox(names[x])
|
||||||
})
|
})
|
||||||
|
|
||||||
b2 := addButton(vbox, "SetMargined(tab)")
|
|
||||||
b2.OnClicked(func(*ui.Button) {
|
|
||||||
x := cbox.Selected()
|
|
||||||
log.Println("x =", x)
|
|
||||||
log.Println("FindWindow; names[x] =", names[x])
|
|
||||||
gw := FindWindow(names[x])
|
|
||||||
if gw == nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if gw.UiTab == nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if gw.TabNumber == nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
scs := spew.ConfigState{MaxDepth: 1}
|
|
||||||
scs.Dump(gw)
|
|
||||||
log.Println("gui.DumpBoxes()\tWindow.UiTab =", gw.UiTab)
|
|
||||||
log.Println("gui.DumpBoxes()\tWindow.TabNumber =", *gw.TabNumber)
|
|
||||||
gw.UiTab.SetMargined(*gw.TabNumber, true)
|
|
||||||
})
|
|
||||||
|
|
||||||
b3 := addButton(vbox, "Hide(tab)")
|
|
||||||
b3.OnClicked(func(*ui.Button) {
|
|
||||||
x := cbox.Selected()
|
|
||||||
log.Println("x =", x)
|
|
||||||
log.Println("FindWindow; names[x] =", names[x])
|
|
||||||
gw := FindWindow(names[x])
|
|
||||||
if gw == nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if gw.UiTab == nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
gw.UiTab.Hide()
|
|
||||||
})
|
|
||||||
|
|
||||||
b4 := addButton(vbox, "Show(tab)")
|
|
||||||
b4.OnClicked(func(*ui.Button) {
|
|
||||||
x := cbox.Selected()
|
|
||||||
log.Println("x =", x)
|
|
||||||
log.Println("FindWindow; names[x] =", names[x])
|
|
||||||
gw := FindWindow(names[x])
|
|
||||||
if gw == nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if gw.UiTab == nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
gw.UiTab.Show()
|
|
||||||
})
|
|
||||||
|
|
||||||
b5 := addButton(vbox, "Delete(tab)")
|
|
||||||
b5.OnClicked(func(*ui.Button) {
|
|
||||||
x := cbox.Selected()
|
|
||||||
log.Println("x =", x)
|
|
||||||
log.Println("FindWindow; names[x] =", names[x])
|
|
||||||
gw := FindWindow(names[x])
|
|
||||||
if gw == nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if gw.UiTab == nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if gw.TabNumber == nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
gw.UiTab.Delete(*gw.TabNumber)
|
|
||||||
})
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////
|
||||||
vbox = addGroup(hbox, "Global Debug")
|
vbox = addGroup(hbox, "Global Debug")
|
||||||
|
|
||||||
|
@ -152,6 +82,7 @@ func makeWindowDebug() *ui.Box {
|
||||||
dump1.OnClicked(func(*ui.Button) {
|
dump1.OnClicked(func(*ui.Button) {
|
||||||
DumpMap()
|
DumpMap()
|
||||||
})
|
})
|
||||||
|
*/
|
||||||
|
|
||||||
/////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////
|
||||||
nodeBox := addGroup(hbox, "Windows:")
|
nodeBox := addGroup(hbox, "Windows:")
|
||||||
|
@ -179,7 +110,7 @@ func makeWindowDebug() *ui.Box {
|
||||||
})
|
})
|
||||||
|
|
||||||
/////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////
|
||||||
vbox = addGroup(hbox, "Node Debug")
|
vbox := addGroup(hbox, "Node Debug")
|
||||||
|
|
||||||
n1 := addButton(vbox, "Data.DumpNodeMap()")
|
n1 := addButton(vbox, "Data.DumpNodeMap()")
|
||||||
n1.OnClicked(func(*ui.Button) {
|
n1.OnClicked(func(*ui.Button) {
|
||||||
|
@ -277,6 +208,7 @@ func addGroup(b *ui.Box, name string) *ui.Box {
|
||||||
return vbox
|
return vbox
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
func dumpBox(s string) {
|
func dumpBox(s string) {
|
||||||
var name string
|
var name string
|
||||||
var window *GuiWindow
|
var window *GuiWindow
|
||||||
|
@ -295,20 +227,6 @@ func dumpBox(s string) {
|
||||||
// log.Println("gui.DumpBoxes()\tWindow.UiWindow type =", reflect.TypeOf(window.UiWindow))
|
// log.Println("gui.DumpBoxes()\tWindow.UiWindow type =", reflect.TypeOf(window.UiWindow))
|
||||||
log.Println("gui.DumpBoxes()\tWindow.UiWindow =", window.UiWindow)
|
log.Println("gui.DumpBoxes()\tWindow.UiWindow =", window.UiWindow)
|
||||||
log.Println("gui.DumpBoxes()\tWindow.UiTab =", window.UiTab)
|
log.Println("gui.DumpBoxes()\tWindow.UiTab =", window.UiTab)
|
||||||
/*
|
|
||||||
log.Println("gui.dumpBox() BoxMap START")
|
|
||||||
for name, abox := range window.BoxMap {
|
|
||||||
log.Printf("gui.DumpBoxes() \tBOX mapname=%-12s abox.Name=%-12s", name, abox.Name)
|
|
||||||
abox.Dump()
|
|
||||||
if name == "MAINBOX" {
|
|
||||||
if Config.Debug {
|
|
||||||
scs := spew.ConfigState{MaxDepth: 1}
|
|
||||||
scs.Dump(abox.UiBox)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
log.Println("gui.dumpBox() BoxMap END")
|
|
||||||
*/
|
|
||||||
if window.UiTab != nil {
|
if window.UiTab != nil {
|
||||||
pages := window.UiTab.NumPages()
|
pages := window.UiTab.NumPages()
|
||||||
log.Println("gui.DumpBoxes()\tWindow.UiTab.NumPages() =", pages)
|
log.Println("gui.DumpBoxes()\tWindow.UiTab.NumPages() =", pages)
|
||||||
|
@ -320,6 +238,7 @@ func dumpBox(s string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
func addButton(box *ui.Box, name string) *ui.Button {
|
func addButton(box *ui.Box, name string) *ui.Button {
|
||||||
button := ui.NewButton(name)
|
button := ui.NewButton(name)
|
||||||
|
|
12
debug.go
12
debug.go
|
@ -5,7 +5,7 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/davecgh/go-spew/spew"
|
// "github.com/davecgh/go-spew/spew"
|
||||||
)
|
)
|
||||||
|
|
||||||
// WatchGUI() opens a goroutine
|
// WatchGUI() opens a goroutine
|
||||||
|
@ -22,7 +22,7 @@ func WatchGUI() {
|
||||||
if count > 20 {
|
if count > 20 {
|
||||||
log.Println("Sleep() in watchGUI()")
|
log.Println("Sleep() in watchGUI()")
|
||||||
if Config.Debug {
|
if Config.Debug {
|
||||||
DumpBoxes()
|
// DumpBoxes()
|
||||||
}
|
}
|
||||||
count = 0
|
count = 0
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,7 @@ func WatchGUI() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
func DumpWindows() {
|
func DumpWindows() {
|
||||||
for name, _ := range Data.WindowMap {
|
for name, _ := range Data.WindowMap {
|
||||||
log.Println("gui.DumpWindows() window =", name)
|
log.Println("gui.DumpWindows() window =", name)
|
||||||
|
@ -41,11 +42,9 @@ func DumpMap() {
|
||||||
for name, window := range Data.WindowMap {
|
for name, window := range Data.WindowMap {
|
||||||
log.Println("gui.DumpBoxes() MAP: ", name)
|
log.Println("gui.DumpBoxes() MAP: ", name)
|
||||||
log.Println("gui.DumpBoxes() window:", window)
|
log.Println("gui.DumpBoxes() window:", window)
|
||||||
/*
|
|
||||||
for name, abox := range window.BoxMap {
|
for name, abox := range window.BoxMap {
|
||||||
log.Printf("gui.DumpBoxes() \tBOX mapname=%-12s abox.Name=%-12s", name, abox.Name)
|
log.Printf("gui.DumpBoxes() \tBOX mapname=%-12s abox.Name=%-12s", name, abox.Name)
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +60,6 @@ func DumpBoxes() {
|
||||||
// log.Println("gui.DumpBoxes()\tWindow.UiWindow type =", reflect.TypeOf(window.UiWindow))
|
// log.Println("gui.DumpBoxes()\tWindow.UiWindow type =", reflect.TypeOf(window.UiWindow))
|
||||||
log.Println("gui.DumpBoxes()\tWindow.UiWindow =", window.UiWindow)
|
log.Println("gui.DumpBoxes()\tWindow.UiWindow =", window.UiWindow)
|
||||||
log.Println("gui.DumpBoxes()\tWindow.UiTab =", window.UiTab)
|
log.Println("gui.DumpBoxes()\tWindow.UiTab =", window.UiTab)
|
||||||
/*
|
|
||||||
for name, abox := range window.BoxMap {
|
for name, abox := range window.BoxMap {
|
||||||
log.Printf("gui.DumpBoxes() \tBOX mapname=%-12s abox.Name=%-12s", name, abox.Name)
|
log.Printf("gui.DumpBoxes() \tBOX mapname=%-12s abox.Name=%-12s", name, abox.Name)
|
||||||
if name == "MAINBOX" {
|
if name == "MAINBOX" {
|
||||||
|
@ -71,7 +69,6 @@ func DumpBoxes() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
if window.UiTab != nil {
|
if window.UiTab != nil {
|
||||||
// log.Println("gui.DumpBoxes()\tWindow.UiTab type =", reflect.TypeOf(window.UiTab))
|
// log.Println("gui.DumpBoxes()\tWindow.UiTab type =", reflect.TypeOf(window.UiTab))
|
||||||
// log.Println("gui.DumpBoxes()\tWindow.UiTab =", window.UiTab)
|
// log.Println("gui.DumpBoxes()\tWindow.UiTab =", window.UiTab)
|
||||||
|
@ -89,7 +86,6 @@ func DumpBoxes() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
for i, window := range Data.Windows {
|
for i, window := range Data.Windows {
|
||||||
if (window.TabNumber == nil) {
|
if (window.TabNumber == nil) {
|
||||||
log.Println("gui.DumpBoxes() Data.Windows", i, "Name =", window.Name, "TabNumber = nil")
|
log.Println("gui.DumpBoxes() Data.Windows", i, "Name =", window.Name, "TabNumber = nil")
|
||||||
|
@ -97,8 +93,8 @@ func DumpBoxes() {
|
||||||
log.Println("gui.DumpBoxes() Data.Windows", i, "Name =", window.Name, "TabNumber =", *window.TabNumber)
|
log.Println("gui.DumpBoxes() Data.Windows", i, "Name =", window.Name, "TabNumber =", *window.TabNumber)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
func addTableTab() {
|
func addTableTab() {
|
||||||
var parts []TableColumnData
|
var parts []TableColumnData
|
||||||
|
|
12
find.go
12
find.go
|
@ -17,19 +17,11 @@ func (n *Node) FindControl() *ui.Control {
|
||||||
return n.uiControl
|
return n.uiControl
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
func (w *GuiWindow) FindNode() *Node {
|
func (w *GuiWindow) FindNode() *Node {
|
||||||
return w.node
|
return w.node
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
func FindWindow(s string) *GuiWindow {
|
|
||||||
for name, window := range Data.WindowMap {
|
|
||||||
if name == s {
|
|
||||||
return window
|
|
||||||
}
|
|
||||||
}
|
|
||||||
log.Printf("COULD NOT FIND WINDOW " + s)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func FindNode(name string) *Node {
|
func FindNode(name string) *Node {
|
||||||
if Data.NodeMap == nil {
|
if Data.NodeMap == nil {
|
||||||
|
|
2
gui.go
2
gui.go
|
@ -17,7 +17,7 @@ func init() {
|
||||||
log.Println("gui.init() has been run")
|
log.Println("gui.init() has been run")
|
||||||
|
|
||||||
Data.buttonMap = make(map[*ui.Button]*GuiButton)
|
Data.buttonMap = make(map[*ui.Button]*GuiButton)
|
||||||
Data.WindowMap = make(map[string]*GuiWindow)
|
// Data.WindowMap = make(map[string]*GuiWindow)
|
||||||
Data.NodeMap = make(map[string]*Node)
|
Data.NodeMap = make(map[string]*Node)
|
||||||
|
|
||||||
Data.NodeSlice = make([]*Node, 0)
|
Data.NodeSlice = make([]*Node, 0)
|
||||||
|
|
|
@ -49,16 +49,18 @@ type Node struct {
|
||||||
parent *Node
|
parent *Node
|
||||||
children []*Node
|
children []*Node
|
||||||
|
|
||||||
window *GuiWindow
|
// window *GuiWindow
|
||||||
area *GuiArea
|
area *GuiArea
|
||||||
custom func(*Node)
|
custom func(*Node)
|
||||||
|
|
||||||
uiControl *ui.Control
|
uiControl *ui.Control
|
||||||
uiButton *ui.Button
|
uiButton *ui.Button
|
||||||
uiWindow *ui.Window
|
uiWindow *ui.Window
|
||||||
uiTab *ui.Tab
|
uiAttrstr *ui.AttributedString
|
||||||
uiBox *ui.Box
|
uiTab *ui.Tab
|
||||||
uiText *ui.EditableCombobox
|
uiBox *ui.Box
|
||||||
|
uiArea *ui.Area
|
||||||
|
uiText *ui.EditableCombobox
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *Node) Parent() *Node {
|
func (n *Node) Parent() *Node {
|
||||||
|
@ -83,7 +85,7 @@ func (n *Node) Dump() {
|
||||||
}
|
}
|
||||||
log.Println("gui.Node.Dump() children = ", n.children)
|
log.Println("gui.Node.Dump() children = ", n.children)
|
||||||
|
|
||||||
log.Println("gui.Node.Dump() window = ", n.window)
|
// log.Println("gui.Node.Dump() window = ", n.window)
|
||||||
// log.Println("gui.Node.Dump() box = ", n.box)
|
// log.Println("gui.Node.Dump() box = ", n.box)
|
||||||
|
|
||||||
log.Println("gui.Node.Dump() uiWindow = ", n.uiWindow)
|
log.Println("gui.Node.Dump() uiWindow = ", n.uiWindow)
|
||||||
|
|
75
structs.go
75
structs.go
|
@ -2,7 +2,7 @@ package gui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"image/color"
|
"image/color"
|
||||||
"log"
|
// "log"
|
||||||
|
|
||||||
"github.com/andlabs/ui"
|
"github.com/andlabs/ui"
|
||||||
"golang.org/x/image/font"
|
"golang.org/x/image/font"
|
||||||
|
@ -42,7 +42,7 @@ type GuiData struct {
|
||||||
|
|
||||||
// A map of all the entry boxes
|
// A map of all the entry boxes
|
||||||
AllEntries []*GuiEntry
|
AllEntries []*GuiEntry
|
||||||
WindowMap map[string]*GuiWindow
|
// WindowMap map[string]*GuiWindow
|
||||||
|
|
||||||
// Store access to everything via binary tree's
|
// Store access to everything via binary tree's
|
||||||
NodeMap map[string]*Node
|
NodeMap map[string]*Node
|
||||||
|
@ -62,7 +62,7 @@ type GuiData struct {
|
||||||
type GuiTab struct {
|
type GuiTab struct {
|
||||||
Name string // field for human readable name
|
Name string // field for human readable name
|
||||||
Number int // the andlabs/ui tab index
|
Number int // the andlabs/ui tab index
|
||||||
Window *GuiWindow // the parent Window
|
// Window *GuiWindow // the parent Window
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -83,6 +83,7 @@ type GuiTab struct {
|
||||||
// This struct keeps track of what is in the window so you
|
// This struct keeps track of what is in the window so you
|
||||||
// can destroy and replace it with something else
|
// can destroy and replace it with something else
|
||||||
//
|
//
|
||||||
|
/*
|
||||||
type GuiWindow struct {
|
type GuiWindow struct {
|
||||||
Name string // field for human readable name
|
Name string // field for human readable name
|
||||||
Width int
|
Width int
|
||||||
|
@ -90,11 +91,7 @@ type GuiWindow struct {
|
||||||
Axis int // does it add items to the X or Y axis
|
Axis int // does it add items to the X or Y axis
|
||||||
TabNumber *int // the andlabs/ui tab index
|
TabNumber *int // the andlabs/ui tab index
|
||||||
|
|
||||||
// the callback function to make the window contents
|
|
||||||
// MakeWindow func(*GuiBox) *GuiBox
|
|
||||||
|
|
||||||
// the components of the window
|
// the components of the window
|
||||||
// BoxMap map[string]*GuiBox
|
|
||||||
EntryMap map[string]*GuiEntry
|
EntryMap map[string]*GuiEntry
|
||||||
Area *GuiArea
|
Area *GuiArea
|
||||||
|
|
||||||
|
@ -104,7 +101,9 @@ type GuiWindow struct {
|
||||||
UiWindow *ui.Window
|
UiWindow *ui.Window
|
||||||
UiTab *ui.Tab // if this != nil, the window is 'tabbed'
|
UiTab *ui.Tab // if this != nil, the window is 'tabbed'
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
func (w *GuiWindow) Dump() {
|
func (w *GuiWindow) Dump() {
|
||||||
log.Println("gui.GuiWindow.Dump() Name = ", w.Name)
|
log.Println("gui.GuiWindow.Dump() Name = ", w.Name)
|
||||||
log.Println("gui.GuiWindow.Dump() node = ", w.node)
|
log.Println("gui.GuiWindow.Dump() node = ", w.node)
|
||||||
|
@ -112,43 +111,6 @@ func (w *GuiWindow) Dump() {
|
||||||
log.Println("gui.GuiWindow.Dump() Height = ", w.Height)
|
log.Println("gui.GuiWindow.Dump() Height = ", w.Height)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
// GuiBox is any type of ui.Hbox or ui.Vbox
|
|
||||||
// There can be lots of these for each GuiWindow
|
|
||||||
type GuiBox struct {
|
|
||||||
Name string // field for human readable name
|
|
||||||
Axis int // does it add items to the X or Y axis
|
|
||||||
Window *GuiWindow // the parent Window
|
|
||||||
|
|
||||||
node *Node
|
|
||||||
|
|
||||||
// andlabs/ui abstraction mapping
|
|
||||||
UiBox *ui.Box
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
func (b *GuiBox) Dump() {
|
|
||||||
log.Println("gui.GuiBox.Dump() Name = ", b.Name)
|
|
||||||
log.Println("gui.GuiBox.Dump() Axis = ", b.Axis)
|
|
||||||
log.Println("gui.GuiBox.Dump() GuiWindow = ", b.Window)
|
|
||||||
log.Println("gui.GuiBox.Dump() node = ", b.node)
|
|
||||||
log.Println("gui.GuiBox.Dump() UiBox = ", b.UiBox)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *GuiBox) SetTitle(title string) {
|
|
||||||
log.Println("DID IT!", title)
|
|
||||||
if b.Window == nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if b.Window.UiWindow == nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
b.Window.UiWindow.SetTitle(title)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
func (w *GuiWindow) SetNode(n *Node) {
|
func (w *GuiWindow) SetNode(n *Node) {
|
||||||
if (w.node != nil) {
|
if (w.node != nil) {
|
||||||
w.Dump()
|
w.Dump()
|
||||||
|
@ -160,27 +122,6 @@ func (w *GuiWindow) SetNode(n *Node) {
|
||||||
panic("gui.SetNode() node == nil")
|
panic("gui.SetNode() node == nil")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
func (b *GuiBox) SetNode(n *Node) {
|
|
||||||
if (b.node != nil) {
|
|
||||||
b.Dump()
|
|
||||||
panic("gui.SetNode() Error not nil")
|
|
||||||
}
|
|
||||||
b.node = n
|
|
||||||
if (b.node == nil) {
|
|
||||||
b.Dump()
|
|
||||||
panic("gui.SetNode() node == nil")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *GuiBox) Append(child ui.Control, x bool) {
|
|
||||||
if b.UiBox == nil {
|
|
||||||
panic("GuiBox.Append() can't work. UiBox == nil")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
b.UiBox.Append(child, x)
|
|
||||||
}
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Note: every mouse click is handled
|
// Note: every mouse click is handled
|
||||||
|
@ -189,7 +130,6 @@ func (b *GuiBox) Append(child ui.Control, x bool) {
|
||||||
// call this 'GuiMouseClick'
|
// call this 'GuiMouseClick'
|
||||||
type GuiButton struct {
|
type GuiButton struct {
|
||||||
Name string // field for human readable name
|
Name string // field for human readable name
|
||||||
// box2 *GuiBox // what box the button click was in
|
|
||||||
|
|
||||||
// a callback function for the main application
|
// a callback function for the main application
|
||||||
Custom func(*GuiButton)
|
Custom func(*GuiButton)
|
||||||
|
@ -210,7 +150,6 @@ type GuiEntry struct {
|
||||||
Normalize func(string) string // function to 'normalize' the data
|
Normalize func(string) string // function to 'normalize' the data
|
||||||
|
|
||||||
B *GuiButton
|
B *GuiButton
|
||||||
// Box *GuiBox
|
|
||||||
|
|
||||||
// andlabs/ui abstraction mapping
|
// andlabs/ui abstraction mapping
|
||||||
UiEntry *ui.Entry
|
UiEntry *ui.Entry
|
||||||
|
@ -223,7 +162,6 @@ type GuiEntry struct {
|
||||||
//
|
//
|
||||||
type GuiArea struct {
|
type GuiArea struct {
|
||||||
Button *GuiButton // what button handles mouse events
|
Button *GuiButton // what button handles mouse events
|
||||||
// Box *GuiBox
|
|
||||||
|
|
||||||
UiAttrstr *ui.AttributedString
|
UiAttrstr *ui.AttributedString
|
||||||
UiArea *ui.Area
|
UiArea *ui.Area
|
||||||
|
@ -261,7 +199,6 @@ type TableData struct {
|
||||||
Cells [20]CellData
|
Cells [20]CellData
|
||||||
Human [20]HumanMap
|
Human [20]HumanMap
|
||||||
|
|
||||||
// Box *GuiBox
|
|
||||||
n *Node
|
n *Node
|
||||||
|
|
||||||
lastRow int
|
lastRow int
|
||||||
|
|
2
table.go
2
table.go
|
@ -97,7 +97,7 @@ func InitColumns(mh *TableData, parts []TableColumnData) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func AddTableTab(gw *GuiWindow, name string, rowcount int, parts []TableColumnData) *TableData {
|
func AddTableTab(name string, rowcount int, parts []TableColumnData) *TableData {
|
||||||
n := NewWindow()
|
n := NewWindow()
|
||||||
return n.AddTableBox(name, rowcount, parts)
|
return n.AddTableBox(name, rowcount, parts)
|
||||||
}
|
}
|
||||||
|
|
34
window.go
34
window.go
|
@ -9,14 +9,19 @@ import (
|
||||||
_ "github.com/andlabs/ui/winmanifest"
|
_ "github.com/andlabs/ui/winmanifest"
|
||||||
)
|
)
|
||||||
|
|
||||||
func MessageWindow(gw *GuiWindow, msg1 string, msg2 string) {
|
func (n *Node) MessageWindow2(msg1 string, msg2 string) (*Node) {
|
||||||
ui.MsgBox(gw.UiWindow, msg1, msg2)
|
ui.MsgBox(n.uiWindow, msg1, msg2)
|
||||||
|
// TODO: make new node
|
||||||
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
func ErrorWindow(gw *GuiWindow, msg1 string, msg2 string) {
|
func (n *Node) ErrorWindow2(msg1 string, msg2 string) (*Node) {
|
||||||
ui.MsgBoxError(gw.UiWindow, msg1, msg2)
|
ui.MsgBoxError(n.uiWindow, msg1, msg2)
|
||||||
|
// TODO: make new node
|
||||||
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
func DeleteWindow(name string) {
|
func DeleteWindow(name string) {
|
||||||
log.Println("gui.DeleteWindow() START name =", name)
|
log.Println("gui.DeleteWindow() START name =", name)
|
||||||
window := Data.WindowMap[name]
|
window := Data.WindowMap[name]
|
||||||
|
@ -51,6 +56,7 @@ func DeleteWindow(name string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
func makeNode(parent *Node, title string, x int, y int) *Node {
|
func makeNode(parent *Node, title string, x int, y int) *Node {
|
||||||
var node Node
|
var node Node
|
||||||
|
@ -137,26 +143,6 @@ func (n *Node) uiNewWindow(title string, x int, y int) {
|
||||||
|
|
||||||
func mapWindow(parent *Node, window *ui.Window, title string, x int, y int) *Node {
|
func mapWindow(parent *Node, window *ui.Window, title string, x int, y int) *Node {
|
||||||
log.Println("gui.WindowMap START title =", title)
|
log.Println("gui.WindowMap START title =", title)
|
||||||
if Data.WindowMap[title] != nil {
|
|
||||||
log.Println("Data.WindowMap[title] already exists title =", title)
|
|
||||||
title = title + Config.prefix + strconv.Itoa(Config.counter)
|
|
||||||
Config.counter += 1
|
|
||||||
}
|
|
||||||
if Data.WindowMap[title] != nil {
|
|
||||||
log.Println("Data.WindowMap[title] already exists title =", title)
|
|
||||||
panic("Data.WindowMap[newGuiWindow.Name] already exists")
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
var newGuiWindow GuiWindow
|
|
||||||
newGuiWindow.Width = x
|
|
||||||
newGuiWindow.Height = y
|
|
||||||
newGuiWindow.Name = title
|
|
||||||
newGuiWindow.UiWindow = window
|
|
||||||
|
|
||||||
newGuiWindow.EntryMap = make(map[string]*GuiEntry)
|
|
||||||
|
|
||||||
Data.WindowMap[newGuiWindow.Name] = &newGuiWindow
|
|
||||||
|
|
||||||
node := makeNode(parent, title, x, y)
|
node := makeNode(parent, title, x, y)
|
||||||
node.uiWindow = window
|
node.uiWindow = window
|
||||||
|
|
Loading…
Reference in New Issue