From 213c7d153b06d3e1211d1cdeae1e4f7833cb89f7 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sun, 31 Oct 2021 14:21:36 -0500 Subject: REFACTOR: refactor everything to gui.Node struct Signed-off-by: Jeff Carr --- debug-window.go | 355 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 355 insertions(+) create mode 100644 debug-window.go (limited to 'debug-window.go') diff --git a/debug-window.go b/debug-window.go new file mode 100644 index 0000000..19f276d --- /dev/null +++ b/debug-window.go @@ -0,0 +1,355 @@ +package gui + +import ( + "log" + // "fmt" + "strconv" + + "github.com/andlabs/ui" + _ "github.com/andlabs/ui/winmanifest" + "github.com/davecgh/go-spew/spew" +) + +var names = make([]string, 100) +var nodeNames = make([]string, 100) + +func DebugWindow() { + Config.Title = "DebugWindow()" + node := NewWindow() + node.DebugTab("WIT GUI Debug Tab") +} + +// TODO: remove this crap +// What does this actually do? +// It populates the nodeNames in a map. No, not a map, an array. +// What is the difference again? (other than one being in order and a predefined length) +func addNodeName(c *ui.Combobox, s string, id string) { + c.Append(s) + nodeNames[y] = id + y = y + 1 +} + +func makeWindowDebug() *ui.Box { + hbox := ui.NewHorizontalBox() + hbox.SetPadded(true) + + ///////////////////////////////////////////////////// + vbox := addGroup(hbox, "range Data.WindowMap") + cbox := ui.NewCombobox() + + for name, _ := range Data.WindowMap { + if (Config.Debug) { + log.Println("range Data.WindowMap() name =", name) + } + addName(cbox, name) + } + cbox.SetSelected(0) + + vbox.Append(cbox, false) + + cbox.OnSelected(func(*ui.Combobox) { + x := cbox.Selected() + log.Println("x =", x) + log.Println("names[x] =", names[x]) + dumpBox(names[x]) + }) + + ///////////////////////////////////////////////////// + vbox = addGroup(hbox, "Debug Window") + + b1 := addButton(vbox, "dumpBox(window)") + b1.OnClicked(func(*ui.Button) { + x := cbox.Selected() + log.Println("x =", x) + log.Println("names[x] =", 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") + + dump3 := addButton(vbox, "Dump Windows") + dump3.OnClicked(func(*ui.Button) { + DumpWindows() + }) + + dump2 := addButton(vbox, "Dump Boxes") + dump2.OnClicked(func(*ui.Button) { + DumpBoxes() + }) + + dump1 := addButton(vbox, "Dump MAP") + dump1.OnClicked(func(*ui.Button) { + DumpMap() + }) + + ///////////////////////////////////////////////////// + nodeBox := addGroup(hbox, "Windows:") + nodeCombo := ui.NewCombobox() + + for name, node := range Data.NodeMap { + if (Config.Debug) { + log.Println("range Data.NodeMap() name =", name) + } + tmp := node.id + " (" + name + ")" + addNodeName(nodeCombo, tmp, node.id) + } + nodeCombo.SetSelected(0) + + nodeBox.Append(nodeCombo, false) + + nodeCombo.OnSelected(func(*ui.Combobox) { + y := nodeCombo.Selected() + log.Println("y =", y) + log.Println("nodeNames[y] =", nodeNames[y]) + node := Data.findId(nodeNames[y]) + if (node != nil) { + node.Dump() + } + }) + + ///////////////////////////////////////////////////// + vbox = addGroup(hbox, "Node Debug") + + n1 := addButton(vbox, "Data.DumpNodeMap()") + n1.OnClicked(func(*ui.Button) { + Data.DumpNodeMap() + }) + + n1 = addButton(vbox, "Data.ListChildren(false)") + n1.OnClicked(func(*ui.Button) { + Data.ListChildren(false) + }) + + n1 = addButton(vbox, "Data.ListChildren(true)") + n1.OnClicked(func(*ui.Button) { + Data.ListChildren(true) + }) + + n1 = addButton(vbox, "Node.Dump()") + n1.OnClicked(func(*ui.Button) { + y := nodeCombo.Selected() + log.Println("y =", y) + log.Println("nodeNames[y] =", nodeNames[y]) + node := Data.findId(nodeNames[y]) + if (node != nil) { + node.Dump() + } + }) + + n1 = addButton(vbox, "Node.ListChildren(false)") + n1.OnClicked(func(*ui.Button) { + y := nodeCombo.Selected() + log.Println("y =", y) + log.Println("nodeNames[y] =", nodeNames[y]) + node := Data.findId(nodeNames[y]) + if (node != nil) { + node.ListChildren(false) + } + }) + + n1 = addButton(vbox, "Node.ListChildren(true)") + n1.OnClicked(func(*ui.Button) { + y := nodeCombo.Selected() + log.Println("y =", y) + log.Println("nodeNames[y] =", nodeNames[y]) + node := Data.findId(nodeNames[y]) + if (node != nil) { + node.ListChildren(true) + } + }) + + n1 = addButton(vbox, "Node.AddDebugTab") + n1.OnClicked(func(*ui.Button) { + y := nodeCombo.Selected() + log.Println("y =", y) + log.Println("nodeNames[y] =", nodeNames[y]) + node := Data.findId(nodeNames[y]) + if (node != nil) { + node.DebugTab("added this DebugTab") + } + }) + + n1 = addButton(vbox, "Node.DemoAndlabsUiTab") + n1.OnClicked(func(*ui.Button) { + y := nodeCombo.Selected() + log.Println("y =", y) + log.Println("nodeNames[y] =", nodeNames[y]) + node := Data.findId(nodeNames[y]) + if (node != nil) { + node.DemoAndlabsUiTab("ran gui.AddDemoAndlabsUiTab() " + strconv.Itoa(Config.counter)) + } + }) + + return hbox +} + +// TODO: remove this crap +var x int = 0 +var y int = 0 + +// TODO: remove this crap +func addName(c *ui.Combobox, s string) { + c.Append(s) + names[x] = s + x = x + 1 +} + +func addGroup(b *ui.Box, name string) *ui.Box { + group := ui.NewGroup(name) + group.SetMargined(true) + b.Append(group, true) + + vbox := ui.NewVerticalBox() + vbox.SetPadded(true) + group.SetChild(vbox) + + return vbox +} + +func dumpBox(s string) { + var name string + var window *GuiWindow + + for name, window = range Data.WindowMap { + if name != s { + continue + } + log.Println("gui.DumpBoxes() MAP: ", name) + if window.TabNumber == nil { + log.Println("gui.DumpBoxes() \tWindows.TabNumber = nil") + } else { + log.Println("gui.DumpBoxes() \tWindows.TabNumber =", *window.TabNumber) + } + log.Println("gui.DumpBoxes()\tWindow.name =", window.Name) + // 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) + 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 { + pages := window.UiTab.NumPages() + log.Println("gui.DumpBoxes()\tWindow.UiTab.NumPages() =", pages) + tabSetMargined(window.UiTab) + if Config.Debug { + scs := spew.ConfigState{MaxDepth: 2} + scs.Dump(window.UiTab) + } + } + } +} + +func addButton(box *ui.Box, name string) *ui.Button { + button := ui.NewButton(name) + + button.OnClicked(func(*ui.Button) { + log.Println("Should do something here") + }) + + box.Append(button, false) + return button +} + +func (n *Node) DebugTab(title string) { + newNode := n.AddTab(title, makeWindowDebug()) + if (Config.DebugNode) { + newNode.Dump() + } + tabSetMargined(newNode.uiTab) +} + +// This sets _all_ the tabs to Margin = true +// +// TODO: do proper tab tracking (will be complicated). low priority +func tabSetMargined(tab *ui.Tab) { + if (Config.DebugTabs) { + log.Println("tabSetMargined() IGNORE THIS") + } + c := tab.NumPages() + for i := 0; i < c; i++ { + if (Config.DebugTabs) { + log.Println("tabSetMargined() i =", i) + } + tab.SetMargined(i, true) + } +} -- cgit v1.2.3 From c95392d4609f06eb0b86fc6a25b93613ee3770fb Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sun, 31 Oct 2021 21:07:36 -0500 Subject: BOX: kill GuiBox Signed-off-by: Jeff Carr --- button.go | 6 +++--- debug-window.go | 2 ++ debug.go | 6 +++++- new-structs.go | 5 +++-- structs.go | 16 +++++++++++----- window.go | 11 ----------- 6 files changed, 24 insertions(+), 22 deletions(-) (limited to 'debug-window.go') diff --git a/button.go b/button.go index 8135962..5017f7a 100644 --- a/button.go +++ b/button.go @@ -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 } diff --git a/debug-window.go b/debug-window.go index 19f276d..f058a1e 100644 --- a/debug-window.go +++ b/debug-window.go @@ -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) diff --git a/debug.go b/debug.go index 0b0baa4..d0e814f 100644 --- a/debug.go +++ b/debug.go @@ -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) diff --git a/new-structs.go b/new-structs.go index d821a3f..bba6347 100644 --- a/new-structs.go +++ b/new-structs.go @@ -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) diff --git a/structs.go b/structs.go index b298f43..c31b021 100644 --- a/structs.go +++ b/structs.go @@ -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 diff --git a/window.go b/window.go index 8b5f9a5..6b2a114 100644 --- a/window.go +++ b/window.go @@ -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 } -- cgit v1.2.3 From 59d15f3fcf9799e00566aad7678f29add4e19dd4 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sun, 31 Oct 2021 21:46:30 -0500 Subject: REFACTOR: remove GuiWindow & GuiBox Signed-off-by: Jeff Carr --- area.go | 14 +++++---- debug-window.go | 93 ++++----------------------------------------------------- debug.go | 12 +++----- find.go | 12 ++------ gui.go | 2 +- new-structs.go | 12 ++++---- structs.go | 75 ++++------------------------------------------ table.go | 2 +- window.go | 34 +++++++-------------- 9 files changed, 45 insertions(+), 211 deletions(-) (limited to 'debug-window.go') diff --git a/area.go b/area.go index 2cf3d18..4fb05ec 100644 --- a/area.go +++ b/area.go @@ -12,22 +12,24 @@ func makeGenericArea(n *Node, newText *ui.AttributedString, custom func(*GuiButt // There should be another way to do this (?) var newB *GuiButton newB = CreateFontButton(n, "AREA") - // newB.Box = gb newB.Custom = custom +/* gw := n.window // initialize the GuiArea{} - gw.Area = new(GuiArea) gw.Area.Button = newB +*/ + area := new(GuiArea) + // gw.Area.Box = gb - gw.Area.UiAttrstr = newText - gw.Area.UiArea = ui.NewArea(gw.Area) + n.uiAttrstr = newText + n.uiArea = ui.NewArea(area) if (Config.Debug) { - spew.Dump(gw.Area.UiArea) + spew.Dump(n.uiArea) log.Println("DEBUGGING", Config.Debug) } else { - log.Println("NOT DEBUGGING AREA mhAH.Button =", gw.Area.Button) + log.Println("NOT DEBUGGING AREA mhAH.Button =", n.uiButton) } } diff --git a/debug-window.go b/debug-window.go index f058a1e..0849f71 100644 --- a/debug-window.go +++ b/debug-window.go @@ -7,7 +7,7 @@ import ( "github.com/andlabs/ui" _ "github.com/andlabs/ui/winmanifest" - "github.com/davecgh/go-spew/spew" +// "github.com/davecgh/go-spew/spew" ) var names = make([]string, 100) @@ -33,6 +33,7 @@ func makeWindowDebug() *ui.Box { hbox := ui.NewHorizontalBox() hbox.SetPadded(true) +/* ///////////////////////////////////////////////////// vbox := addGroup(hbox, "range Data.WindowMap") cbox := ui.NewCombobox() @@ -44,7 +45,6 @@ func makeWindowDebug() *ui.Box { addName(cbox, name) } cbox.SetSelected(0) - vbox.Append(cbox, false) cbox.OnSelected(func(*ui.Combobox) { @@ -65,76 +65,6 @@ func makeWindowDebug() *ui.Box { 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") @@ -152,6 +82,7 @@ func makeWindowDebug() *ui.Box { dump1.OnClicked(func(*ui.Button) { DumpMap() }) +*/ ///////////////////////////////////////////////////// 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.OnClicked(func(*ui.Button) { @@ -277,6 +208,7 @@ func addGroup(b *ui.Box, name string) *ui.Box { return vbox } +/* func dumpBox(s string) { var name string 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 =", 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) - 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 { pages := window.UiTab.NumPages() 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 { button := ui.NewButton(name) diff --git a/debug.go b/debug.go index d0e814f..2caf6d0 100644 --- a/debug.go +++ b/debug.go @@ -5,7 +5,7 @@ import ( "log" "time" - "github.com/davecgh/go-spew/spew" + // "github.com/davecgh/go-spew/spew" ) // WatchGUI() opens a goroutine @@ -22,7 +22,7 @@ func WatchGUI() { if count > 20 { log.Println("Sleep() in watchGUI()") if Config.Debug { - DumpBoxes() + // DumpBoxes() } count = 0 } @@ -31,6 +31,7 @@ func WatchGUI() { } } +/* func DumpWindows() { for name, _ := range Data.WindowMap { log.Println("gui.DumpWindows() window =", name) @@ -41,11 +42,9 @@ func DumpMap() { for name, window := range Data.WindowMap { log.Println("gui.DumpBoxes() MAP: ", 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) } - */ } } @@ -61,7 +60,6 @@ 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" { @@ -71,7 +69,6 @@ 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) @@ -89,7 +86,6 @@ func DumpBoxes() { } } } - /* for i, window := range Data.Windows { if (window.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) } } - */ } +*/ func addTableTab() { var parts []TableColumnData diff --git a/find.go b/find.go index 619ba36..5eb0854 100644 --- a/find.go +++ b/find.go @@ -17,19 +17,11 @@ func (n *Node) FindControl() *ui.Control { return n.uiControl } +/* func (w *GuiWindow) FindNode() *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 { if Data.NodeMap == nil { diff --git a/gui.go b/gui.go index 4174133..bb7e0e5 100644 --- a/gui.go +++ b/gui.go @@ -17,7 +17,7 @@ func init() { log.Println("gui.init() has been run") 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.NodeSlice = make([]*Node, 0) diff --git a/new-structs.go b/new-structs.go index bba6347..32d34aa 100644 --- a/new-structs.go +++ b/new-structs.go @@ -49,16 +49,18 @@ type Node struct { parent *Node children []*Node - window *GuiWindow + // window *GuiWindow area *GuiArea custom func(*Node) uiControl *ui.Control uiButton *ui.Button uiWindow *ui.Window - uiTab *ui.Tab - uiBox *ui.Box - uiText *ui.EditableCombobox + uiAttrstr *ui.AttributedString + uiTab *ui.Tab + uiBox *ui.Box + uiArea *ui.Area + uiText *ui.EditableCombobox } 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() window = ", n.window) + // log.Println("gui.Node.Dump() window = ", n.window) // log.Println("gui.Node.Dump() box = ", n.box) log.Println("gui.Node.Dump() uiWindow = ", n.uiWindow) diff --git a/structs.go b/structs.go index c31b021..9a47e44 100644 --- a/structs.go +++ b/structs.go @@ -2,7 +2,7 @@ package gui import ( "image/color" - "log" +// "log" "github.com/andlabs/ui" "golang.org/x/image/font" @@ -42,7 +42,7 @@ type GuiData struct { // A map of all the entry boxes AllEntries []*GuiEntry - WindowMap map[string]*GuiWindow + // WindowMap map[string]*GuiWindow // Store access to everything via binary tree's NodeMap map[string]*Node @@ -62,7 +62,7 @@ type GuiData struct { type GuiTab struct { Name string // field for human readable name 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 // can destroy and replace it with something else // +/* type GuiWindow struct { Name string // field for human readable name Width int @@ -90,11 +91,7 @@ type GuiWindow struct { Axis int // does it add items to the X or Y axis TabNumber *int // the andlabs/ui tab index - // the callback function to make the window contents - // MakeWindow func(*GuiBox) *GuiBox - // the components of the window - // BoxMap map[string]*GuiBox EntryMap map[string]*GuiEntry Area *GuiArea @@ -104,7 +101,9 @@ type GuiWindow struct { UiWindow *ui.Window UiTab *ui.Tab // if this != nil, the window is 'tabbed' } +*/ +/* func (w *GuiWindow) Dump() { log.Println("gui.GuiWindow.Dump() Name = ", w.Name) log.Println("gui.GuiWindow.Dump() node = ", w.node) @@ -112,43 +111,6 @@ 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 { - 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) { if (w.node != nil) { w.Dump() @@ -160,27 +122,6 @@ func (w *GuiWindow) SetNode(n *Node) { 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 @@ -189,7 +130,6 @@ func (b *GuiBox) Append(child ui.Control, x bool) { // call this 'GuiMouseClick' type GuiButton struct { Name string // field for human readable name - // box2 *GuiBox // what box the button click was in // a callback function for the main application Custom func(*GuiButton) @@ -210,7 +150,6 @@ type GuiEntry struct { Normalize func(string) string // function to 'normalize' the data B *GuiButton - // Box *GuiBox // andlabs/ui abstraction mapping UiEntry *ui.Entry @@ -223,7 +162,6 @@ type GuiEntry struct { // type GuiArea struct { Button *GuiButton // what button handles mouse events - // Box *GuiBox UiAttrstr *ui.AttributedString UiArea *ui.Area @@ -261,7 +199,6 @@ type TableData struct { Cells [20]CellData Human [20]HumanMap - // Box *GuiBox n *Node lastRow int diff --git a/table.go b/table.go index a149450..378cab2 100644 --- a/table.go +++ b/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() return n.AddTableBox(name, rowcount, parts) } diff --git a/window.go b/window.go index 6b2a114..c554d9c 100644 --- a/window.go +++ b/window.go @@ -9,14 +9,19 @@ import ( _ "github.com/andlabs/ui/winmanifest" ) -func MessageWindow(gw *GuiWindow, msg1 string, msg2 string) { - ui.MsgBox(gw.UiWindow, msg1, msg2) +func (n *Node) MessageWindow2(msg1 string, msg2 string) (*Node) { + ui.MsgBox(n.uiWindow, msg1, msg2) + // TODO: make new node + return n } -func ErrorWindow(gw *GuiWindow, msg1 string, msg2 string) { - ui.MsgBoxError(gw.UiWindow, msg1, msg2) +func (n *Node) ErrorWindow2(msg1 string, msg2 string) (*Node) { + ui.MsgBoxError(n.uiWindow, msg1, msg2) + // TODO: make new node + return n } +/* func DeleteWindow(name string) { log.Println("gui.DeleteWindow() START name =", name) window := Data.WindowMap[name] @@ -51,6 +56,7 @@ func DeleteWindow(name string) { } } } +*/ func makeNode(parent *Node, title string, x int, y int) *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 { 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.uiWindow = window -- cgit v1.2.3 From 2a6c54b785ccb7e18b586f38c73ca57197b4c733 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sun, 31 Oct 2021 22:22:16 -0500 Subject: CLEAN: more code removals Signed-off-by: Jeff Carr --- debug-window.go | 83 --------------------------------------------------------- find.go | 6 ----- gui.go | 1 - new-structs.go | 1 - structs.go | 59 ---------------------------------------- window.go | 37 ------------------------- 6 files changed, 187 deletions(-) (limited to 'debug-window.go') diff --git a/debug-window.go b/debug-window.go index 0849f71..288d433 100644 --- a/debug-window.go +++ b/debug-window.go @@ -33,57 +33,6 @@ func makeWindowDebug() *ui.Box { hbox := ui.NewHorizontalBox() hbox.SetPadded(true) -/* - ///////////////////////////////////////////////////// - vbox := addGroup(hbox, "range Data.WindowMap") - cbox := ui.NewCombobox() - - for name, _ := range Data.WindowMap { - if (Config.Debug) { - log.Println("range Data.WindowMap() name =", name) - } - addName(cbox, name) - } - cbox.SetSelected(0) - vbox.Append(cbox, false) - - cbox.OnSelected(func(*ui.Combobox) { - x := cbox.Selected() - log.Println("x =", x) - log.Println("names[x] =", names[x]) - dumpBox(names[x]) - }) - - ///////////////////////////////////////////////////// - vbox = addGroup(hbox, "Debug Window") - - b1 := addButton(vbox, "dumpBox(window)") - b1.OnClicked(func(*ui.Button) { - x := cbox.Selected() - log.Println("x =", x) - log.Println("names[x] =", names[x]) - dumpBox(names[x]) - }) - - ///////////////////////////////////////////////////// - vbox = addGroup(hbox, "Global Debug") - - dump3 := addButton(vbox, "Dump Windows") - dump3.OnClicked(func(*ui.Button) { - DumpWindows() - }) - - dump2 := addButton(vbox, "Dump Boxes") - dump2.OnClicked(func(*ui.Button) { - DumpBoxes() - }) - - dump1 := addButton(vbox, "Dump MAP") - dump1.OnClicked(func(*ui.Button) { - DumpMap() - }) -*/ - ///////////////////////////////////////////////////// nodeBox := addGroup(hbox, "Windows:") nodeCombo := ui.NewCombobox() @@ -208,38 +157,6 @@ func addGroup(b *ui.Box, name string) *ui.Box { return vbox } -/* -func dumpBox(s string) { - var name string - var window *GuiWindow - - for name, window = range Data.WindowMap { - if name != s { - continue - } - log.Println("gui.DumpBoxes() MAP: ", name) - if window.TabNumber == nil { - log.Println("gui.DumpBoxes() \tWindows.TabNumber = nil") - } else { - log.Println("gui.DumpBoxes() \tWindows.TabNumber =", *window.TabNumber) - } - log.Println("gui.DumpBoxes()\tWindow.name =", window.Name) - // 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) - if window.UiTab != nil { - pages := window.UiTab.NumPages() - log.Println("gui.DumpBoxes()\tWindow.UiTab.NumPages() =", pages) - tabSetMargined(window.UiTab) - if Config.Debug { - scs := spew.ConfigState{MaxDepth: 2} - scs.Dump(window.UiTab) - } - } - } -} -*/ - func addButton(box *ui.Box, name string) *ui.Button { button := ui.NewButton(name) diff --git a/find.go b/find.go index 5eb0854..15f2714 100644 --- a/find.go +++ b/find.go @@ -17,12 +17,6 @@ func (n *Node) FindControl() *ui.Control { return n.uiControl } -/* -func (w *GuiWindow) FindNode() *Node { - return w.node -} -*/ - func FindNode(name string) *Node { if Data.NodeMap == nil { log.Println("gui.FindNode() gui.Data.NodeMap == nil") diff --git a/gui.go b/gui.go index bb7e0e5..236affb 100644 --- a/gui.go +++ b/gui.go @@ -17,7 +17,6 @@ func init() { log.Println("gui.init() has been run") Data.buttonMap = make(map[*ui.Button]*GuiButton) - // Data.WindowMap = make(map[string]*GuiWindow) Data.NodeMap = make(map[string]*Node) Data.NodeSlice = make([]*Node, 0) diff --git a/new-structs.go b/new-structs.go index 32d34aa..6f222b9 100644 --- a/new-structs.go +++ b/new-structs.go @@ -49,7 +49,6 @@ type Node struct { parent *Node children []*Node - // window *GuiWindow area *GuiArea custom func(*Node) diff --git a/structs.go b/structs.go index 9a47e44..dc0c1f4 100644 --- a/structs.go +++ b/structs.go @@ -65,65 +65,6 @@ type GuiTab struct { // Window *GuiWindow // the parent Window } -// -// stores information on the 'window' -// -// This merges the concept of andlabs/ui *Window and *Tab -// -// More than one Window is not supported in a cross platform -// sense & may never be. On Windows and MacOS, you have to have -// 'tabs'. Even under Linux, more than one Window is currently -// unstable -// -// This code will make a 'GuiWindow' regardless of if it is -// a stand alone window (which is more or less working on Linux) -// or a 'tab' inside a window (which is all that works on MacOS -// and MSWindows. -// -// This struct keeps track of what is in the window so you -// can destroy and replace it with something else -// -/* -type GuiWindow struct { - Name string // field for human readable name - Width int - Height int - Axis int // does it add items to the X or Y axis - TabNumber *int // the andlabs/ui tab index - - // the components of the window - EntryMap map[string]*GuiEntry - Area *GuiArea - - node *Node - - // andlabs/ui abstraction mapping - UiWindow *ui.Window - UiTab *ui.Tab // if this != nil, the window is 'tabbed' -} -*/ - -/* -func (w *GuiWindow) Dump() { - log.Println("gui.GuiWindow.Dump() Name = ", w.Name) - log.Println("gui.GuiWindow.Dump() node = ", w.node) - log.Println("gui.GuiWindow.Dump() Width = ", w.Width) - log.Println("gui.GuiWindow.Dump() Height = ", w.Height) -} - -func (w *GuiWindow) SetNode(n *Node) { - if (w.node != nil) { - w.Dump() - panic("gui.SetNode() Error not nil") - } - w.node = n - if (w.node == nil) { - w.Dump() - panic("gui.SetNode() node == nil") - } -} -*/ - // Note: every mouse click is handled // as a 'Button' regardless of where // the user clicks it. You could probably diff --git a/window.go b/window.go index c554d9c..48aaa17 100644 --- a/window.go +++ b/window.go @@ -21,43 +21,6 @@ func (n *Node) ErrorWindow2(msg1 string, msg2 string) (*Node) { return n } -/* -func DeleteWindow(name string) { - log.Println("gui.DeleteWindow() START name =", name) - window := Data.WindowMap[name] - if window == nil { - log.Println("gui.DeleteWindow() NO WINDOW WITH name =", name) - return - } - - log.Println("gui.DumpBoxes() MAP: ", name) - log.Println("gui.DumpBoxes()\tWindow.name =", window.Name) - if window.TabNumber == nil { - log.Println("gui.DumpBoxes() \tWindows.TabNumber = nil") - } - tab := *window.TabNumber - log.Println("gui.DumpBoxes() \tWindows.TabNumber =", tab) - log.Println("gui.DumpBoxes() \tSHOULD DELETE TAB", tab, "HERE") - window.UiTab.Delete(tab) - delete(Data.WindowMap, name) - - // renumber tabs here - for name, window := range Data.WindowMap { - log.Println("gui.DumpBoxes() MAP: ", name) - if window.TabNumber == nil { - log.Println("gui.DumpBoxes() \tWindows.TabNumber = nil") - } else { - log.Println("gui.DumpBoxes() \tWindows.TabNumber =", *window.TabNumber) - if tab < *window.TabNumber { - log.Println("gui.DumpBoxes() \tSubtracting 1 from TabNumber") - *window.TabNumber -= 1 - log.Println("gui.DumpBoxes() \tWindows.TabNumber is now =", *window.TabNumber) - } - } - } -} -*/ - func makeNode(parent *Node, title string, x int, y int) *Node { var node Node node.Name = title -- cgit v1.2.3 From ff30a1acbb0e56c358f0490b0e89e8324268b032 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Thu, 4 Nov 2021 02:23:41 -0500 Subject: GOOD: use global 'Stretchy' setting Signed-off-by: Jeff Carr --- box.go | 2 +- button.go | 4 ++-- debug-window.go | 6 +++--- demo-window.go | 22 ++-------------------- entry.go | 3 +-- gui.go | 1 + new-structs.go | 6 +++--- structs.go | 1 + 8 files changed, 14 insertions(+), 31 deletions(-) (limited to 'debug-window.go') diff --git a/box.go b/box.go index 65a8d39..5b4febe 100644 --- a/box.go +++ b/box.go @@ -37,7 +37,7 @@ func (n *Node) AddComboBox(title string, s ...string) *Node { } }) - box.Append(ecbox, false) + box.Append(ecbox, Config.Stretchy) return newNode } diff --git a/button.go b/button.go index ef73f73..9895ed8 100644 --- a/button.go +++ b/button.go @@ -32,7 +32,7 @@ func (n *Node) AddButton(name string, custom func(*Node)) *Node { log.Println("reflect.TypeOF(uiButton) =", reflect.TypeOf(button)) } // true == expand, false == make normal size button - n.uiBox.Append(button, false) + n.uiBox.Append(button, Config.Stretchy) n.uiButton = button newNode := n.makeNode(name, 888, 888 + Config.counter) @@ -73,6 +73,6 @@ func (n *Node) CreateColorButton(custom func(*Node), name string, values interfa Data.MouseClick(n) } }) - n.uiBox.Append(n.uiColorButton, false) + n.uiBox.Append(n.uiColorButton, Config.Stretchy) return n } diff --git a/debug-window.go b/debug-window.go index 288d433..72272ec 100644 --- a/debug-window.go +++ b/debug-window.go @@ -46,7 +46,7 @@ func makeWindowDebug() *ui.Box { } nodeCombo.SetSelected(0) - nodeBox.Append(nodeCombo, false) + nodeBox.Append(nodeCombo, Config.Stretchy) nodeCombo.OnSelected(func(*ui.Combobox) { y := nodeCombo.Selected() @@ -148,7 +148,7 @@ func addName(c *ui.Combobox, s string) { func addGroup(b *ui.Box, name string) *ui.Box { group := ui.NewGroup(name) group.SetMargined(true) - b.Append(group, true) + b.Append(group, Config.Stretchy) vbox := ui.NewVerticalBox() vbox.SetPadded(true) @@ -164,7 +164,7 @@ func addButton(box *ui.Box, name string) *ui.Button { log.Println("Should do something here") }) - box.Append(button, false) + box.Append(button, Config.Stretchy) return button } diff --git a/demo-window.go b/demo-window.go index 3d17c35..6cbb5fd 100644 --- a/demo-window.go +++ b/demo-window.go @@ -16,7 +16,7 @@ func (n *Node) AddGroup(title string) *Node { } group := ui.NewGroup(title) group.SetMargined(true) - hbox.Append(group, true) + hbox.Append(group, Config.Stretchy) vbox := ui.NewVerticalBox() vbox.SetPadded(true) @@ -77,7 +77,7 @@ func (n *Node) MakeGroupEdit(title string) *Node { group := ui.NewGroup(title) group.SetMargined(true) - n.uiBox.Append(group, true) + n.uiBox.Append(group, Config.Stretchy) entrybox := ui.NewNonWrappingMultilineEntry() @@ -89,22 +89,4 @@ func (n *Node) MakeGroupEdit(title string) *Node { newNode.uiMultilineEntry = entrybox newNode.uiGroup = group return newNode - -/* - panic("dump") - entryForm := ui.NewForm() - entryForm.SetPadded(true) - group.SetChild(entryForm) - - entryForm.Append("Entry", ui.NewEntry(), false) - entryForm.Append("Password Entry", ui.NewPasswordEntry(), false) - entryForm.Append("Search Entry", ui.NewSearchEntry(), false) - entryForm.Append("Multiline Entry", ui.NewMultilineEntry(), true) - entryForm.Append("Multiline Entry No Wrap", ui.NewNonWrappingMultilineEntry(), true) - - origbox.Append(vbox, false) - newNode := n.AddNode(title) - newNode.uiBox = vbox -*/ - return n } diff --git a/entry.go b/entry.go index a69adba..539c2f7 100644 --- a/entry.go +++ b/entry.go @@ -12,8 +12,7 @@ import _ "github.com/andlabs/ui/winmanifest" func (n *Node) NewLabel(text string) *Node { // make new node here - // n.Append(ui.NewLabel(text), false) - newNode := n.makeNode(text, 333, 334) +newNode := n.makeNode(text, 333, 334) newNode.Dump() n.Append(newNode) diff --git a/gui.go b/gui.go index 88554c8..6f7a236 100644 --- a/gui.go +++ b/gui.go @@ -24,6 +24,7 @@ func init() { Config.prefix = "wit" Config.DebugNode = false Config.DebugTabs = false + Config.Stretchy = true } func GuiInit() { diff --git a/new-structs.go b/new-structs.go index 5bceae2..e6b947e 100644 --- a/new-structs.go +++ b/new-structs.go @@ -242,7 +242,7 @@ func (n *Node) AddHorizontalBreak() *Node { log.Println("AddHorizontalBreak added to node =", n.Name) if (n.uiBox != nil) { tmp := ui.NewHorizontalSeparator() - n.uiBox.Append(tmp, false) + n.uiBox.Append(tmp, Config.Stretchy) } else { n.Dump() return nil @@ -254,7 +254,7 @@ func (n *Node) AddVerticalBreak() *Node { log.Println("AddVerticalBreak added to node =", n.Name) if (n.uiBox != nil) { tmp := ui.NewVerticalSeparator() - n.uiBox.Append(tmp, false) + n.uiBox.Append(tmp, Config.Stretchy) } else { n.Dump() return nil @@ -267,7 +267,7 @@ func (n *Node) AddHorizontalBox(title string) *Node { hbox.SetPadded(true) if (n.uiBox != nil) { log.Println("add new hbox to uiBox =", n.uiBox) - n.uiBox.Append(hbox, false) + n.uiBox.Append(hbox, Config.Stretchy) newNode := n.makeNode(title, 333, 333 + Config.counter) newNode.parent = n newNode.uiBox = hbox diff --git a/structs.go b/structs.go index 223ec4d..d82e621 100644 --- a/structs.go +++ b/structs.go @@ -22,6 +22,7 @@ type GuiConfig struct { Title string Width int Height int + Stretchy bool Exit func(*Node) Debug bool -- cgit v1.2.3