compute window size

This commit is contained in:
Jeff Carr 2025-02-03 15:29:44 -06:00
parent d61e03b877
commit 65622d01cd
2 changed files with 32 additions and 3 deletions

View File

@ -42,9 +42,8 @@ func (tk *guiWidget) dumpWidget(s string) {
tk.gocuiSize.w0, tk.gocuiSize.h0, tk.gocuiSize.w1, tk.gocuiSize.h1) tk.gocuiSize.w0, tk.gocuiSize.h0, tk.gocuiSize.w1, tk.gocuiSize.h1)
// vx0, vy0, vx1, vy1, _ := me.baseGui.ViewPosition("msg") // vx0, vy0, vx1, vy1, _ := me.baseGui.ViewPosition("msg")
// vw0, vh0, vw1, vh1, _ := me.baseGui.ViewPosition(tk.v.Name()) // vw0, vh0, vw1, vh1, _ := me.baseGui.ViewPosition(tk.v.Name())
vw0, vh0, vw1, vh1, _ := me.baseGui.ViewPosition(tk.v.Name()) r := tk.getFullSize()
s1 += fmt.Sprintf(" real=(%3d,%3d,%3d,%3d)", s1 += fmt.Sprintf(" full=(%3d,%3d,%3d,%3d)", r.w0, r.h0, r.w1, r.h1)
vw0, vh0, vw1, vh1)
} else { } else {
s1 += fmt.Sprintf(" %3s %3s %3s %3s ", "", "", "", "") s1 += fmt.Sprintf(" %3s %3s %3s %3s ", "", "", "", "")
s1 += fmt.Sprintf(" %3s %3s %3s %3s ", "", "", "", "") s1 += fmt.Sprintf(" %3s %3s %3s %3s ", "", "", "", "")

30
find.go
View File

@ -57,6 +57,36 @@ func (tk *guiWidget) findByXYreal(w int, h int) []*guiWidget {
return widgets return widgets
} }
// this checks a widget to see if it is under (W,H), then checks the widget's children
// anything that matches is passed back as an array of widgets
func (tk *guiWidget) getFullSize() rectType {
var r rectType
r.w0 = tk.gocuiSize.w0
r.w1 = tk.gocuiSize.w1
r.h0 = tk.gocuiSize.h0
r.h1 = tk.gocuiSize.h1
// search through the children widgets in the binary tree
for _, child := range tk.children {
cr := child.getFullSize()
if r.w0 > cr.w0 {
r.w0 = cr.w0
}
if r.h0 > cr.h0 {
r.h0 = cr.h0
}
if r.w1 < cr.w1 {
r.w1 = cr.w1
}
if r.h1 < cr.h1 {
r.h1 = cr.h1
}
}
return r
}
// returns the "highest priority widget under the mouse // returns the "highest priority widget under the mouse
func findUnderMouse() *guiWidget { func findUnderMouse() *guiWidget {
w, h := me.baseGui.MousePosition() w, h := me.baseGui.MousePosition()