diff options
| author | Jeff Carr <[email protected]> | 2023-04-03 10:26:47 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2023-04-03 10:26:47 -0500 |
| commit | 4b6207743b90968d6b822032a4355e43b6ce6da9 (patch) | |
| tree | 2cb9f13d5e95f14e165f8e41e8484320b7454177 /toolkit/gocui/logical.go | |
| parent | 0320ebe4bb49ea80761d77af80fa208157ffdb89 (diff) | |
gocui: working towards correct layout
make a gocui widget binary tree
more debugging cleanups
sample button app displays in gocui
geometry logic closer to correct
improvements in gocui layout
continued attempts to clean up tabs
dump binary tree
moving towards proper chan callback()
deprecate Widget.Name
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'toolkit/gocui/logical.go')
| -rw-r--r-- | toolkit/gocui/logical.go | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/toolkit/gocui/logical.go b/toolkit/gocui/logical.go new file mode 100644 index 0000000..2c6081b --- /dev/null +++ b/toolkit/gocui/logical.go @@ -0,0 +1,72 @@ +package main + +import ( + // "git.wit.org/wit/gui/toolkit" +) + +var adjusted bool = false + +// expands the logical size of the parents +func (w *cuiWidget) setParentLogical(p *cuiWidget) { + if (w.visable) { + // expand the parent logicalsize to include the widget realSize + if (p.logicalSize.w0 > w.realSize.w0) { + p.logicalSize.w0 = w.realSize.w0 + adjusted = true + } + if (p.logicalSize.h0 > w.realSize.h0) { + p.logicalSize.h0 = w.realSize.h0 + adjusted = true + } + if (p.logicalSize.w1 < w.realSize.w1) { + p.logicalSize.w1 = w.realSize.w1 + adjusted = true + } + if (p.logicalSize.h1 < w.realSize.h1) { + p.logicalSize.h1 = w.realSize.h1 + adjusted = true + } + } else { + // expand the parent logicalsize to include the widget logicalsize + if (p.logicalSize.w0 > w.logicalSize.w0) { + p.logicalSize.w0 = w.logicalSize.w0 + adjusted = true + } + if (p.logicalSize.h0 > w.logicalSize.h0) { + p.logicalSize.h0 = w.logicalSize.h0 + adjusted = true + } + if (p.logicalSize.w1 < w.logicalSize.w1) { + p.logicalSize.w1 = w.logicalSize.w1 + adjusted = true + } + if (p.logicalSize.h1 < w.logicalSize.h1) { + p.logicalSize.h1 = w.logicalSize.h1 + adjusted = true + } + } + if (w.visable) { + // adjust the widget realSize to the top left corner of the logicalsize + if (w.logicalSize.w0 > w.realSize.w0) { + w.realSize.w0 = w.logicalSize.w0 + w.realSize.w1 = w.realSize.w0 + w.realWidth + adjusted = true + } + if (w.logicalSize.h0 > w.realSize.h0) { + w.realSize.h0 = w.logicalSize.h0 + w.realSize.h1 = w.realSize.h0 + w.realHeight + adjusted = true + } + } + w.showWidgetPlacement(logNow, "setParentLogical() widget") + p.showWidgetPlacement(logNow, "setParentLogical() parent") + if (w.id == 0) || (p.id == 0) { + // stop resizing when you hit the root widget + return + } + // pass the logical resizing up + pP := w.parent + if (pP != nil) { + p.setParentLogical(pP) + } +} |
