minor reorg

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2023-04-04 10:44:27 -05:00
parent 3a4d07fd7a
commit d6f87e2edf
2 changed files with 74 additions and 74 deletions

View File

@ -10,80 +10,6 @@ import (
"git.wit.org/wit/gui/toolkit" "git.wit.org/wit/gui/toolkit"
) )
func (w *cuiWidget) gridBounds() {
w.showWidgetPlacement(logNow, "gridBounds:")
p := w.parent
/*
for a := 0; a < w.x; a++ {
for b := 0; b < w.y; b++ {
log(logNow, "gridBounds() (w,h)", a, b,
"logical(W,H)", w.logicalW[a], w.logicalH[b],
"p.next(W,H)", p.nextW, p.nextH)
}
log("\n")
}
*/
var wCount int = 0
var hCount int = 0
for _, child := range w.children {
// increment for the next child
w.nextW = p.nextW + wCount * 20
w.nextH = p.nextH + hCount * 2
child.redoBox(true)
// set the child's realWidth, and grid offset
child.parentH = hCount
child.parentW = wCount
if (w.logicalW[wCount] < child.realWidth) {
w.logicalW[wCount] = child.realWidth
}
if (w.logicalH[hCount] < child.realHeight) {
w.logicalH[hCount] = child.realHeight
}
log(logNow, "redoBox(GRID) (w,h count)", wCount, hCount, "(X,Y)", w.x, w.y, w.name)
child.showWidgetPlacement(logNow, "grid:")
if ((wCount + 1) < w.y) {
wCount += 1
} else {
wCount = 0
hCount += 1
}
}
for _, child := range w.children {
child.showWidgetPlacement(logVerbose, "gridBounds:")
var totalW, totalH int
for i, val := range w.logicalW {
if (i < child.parentW) {
log(logVerbose, "gridBounds() (w, logicalW[])", i, val)
totalW += w.logicalW[i]
}
}
for i, h := range w.logicalH {
if (i < child.parentH) {
totalH += h
}
}
// the new corner to move the child to
realW := w.nextW + totalW
realH := w.nextH + totalH
log(logInfo, "gridBounds()", child.id, "parent (W,H) =", child.parentW, child.parentH,
"total (W,H) =", totalW, totalH,
"real (W,H) =", realW, realH)
child.moveTo(realW, realH)
child.showWidgetPlacement(logInfo, "gridBounds:")
log(logInfo)
}
w.updateLogicalSizes()
w.showWidgetPlacement(logNow, "gridBounds:")
}
func (w *cuiWidget) doWidgetClick() { func (w *cuiWidget) doWidgetClick() {
switch w.widgetType { switch w.widgetType {
case toolkit.Root: case toolkit.Root:

View File

@ -156,3 +156,77 @@ func (w *cuiWidget) updateLogicalSizes() {
} }
} }
} }
func (w *cuiWidget) gridBounds() {
w.showWidgetPlacement(logNow, "gridBounds:")
p := w.parent
/*
for a := 0; a < w.x; a++ {
for b := 0; b < w.y; b++ {
log(logNow, "gridBounds() (w,h)", a, b,
"logical(W,H)", w.logicalW[a], w.logicalH[b],
"p.next(W,H)", p.nextW, p.nextH)
}
log("\n")
}
*/
var wCount int = 0
var hCount int = 0
for _, child := range w.children {
// increment for the next child
w.nextW = p.nextW + wCount * 20
w.nextH = p.nextH + hCount * 2
child.redoBox(true)
// set the child's realWidth, and grid offset
child.parentH = hCount
child.parentW = wCount
if (w.logicalW[wCount] < child.realWidth) {
w.logicalW[wCount] = child.realWidth
}
if (w.logicalH[hCount] < child.realHeight) {
w.logicalH[hCount] = child.realHeight
}
log(logNow, "redoBox(GRID) (w,h count)", wCount, hCount, "(X,Y)", w.x, w.y, w.name)
child.showWidgetPlacement(logNow, "grid:")
if ((wCount + 1) < w.y) {
wCount += 1
} else {
wCount = 0
hCount += 1
}
}
for _, child := range w.children {
child.showWidgetPlacement(logVerbose, "gridBounds:")
var totalW, totalH int
for i, val := range w.logicalW {
if (i < child.parentW) {
log(logVerbose, "gridBounds() (w, logicalW[])", i, val)
totalW += w.logicalW[i]
}
}
for i, h := range w.logicalH {
if (i < child.parentH) {
totalH += h
}
}
// the new corner to move the child to
realW := w.nextW + totalW
realH := w.nextH + totalH
log(logInfo, "gridBounds()", child.id, "parent (W,H) =", child.parentW, child.parentH,
"total (W,H) =", totalW, totalH,
"real (W,H) =", realW, realH)
child.moveTo(realW, realH)
child.showWidgetPlacement(logInfo, "gridBounds:")
log(logInfo)
}
w.updateLogicalSizes()
w.showWidgetPlacement(logNow, "gridBounds:")
}