From a3fc02c2f7e22f92b76ff6db92618be0cf3656a6 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Fri, 21 Oct 2022 11:40:08 -0500 Subject: v0.4.1 set sane toolkit default look and feel autogenerate README.md from doc.go (goreadme cmd) remove passing arguements on a mouse click() make defaults for padding, margin, stretchy, etc add a checkbox widget function rename to NewButton() keep cleaning up toolkit code fix date. I was somehow in the future Signed-off-by: Jeff Carr --- structs.go | 46 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 8 deletions(-) (limited to 'structs.go') diff --git a/structs.go b/structs.go index d9b5bef..4b4fa33 100644 --- a/structs.go +++ b/structs.go @@ -2,7 +2,7 @@ package gui import ( "log" - + "reflect" ) import toolkit "git.wit.org/wit/gui/toolkit/andlabs" @@ -21,6 +21,25 @@ import toolkit "git.wit.org/wit/gui/toolkit/andlabs" var Config GuiConfig +func SetDebugToolkit (s bool) { + toolkit.DebugToolkit = s +} + +func GetDebugToolkit () bool { + return toolkit.DebugToolkit +} + +func ShowDebugValues() { + log.Println("\t wit/gui Debug =", Config.Debug) + log.Println("\t wit/gui DebugDump =", Config.DebugDump) + log.Println("\t wit/gui DebugNode =", Config.DebugNode) + log.Println("\t wit/gui DebugTabs =", Config.DebugTabs) + log.Println("\t wit/gui DebugTable =", Config.DebugTable) + log.Println("\t wit/gui DebugWindow =", Config.DebugWindow) + log.Println("\t wit/gui DebugWindow =", Config.DebugWindow) + log.Println("\t wit/gui DebugToolkit =", toolkit.DebugToolkit) +} + type GuiConfig struct { // This is the master node. The Binary Tree starts here master *Node @@ -34,11 +53,11 @@ type GuiConfig struct { // These are global debugging settings // TODO: move to a standard logging system Debug bool + DebugDump bool DebugNode bool DebugTabs bool DebugTable bool DebugWindow bool - DebugToolkit bool // hacks depth int @@ -84,10 +103,14 @@ type Node struct { Height int parent *Node + // TODO: make children a double linked list since some toolkits require order children []*Node - custom func(*Node) + // things that may not really be needed (?) + custom func() OnChanged func(*Node) + checked bool + text string toolkit *toolkit.Toolkit } @@ -101,6 +124,10 @@ func (n *Node) Window() *Node { } func (n *Node) Dump() { + if ! Config.DebugDump { + return + } + IndentPrintln("NODE DUMP START") IndentPrintln("id = ", n.id) IndentPrintln("Name = ", n.Name) IndentPrintln("Width = ", n.Width) @@ -109,27 +136,30 @@ func (n *Node) Dump() { if (n.parent == nil) { IndentPrintln("parent = nil") } else { - IndentPrintln("parent =", n.parent.id) + IndentPrintln("parent.id =", n.parent.id) } if (n.children != nil) { IndentPrintln("children = ", n.children) } - if (n.toolkit != nil) { - IndentPrintln("toolkit = ", n.toolkit) - n.toolkit.Dump() - } if (n.custom != nil) { IndentPrintln("custom = ", n.custom) } + IndentPrintln("checked = ", n.checked) if (n.OnChanged != nil) { IndentPrintln("OnChanged = ", n.OnChanged) } + IndentPrintln("text = ", reflect.ValueOf(n.text).Kind(), n.text) + if (n.toolkit != nil) { + IndentPrintln("toolkit = ", reflect.ValueOf(n.toolkit).Kind()) + n.toolkit.Dump() + } if (n.id == "") { // Node structs should never have a nil id. // I probably shouldn't panic here, but this is just to check the sanity of // the gui package to make sure it's not exiting panic("gui.Node.Dump() id == nil TODO: make a unigue id here in the golang gui library") } + IndentPrintln("NODE DUMP END") } func (n *Node) SetName(name string) { -- cgit v1.2.3