gocui/debug.go

72 lines
2.0 KiB
Go
Raw Normal View History

2025-02-01 11:42:31 -06:00
// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
// Use of this source code is governed by the GPL 3.0
package main
import (
"fmt"
"go.wit.com/log"
"go.wit.com/widget"
)
func (w *guiWidget) dumpTree(s string) {
// log.Log(ERROR, "dump w", w.node.WidgetId, w.WidgetType, w.String())
if w == nil {
log.Log(ERROR, "dump w.TK == nil", w.node.WidgetId, w.node.WidgetType, w.String())
return
}
w.dumpWidget("dumpTree() " + s)
for _, child := range w.children {
child.dumpTree(s)
}
}
// a standard function to print out information about a widget
2025-02-03 10:55:50 -06:00
func (tk *guiWidget) dumpWidget(s string) {
var s1 string
var pId int
2025-02-03 10:55:50 -06:00
tk.verifyRect()
if tk.node.Parent == nil {
log.Log(INFO, "showWidgetPlacement() parent == nil", tk.node.WidgetId, tk.cuiName)
pId = 0
} else {
2025-02-03 10:55:50 -06:00
pId = tk.node.Parent.WidgetId
}
2025-02-03 10:55:50 -06:00
s1 = fmt.Sprintf("(wId,pId)=(%4d,%4d) ", tk.node.WidgetId, pId)
sizeW, sizeH := tk.Size()
s1 += fmt.Sprintf("size=(%3d,%3d)", sizeW, sizeH)
2025-02-03 10:55:50 -06:00
if tk.Visible() {
2025-02-04 09:52:46 -06:00
r := tk.getFullSize()
s1 += fmt.Sprintf("gocui=(%3d,%3d,%3d,%3d)",
2025-02-03 10:55:50 -06:00
tk.gocuiSize.w0, tk.gocuiSize.h0, tk.gocuiSize.w1, tk.gocuiSize.h1)
2025-02-02 23:36:33 -06:00
// vx0, vy0, vx1, vy1, _ := me.baseGui.ViewPosition("msg")
2025-02-03 10:55:50 -06:00
// vw0, vh0, vw1, vh1, _ := me.baseGui.ViewPosition(tk.v.Name())
2025-02-03 15:29:44 -06:00
s1 += fmt.Sprintf(" full=(%3d,%3d,%3d,%3d)", r.w0, r.h0, r.w1, r.h1)
} else {
s1 += fmt.Sprintf(" %3s %3s %3s %3s ", "", "", "", "")
2025-02-02 23:36:33 -06:00
s1 += fmt.Sprintf(" %3s %3s %3s %3s ", "", "", "", "")
}
2025-02-03 10:55:50 -06:00
if tk.node.Parent != nil {
if tk.node.Parent.WidgetType == widget.Grid {
s1 += fmt.Sprintf("At(%3d,%3d) ", tk.node.State.AtW, tk.node.State.AtH)
2025-01-29 07:55:56 -06:00
} else {
s1 += fmt.Sprintf(" %3s %3s ", "", "")
}
2025-01-29 07:55:56 -06:00
} else {
s1 += fmt.Sprintf(" %3s %3s ", "", "")
}
var end string
2025-02-03 10:55:50 -06:00
if tk.node.WidgetType == widget.Box {
end = fmt.Sprintf("%5s %-8s %s", tk.cuiName, tk.node.WidgetType, tk.node.State.Direction.String())
} else {
2025-02-03 10:55:50 -06:00
curval := tk.String()
if curval == "" {
2025-02-03 10:55:50 -06:00
curval = tk.node.GetLabel()
}
2025-02-03 10:55:50 -06:00
end = fmt.Sprintf("%5s %-8s %s", tk.cuiName, tk.node.WidgetType, tk.String())
}
log.Log(NOW, s1, s, end)
}