From 38a08d66fc8b49a33c749c6baeb7cd2860630c73 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Wed, 5 Feb 2025 11:08:15 -0600 Subject: [PATCH] closer --- find.go | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/find.go b/find.go index 666e11b..d423151 100644 --- a/find.go +++ b/find.go @@ -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