From 65622d01cd303f6e357d32e4ad6ab8b42755f74c Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Mon, 3 Feb 2025 15:29:44 -0600 Subject: compute window size --- find.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'find.go') diff --git a/find.go b/find.go index b8f4d4c..30344de 100644 --- a/find.go +++ b/find.go @@ -57,6 +57,36 @@ func (tk *guiWidget) findByXYreal(w int, h int) []*guiWidget { 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 func findUnderMouse() *guiWidget { w, h := me.baseGui.MousePosition() -- cgit v1.2.3