From 1d7b9613a68abdd41ad1cf0b6803b0ab6593e813 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sun, 28 Jan 2024 20:36:59 -0600 Subject: [PATCH] sizes are close to correct Signed-off-by: Jeff Carr --- click.go | 4 +--- debug.go | 6 +++--- place.go | 16 ++++++++-------- size.go | 12 ++++++------ structs.go | 4 ++-- 5 files changed, 20 insertions(+), 22 deletions(-) diff --git a/click.go b/click.go index d2dc21e..cf5790b 100644 --- a/click.go +++ b/click.go @@ -172,9 +172,7 @@ func (w *guiWidget) doWidgetClick() { w.dumpTree("click start") if w.active { w.active = false - startW := w.parent.AtW - startH := w.parent.AtH - w.placeWidgets(startW, startH) + w.placeWidgets(w.startW, w.startH) w.showWidgets() /* for _, child := range w.children { diff --git a/debug.go b/debug.go index 71e6958..f9a5b4c 100644 --- a/debug.go +++ b/debug.go @@ -32,15 +32,15 @@ func (w *guiWidget) showWidgetPlacement(s string) { s1 = fmt.Sprintf("(wId,pId)=(%2d,%2d) ", w.node.WidgetId, pId) if w.Visible() { sizeW, sizeH := w.Size() - s1 += fmt.Sprintf("gocui=(%2d,%2d)(%2d,%2d,%2d,%2d)", - sizeW, sizeH, + s1 += fmt.Sprintf("size=(%2d,%2d)", sizeW, sizeH) + s1 += fmt.Sprintf("gocui=(%2d,%2d,%2d,%2d)", w.gocuiSize.w0, w.gocuiSize.h0, w.gocuiSize.w1, w.gocuiSize.h1) } else { s1 += fmt.Sprintf(" w.Visable() == false ") } if w.node.Parent != nil { if w.node.Parent.WidgetType == widget.Grid { - s1 += fmt.Sprintf("At(%2d,%2d) ", w.AtW, w.AtH) + s1 += fmt.Sprintf("At(%2d,%2d) ", w.node.State.AtW, w.node.State.AtH) } } tmp := "." + w.String() + "." diff --git a/place.go b/place.go index 0caf227..bd602f7 100644 --- a/place.go +++ b/place.go @@ -122,14 +122,14 @@ func (w *guiWidget) placeGrid(startW int, startH int) (int, int) { childW, childH := child.placeWidgets(child.startW, child.startH) // set the child's realWidth, and grid offset - if w.widths[child.AtW] < childW { - w.widths[child.AtW] = childW + if w.widths[child.node.State.AtW] < childW { + w.widths[child.node.State.AtW] = childW } - if w.heights[child.AtH] < childH { - w.heights[child.AtH] = childH + if w.heights[child.node.State.AtH] < childH { + w.heights[child.node.State.AtH] = childH } // child.showWidgetPlacement("grid: ") - log.Log(INFO, "placeGrid:", child.String(), "child()", childW, childH, "At()", child.AtW, child.AtH) + log.Log(INFO, "placeGrid:", child.String(), "child()", childW, childH, "At()", child.node.State.AtW, child.node.State.AtH) } var maxW int = 0 @@ -141,12 +141,12 @@ func (w *guiWidget) placeGrid(startW int, startH int) (int, int) { var totalW, totalH int for i, w := range w.widths { - if i < child.AtW { + if i < child.node.State.AtW { totalW += w } } for i, h := range w.heights { - if i < child.AtH { + if i < child.node.State.AtH { totalH += h } } @@ -162,7 +162,7 @@ func (w *guiWidget) placeGrid(startW int, startH int) (int, int) { maxH = totalH } - log.Log(INFO, "placeGrid:", child.String(), "new()", newW, newH, "At()", child.AtW, child.AtH) + log.Log(INFO, "placeGrid:", child.String(), "new()", newW, newH, "At()", child.node.State.AtW, child.node.State.AtH) child.placeWidgets(newW, newH) child.showWidgetPlacement("grid2:") } diff --git a/size.go b/size.go index ed73cb9..20d4ed8 100644 --- a/size.go +++ b/size.go @@ -58,11 +58,11 @@ func (w *guiWidget) sizeGrid() (int, int) { sizeW, sizeH := child.Size() // set the child's realWidth, and grid offset - if w.widths[child.AtW] < sizeW { - w.widths[child.AtW] = sizeW + if w.widths[child.node.State.AtW] < sizeW { + w.widths[child.node.State.AtW] = sizeW } - if w.heights[child.AtH] < sizeH { - w.heights[child.AtH] = sizeH + if w.heights[child.node.State.AtH] < sizeH { + w.heights[child.node.State.AtH] = sizeH } } @@ -73,12 +73,12 @@ func (w *guiWidget) sizeGrid() (int, int) { for _, child := range w.children { var totalW, totalH int for i, w := range w.widths { - if i < child.AtW { + if i < child.node.State.AtW { totalW += w } } for i, h := range w.heights { - if i < child.AtH { + if i < child.node.State.AtH { totalH += h } } diff --git a/structs.go b/structs.go index a7372bb..0eb96e7 100644 --- a/structs.go +++ b/structs.go @@ -145,8 +145,8 @@ type guiWidget struct { active bool - AtW int - AtH int +// AtW int +// AtH int direction widget.Orientation