diff options
| author | Jeff Carr <[email protected]> | 2023-12-02 19:02:51 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2023-12-02 19:02:51 -0600 |
| commit | 7880d9df6de1040258bea966f040e12be6205af1 (patch) | |
| tree | bb0f3d74eb4e3b5094bfe78e936679efb940cacf /toolkit/gocui/debug.go | |
| parent | 19e6ea76f3c09fe3a5d9a4d4caff7d14571f4ba5 (diff) | |
gocui plugin refactor to a *node binary tree
rename arg '--gui <toolkit>'
add a cloudflare example
fixes since go v1.21 didn't compile anymore due to argv order
more place() changes
recursive size computation
gocui: Major refactor to use the *node binary tree
gocui: refactor place() and size()
gocui: better place() and spacing (tab, buttons, etc)
gocui: better mouse click handling
gocui: switch to using tk.gocuiSize & tk.size
gocui: event handling cleanups
gocui: add window labels work
gocui: struct cleanups
gocui: duplicate binary tree structs removed
gocui: deprecate old children
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'toolkit/gocui/debug.go')
| -rw-r--r-- | toolkit/gocui/debug.go | 69 |
1 files changed, 52 insertions, 17 deletions
diff --git a/toolkit/gocui/debug.go b/toolkit/gocui/debug.go index e3f3586..3ea31b0 100644 --- a/toolkit/gocui/debug.go +++ b/toolkit/gocui/debug.go @@ -2,37 +2,72 @@ package main import ( "fmt" + "git.wit.org/wit/gui/toolkit" ) -func (w *cuiWidget) dumpTree(draw bool) { +func (n *node) dumpTree(draw bool) { + w := n.tk if (w == nil) { return } - w.showWidgetPlacement(logNow, "Tree:") + n.showWidgetPlacement(logNow, "Tree:") - for _, child := range w.children { + for _, child := range n.children { child.dumpTree(draw) } } -func (w *cuiWidget) showWidgetPlacement(b bool, s string) { - var s1 string - var pId int - if (w == nil) { +func (n *node) showWidgetPlacement(b bool, s string) { + if (n == nil) { log(logError, "WTF w == nil") return } - if (w.parent == nil) { - log(logVerbose, "showWidgetPlacement() parent == nil", w.id, w.cuiName) + w := n.tk + + var s1 string + var pId int + if (n.parent == nil) { + log(logVerbose, "showWidgetPlacement() parent == nil", n.WidgetId, w.cuiName) pId = 0 } else { - pId = w.parent.id + pId = n.parent.WidgetId + } + s1 = fmt.Sprintf("(wId,pId)=(%2d,%2d) ", n.WidgetId, pId) + s1 += fmt.Sprintf("size=(%2d,%2d)(%2d,%2d,%2d,%2d)", + w.size.Width(), w.size.Height(), + w.size.w0, w.size.h0, w.size.w1, w.size.h1) + if n.Visible() { + s1 += fmt.Sprintf("gocui=(%2d,%2d)(%2d,%2d,%2d,%2d)", + w.gocuiSize.Width(), w.gocuiSize.Height(), + w.gocuiSize.w0, w.gocuiSize.h0, w.gocuiSize.w1, w.gocuiSize.h1) + } + if (n.parent != nil) { + if (n.parent.WidgetType == toolkit.Grid) { + s1 += fmt.Sprintf("At(%2d,%2d) ", n.AtW, n.AtH) + } + } + log(b, s1, s, n.WidgetType, ",", n.Name) // , "text=", w.text) +} + +func (n *node) dumpWidget(pad string) { + log(true, "node:", pad, n.WidgetId, "At(", n.AtW, n.AtH, ") ,", n.WidgetType, ",", n.Name) +} + +func (n *node) listWidgets() { + if (n == nil) { + return + } + + var pad string + for i := 0; i < me.depth; i++ { + pad = pad + " " + } + n.dumpWidget(pad) + + for _, child := range n.children { + me.depth += 1 + child.listWidgets() + me.depth -= 1 } - s1 = fmt.Sprintf("(wId,pId)=(%2d,%2d) ", w.id, pId) - s1 += fmt.Sprintf("s/n (%2d,%2d) (%2d,%2d) ", w.startW, w.startH, w.nextW, w.nextH) - s1 += fmt.Sprintf("size (%2d,%2d) ", w.realWidth, w.realHeight) - s1 += fmt.Sprintf("gocui=(%2d,%2d)(%2d,%2d,%2d,%2d)", - w.gocuiSize.Width(), w.gocuiSize.Height(), - w.gocuiSize.w0, w.gocuiSize.h0, w.gocuiSize.w1, w.gocuiSize.h1) - log(b, s1, s, w.widgetType, ",", w.name) // , "text=", w.text) + return } |
