From 4fa1dd75b04aad0a85d171a1d333d799a61ba713 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sun, 28 Jan 2024 21:15:15 -0600 Subject: sizes are getting better Signed-off-by: Jeff Carr --- place.go | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) (limited to 'place.go') diff --git a/place.go b/place.go index bd602f7..48d7b3a 100644 --- a/place.go +++ b/place.go @@ -8,43 +8,32 @@ import ( "go.wit.com/widget" ) -func (tk *guiWidget) placeBox(startW int, startH int) (int, int) { +func (tk *guiWidget) placeBox(startW int, startH int) { if tk.WidgetType != widget.Box { - return 0, 0 + return } tk.dumpTree("beforebox") newW := startW newH := startH - var maxW int = 0 - var maxH int = 0 for _, child := range tk.children { - sizeW, sizeH := child.placeWidgets(newW, newH) + sizeW, sizeH := child.Size() + log.Log(NOW, "BOX START size(W,H) =", sizeW, sizeH, "new(W,H) =", newW, newH) + child.placeWidgets(newW, newH) + sizeW, sizeH = child.Size() if child.direction == widget.Horizontal { log.Log(NOW, "BOX IS HORIZONTAL", tk.String(), "newWH()", newW, newH, "child()", sizeW, sizeH, child.String()) // expand based on the child width newW += sizeW - maxW += sizeW - if sizeH > maxH { - maxH = sizeH - } } else { log.Log(NOW, "BOX IS VERTICAL ", tk.String(), "newWH()", newW, newH, "child()", sizeW, sizeH, child.String()) // expand based on the child height newH += sizeH - maxH += sizeH - if sizeW > maxW { - maxW = sizeW - } } + log.Log(NOW, "BOX END size(W,H) =", sizeW, sizeH, "new(W,H) =", newW, newH) } - - // just compute this every time? - // newR := n.realGocuiSize() - tk.dumpTree("afterbox") - return maxW, maxH } func (tk *guiWidget) placeWidgets(startW int, startH int) (int, int) { @@ -64,7 +53,8 @@ func (tk *guiWidget) placeWidgets(startW int, startH int) (int, int) { newH := startH var maxH int = 0 for _, child := range tk.children { - sizeW, sizeH := child.placeWidgets(newW, newH) + child.placeWidgets(newW, newH) + sizeW, sizeH := child.Size() if sizeW < 20 { sizeW = 20 } @@ -79,7 +69,8 @@ func (tk *guiWidget) placeWidgets(startW int, startH int) (int, int) { case widget.Grid: return tk.placeGrid(startW, startH) case widget.Box: - return tk.placeBox(startW, startH) + tk.placeBox(startW, startH) + return 0, 0 case widget.Group: // move the group to the parent's next location tk.gocuiSetWH(startW, startH) -- cgit v1.2.3