This commit is contained in:
Jeff Carr 2025-02-05 11:08:15 -06:00
parent fb8d1d0940
commit 38a08d66fc
1 changed files with 40 additions and 0 deletions

40
find.go
View File

@ -105,11 +105,51 @@ func (tk *guiWidget) setFullSize() bool {
return changed
}
func (tk *guiWidget) gridFullSize() rectType {
var r rectType
var first bool = true
for _, child := range tk.children {
cr := child.getFullSize()
if cr.Width() == 0 && cr.Height() == 0 {
// ignore widgets of zero size?
continue
}
if first {
// use the lowest width and hight from children widgets
r.w0 = cr.w0
r.h0 = cr.h0
r.w1 = cr.w1
r.h1 = cr.h1
first = false
continue
}
// use the lowest width and hight from children widgets
if r.w0 > cr.w0 {
r.w0 = cr.w0
}
if r.h0 > cr.h0 {
r.h0 = cr.h0
}
// use the highest width and hight from children widgets
if r.w1 < cr.w1 {
r.w1 = cr.w1
}
if r.h1 < cr.h1 {
r.h1 = cr.h1
}
}
return r
}
// 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
if tk.node.WidgetType == widget.Grid {
return tk.gridFullSize()
}
if tk.v == nil {
r.w0 = tk.full.w0
r.w1 = tk.full.w1