BOX: kill GuiBox

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2021-10-31 21:07:36 -05:00
parent df1978e6a8
commit d6980daa81
6 changed files with 24 additions and 22 deletions

View File

@ -50,7 +50,7 @@ func CreateFontButton(n *Node, action string) *GuiButton {
var newGB GuiButton
newGB.Name = "FONT"
newGB.FB = ui.NewFontButton()
newGB.Box = n.box
// newGB.Box = n.box
Data.AllButtons = append(Data.AllButtons, &newGB)
newGB.FB.OnChanged(func (*ui.FontButton) {
@ -67,7 +67,7 @@ func CreateColorButton(n *Node, custom func(*GuiButton), name string, values int
var newCB GuiButton
newCB.Name = name
newCB.CB = ui.NewColorButton()
newCB.Box = n.box
// newCB.Box = n.box
newCB.Custom = custom
newCB.Values = values
@ -83,6 +83,6 @@ func CreateColorButton(n *Node, custom func(*GuiButton), name string, values int
Data.MouseClick(&newCB)
}
})
n.box.Append(newCB.CB, false)
n.uiBox.Append(newCB.CB, false)
return &newCB
}

View File

@ -295,6 +295,7 @@ func dumpBox(s string) {
// log.Println("gui.DumpBoxes()\tWindow.UiWindow type =", reflect.TypeOf(window.UiWindow))
log.Println("gui.DumpBoxes()\tWindow.UiWindow =", window.UiWindow)
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)
@ -307,6 +308,7 @@ func dumpBox(s string) {
}
}
log.Println("gui.dumpBox() BoxMap END")
*/
if window.UiTab != nil {
pages := window.UiTab.NumPages()
log.Println("gui.DumpBoxes()\tWindow.UiTab.NumPages() =", pages)

View File

@ -40,10 +40,12 @@ func DumpWindows() {
func DumpMap() {
for name, window := range Data.WindowMap {
log.Println("gui.DumpBoxes() MAP: ", name)
log.Println("gui.DumpBoxes() BOXES:", name)
log.Println("gui.DumpBoxes() window:", window)
/*
for name, abox := range window.BoxMap {
log.Printf("gui.DumpBoxes() \tBOX mapname=%-12s abox.Name=%-12s", name, abox.Name)
}
*/
}
}
@ -59,6 +61,7 @@ func DumpBoxes() {
// log.Println("gui.DumpBoxes()\tWindow.UiWindow type =", reflect.TypeOf(window.UiWindow))
log.Println("gui.DumpBoxes()\tWindow.UiWindow =", window.UiWindow)
log.Println("gui.DumpBoxes()\tWindow.UiTab =", window.UiTab)
/*
for name, abox := range window.BoxMap {
log.Printf("gui.DumpBoxes() \tBOX mapname=%-12s abox.Name=%-12s", name, abox.Name)
if name == "MAINBOX" {
@ -68,6 +71,7 @@ func DumpBoxes() {
}
}
}
*/
if window.UiTab != nil {
// log.Println("gui.DumpBoxes()\tWindow.UiTab type =", reflect.TypeOf(window.UiTab))
// log.Println("gui.DumpBoxes()\tWindow.UiTab =", window.UiTab)

View File

@ -50,7 +50,6 @@ type Node struct {
children []*Node
window *GuiWindow
box *GuiBox
area *GuiArea
custom func(*Node)
@ -85,7 +84,7 @@ func (n *Node) Dump() {
log.Println("gui.Node.Dump() children = ", n.children)
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() uiTab = ", n.uiTab)
@ -237,10 +236,12 @@ func (n *Node) AddTab(title string, uiC *ui.Box) *Node {
log.Println("gui.Node.AddTab() ERROR ui.Window == nil")
return nil
}
/*
if parent.box == nil {
parent.Dump()
// panic("gui.AddTab() ERROR box == nil")
}
*/
if parent.uiTab == nil {
inittab := ui.NewTab() // no, not that 'inittab'
parent.uiWindow.SetChild(inittab)

View File

@ -94,7 +94,7 @@ type GuiWindow struct {
// MakeWindow func(*GuiBox) *GuiBox
// the components of the window
BoxMap map[string]*GuiBox
// BoxMap map[string]*GuiBox
EntryMap map[string]*GuiEntry
Area *GuiArea
@ -112,6 +112,7 @@ func (w *GuiWindow) Dump() {
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 {
@ -124,7 +125,9 @@ type GuiBox struct {
// 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)
@ -144,6 +147,7 @@ func (b *GuiBox) SetTitle(title string) {
b.Window.UiWindow.SetTitle(title)
return
}
*/
func (w *GuiWindow) SetNode(n *Node) {
if (w.node != nil) {
@ -157,6 +161,7 @@ func (w *GuiWindow) SetNode(n *Node) {
}
}
/*
func (b *GuiBox) SetNode(n *Node) {
if (b.node != nil) {
b.Dump()
@ -176,6 +181,7 @@ func (b *GuiBox) Append(child ui.Control, x bool) {
}
b.UiBox.Append(child, x)
}
*/
// Note: every mouse click is handled
// as a 'Button' regardless of where
@ -183,7 +189,7 @@ func (b *GuiBox) Append(child ui.Control, x bool) {
// call this 'GuiMouseClick'
type GuiButton struct {
Name string // field for human readable name
Box *GuiBox // what box the button click was in
// box2 *GuiBox // what box the button click was in
// a callback function for the main application
Custom func(*GuiButton)
@ -204,7 +210,7 @@ type GuiEntry struct {
Normalize func(string) string // function to 'normalize' the data
B *GuiButton
Box *GuiBox
// Box *GuiBox
// andlabs/ui abstraction mapping
UiEntry *ui.Entry
@ -217,7 +223,7 @@ type GuiEntry struct {
//
type GuiArea struct {
Button *GuiButton // what button handles mouse events
Box *GuiBox
// Box *GuiBox
UiAttrstr *ui.AttributedString
UiArea *ui.Area
@ -255,7 +261,7 @@ type TableData struct {
Cells [20]CellData
Human [20]HumanMap
Box *GuiBox
// Box *GuiBox
n *Node
lastRow int

View File

@ -154,23 +154,12 @@ func mapWindow(parent *Node, window *ui.Window, title string, x int, y int) *Nod
newGuiWindow.Name = title
newGuiWindow.UiWindow = window
newGuiWindow.BoxMap = make(map[string]*GuiBox)
newGuiWindow.EntryMap = make(map[string]*GuiEntry)
Data.WindowMap[newGuiWindow.Name] = &newGuiWindow
/*
var box GuiBox
box.Window = &newGuiWindow
box.Name = title
*/
node := makeNode(parent, title, x, y)
node.uiWindow = window
// node.box = &box
// box.node = node
// newGuiWindow.BoxMap["jcarrInitTest"] = &box
return node
}