From e55fb6675d692e3f44fa67b02b12661e476bd028 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sun, 6 Nov 2022 12:59:24 -0600 Subject: start trying to make the tookits plugins totally minimize helloworld demo try to make a button plugin example debug changes final changes before attempting to use a golang plugin actually running gocui as a plugin add gocli-as-plugin example try to convert the go-cui toolkit into a plugin doc updates make a minimal console gui Signed-off-by: Jeff Carr --- structs.go | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) (limited to 'structs.go') diff --git a/structs.go b/structs.go index e72e28a..2a0493e 100644 --- a/structs.go +++ b/structs.go @@ -21,7 +21,15 @@ import toolkit "git.wit.org/wit/gui/toolkit/andlabs" var Config GuiConfig -func SetDebugToolkit (s bool) { +func GetDebug () bool { + return Config.Options.Debug +} + +func SetDebug (s bool) { + Config.Options.Debug = s + // also set these + Config.Options.DebugDump = s + Config.Options.DebugNode = s toolkit.DebugToolkit = s } @@ -29,6 +37,10 @@ func GetDebugToolkit () bool { return toolkit.DebugToolkit } +func SetDebugToolkit (s bool) { + toolkit.DebugToolkit = s +} + func ShowDebugValues() { log.Println("\t wit/gui Debug =", Config.Options.Debug) log.Println("\t wit/gui DebugDump =", Config.Options.DebugDump) @@ -102,23 +114,27 @@ func (s Widget) String() string { // The Node is simply the name and the size of whatever GUI element exists type Node struct { - id string + id int Name string Width int Height int + // this function is run when there are mouse or keyboard events + OnChanged func(*Node) + parent *Node - // TODO: make children a double linked list since some toolkits require order + // TODO: make children a double linked list since some toolkits require order (?) children []*Node + // hmm. how do you handle this when the toolkits are plugins? + toolkit *toolkit.Toolkit + // things that may not really be needed (?) custom func() - OnChanged func(*Node) checked bool text string - toolkit *toolkit.Toolkit } func (n *Node) Parent() *Node { @@ -159,12 +175,12 @@ func (n *Node) Dump() { 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") - } +// if (n.id == nil) { +// // 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") } -- cgit v1.2.3