sizes are close to correct

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-01-28 20:36:59 -06:00
parent 3029f04bd2
commit 1d7b9613a6
5 changed files with 20 additions and 22 deletions

View File

@ -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 {

View File

@ -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() + "."

View File

@ -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:")
}

12
size.go
View File

@ -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
}
}

View File

@ -145,8 +145,8 @@ type guiWidget struct {
active bool
AtW int
AtH int
// AtW int
// AtH int
direction widget.Orientation