gocui: s/realSize/gocuiSize/

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2023-04-05 13:30:49 -05:00
parent fb43b88a0b
commit 0fb9ab6702
8 changed files with 43 additions and 62 deletions

View File

@ -13,8 +13,8 @@ import (
func (w *cuiWidget) doWidgetClick() { func (w *cuiWidget) doWidgetClick() {
switch w.widgetType { switch w.widgetType {
case toolkit.Root: case toolkit.Root:
me.rootNode.logicalSize.w1 = 1
me.rootNode.redoTabs(true) me.rootNode.redoTabs(true)
// me.rootNode.redoFake(true)
case toolkit.Flag: case toolkit.Flag:
me.rootNode.redoColor(true) me.rootNode.redoColor(true)
case toolkit.Window: case toolkit.Window:
@ -137,8 +137,8 @@ func ctrlDown(g *gocui.Gui, v *gocui.View) error {
// find buttons that are below where the mouse button click // find buttons that are below where the mouse button click
f = func(widget *cuiWidget) { f = func(widget *cuiWidget) {
// if ((widget.logicalSize.w0 < w) && (w < widget.logicalSize.w1)) { // if ((widget.logicalSize.w0 < w) && (w < widget.logicalSize.w1)) {
if ((widget.realSize.w0 <= w) && (w <= widget.realSize.w1) && if ((widget.gocuiSize.w0 <= w) && (w <= widget.gocuiSize.w1) &&
(widget.realSize.h0 <= h) && (h <= widget.realSize.h1)) { (widget.gocuiSize.h0 <= h) && (h <= widget.gocuiSize.h1)) {
widgets = append(widgets, widget) widgets = append(widgets, widget)
found = widget found = widget
} }
@ -165,10 +165,10 @@ func ctrlDown(g *gocui.Gui, v *gocui.View) error {
found = me.rootNode found = me.rootNode
} }
found.updateLogicalSizes() found.updateLogicalSizes()
me.ctrlDown.realSize.w0 = found.logicalSize.w0 me.ctrlDown.gocuiSize.w0 = found.logicalSize.w0
me.ctrlDown.realSize.w1 = found.logicalSize.w1 me.ctrlDown.gocuiSize.w1 = found.logicalSize.w1
me.ctrlDown.realSize.h0 = found.logicalSize.h0 me.ctrlDown.gocuiSize.h0 = found.logicalSize.h0
me.ctrlDown.realSize.h1 = found.logicalSize.h1 me.ctrlDown.gocuiSize.h1 = found.logicalSize.h1
if (me.ctrlDown.v == nil) { if (me.ctrlDown.v == nil) {
me.ctrlDown.text = found.text me.ctrlDown.text = found.text

View File

@ -46,7 +46,7 @@ func (w *cuiWidget) showWidgetPlacement(b bool, s string) {
pId = w.parent.id pId = w.parent.id
} }
s1 = fmt.Sprintf("(wId,pId)=(%2d,%2d) ", w.id, pId) s1 = fmt.Sprintf("(wId,pId)=(%2d,%2d) ", w.id, pId)
s1 += fmt.Sprintf("real()=(%2d,%2d,%2d,%2d) ", w.realSize.w0, w.realSize.h0, w.realSize.w1, w.realSize.h1) s1 += fmt.Sprintf("real()=(%2d,%2d,%2d,%2d) ", w.gocuiSize.w0, w.gocuiSize.h0, w.gocuiSize.w1, w.gocuiSize.h1)
s1 += fmt.Sprintf("size()=(%2d,%2d) ", w.realWidth, w.realHeight) s1 += fmt.Sprintf("size()=(%2d,%2d) ", w.realWidth, w.realHeight)
switch w.widgetType { switch w.widgetType {
@ -58,16 +58,16 @@ func (w *cuiWidget) showWidgetPlacement(b bool, s string) {
} }
log(b, s1, s, w.widgetType, ",", w.name) // , "text=", w.text) log(b, s1, s, w.widgetType, ",", w.name) // , "text=", w.text)
if (w.realWidth != (w.realSize.w1 - w.realSize.w0)) { if (w.realWidth != (w.gocuiSize.w1 - w.gocuiSize.w0)) {
log(b, "dump()", s, log(b, "dump()", s,
"badsize()=(", w.realWidth, ",", w.realHeight, ")", "badsize()=(", w.realWidth, ",", w.realHeight, ")",
"badreal()=(", w.realSize.w0, ",", w.realSize.h0, ",", w.realSize.w1, ",", w.realSize.h1, ")", "badreal()=(", w.gocuiSize.w0, ",", w.gocuiSize.h0, ",", w.gocuiSize.w1, ",", w.gocuiSize.h1, ")",
w.widgetType, ",", w.name) w.widgetType, ",", w.name)
} }
if (w.realHeight != (w.realSize.h1 - w.realSize.h0)) { if (w.realHeight != (w.gocuiSize.h1 - w.gocuiSize.h0)) {
log(b, "dump()", s, log(b, "dump()", s,
"badsize()=(", w.realWidth, ",", w.realHeight, ")", "badsize()=(", w.realWidth, ",", w.realHeight, ")",
"badreal()=(", w.realSize.w0, ",", w.realSize.h0, ",", w.realSize.w1, ",", w.realSize.h1, ")", "badreal()=(", w.gocuiSize.w0, ",", w.gocuiSize.h0, ",", w.gocuiSize.w1, ",", w.gocuiSize.h1, ")",
w.widgetType, ",", w.name) w.widgetType, ",", w.name)
} }
} }

View File

@ -9,7 +9,7 @@ import (
var logNow bool = true // useful for active development var logNow bool = true // useful for active development
var logError bool = true var logError bool = true
var logWarn bool = false var logWarn bool = false
var logInfo bool = true var logInfo bool = false
var logVerbose bool = false var logVerbose bool = false
func log(a ...any) { func log(a ...any) {

View File

@ -15,10 +15,10 @@ func (w *cuiWidget) setFake() {
// setup fake labels for non-visable things off screen // setup fake labels for non-visable things off screen
w.realWidth = t + 2 w.realWidth = t + 2
w.realHeight = me.defaultHeight w.realHeight = me.defaultHeight
w.realSize.w0 = fakeStartWidth w.gocuiSize.w0 = fakeStartWidth
w.realSize.h0 = fakeStartHeight w.gocuiSize.h0 = fakeStartHeight
w.realSize.w1 = w.realSize.w0 + w.realWidth w.gocuiSize.w1 = w.gocuiSize.w0 + w.realWidth
w.realSize.h1 = w.realSize.h0 + w.realHeight w.gocuiSize.h1 = w.gocuiSize.h0 + w.realHeight
fakeStartHeight += 3 fakeStartHeight += 3
if (fakeStartHeight > 24) { if (fakeStartHeight > 24) {
fakeStartHeight = 3 fakeStartHeight = 3
@ -51,7 +51,7 @@ func findPlace(w *cuiWidget) {
func (w *cuiWidget) getBoxWH() { func (w *cuiWidget) getBoxWH() {
p := w.parent // the parent must be a box widget p := w.parent // the parent must be a box widget
// update parent realSize // update parent gocuiSize
p.realWidth = 0 p.realWidth = 0
p.realHeight = 0 p.realHeight = 0
for _, child := range p.children { for _, child := range p.children {
@ -85,7 +85,7 @@ func (w *cuiWidget) getBoxWH() {
func (w *cuiWidget) getGroupWH() { func (w *cuiWidget) getGroupWH() {
p := w.parent // the parent must be a group widget p := w.parent // the parent must be a group widget
// update parent realSize // update parent gocuiSize
p.realWidth = 0 p.realWidth = 0
p.realHeight = 0 p.realHeight = 0
p.realHeight += me.buttonPadding // pad height for the group label p.realHeight += me.buttonPadding // pad height for the group label
@ -188,8 +188,8 @@ func (w *cuiWidget) redoBox(draw bool) {
w.showWidgetPlacement(logNow, "group:") w.showWidgetPlacement(logNow, "group:")
default: default:
w.moveTo(p.nextW, p.nextH) w.moveTo(p.nextW, p.nextH)
w.nextW = w.realSize.w1 w.nextW = w.gocuiSize.w1
w.nextH = w.realSize.h1 w.nextH = w.gocuiSize.h1
} }
} }
@ -197,16 +197,16 @@ func (w *cuiWidget) moveTo(leftW int, topH int) {
if (w.isFake) { if (w.isFake) {
// don't ever move these // don't ever move these
} else { } else {
w.realSize.w0 = leftW w.gocuiSize.w0 = leftW
w.realSize.h0 = topH w.gocuiSize.h0 = topH
} }
w.realSize.w1 = w.realSize.w0 + w.realWidth w.gocuiSize.w1 = w.gocuiSize.w0 + w.realWidth
w.realSize.h1 = w.realSize.h0 + w.realHeight w.gocuiSize.h1 = w.gocuiSize.h0 + w.realHeight
w.logicalSize.w0 = w.realSize.w0 w.logicalSize.w0 = w.gocuiSize.w0
w.logicalSize.h0 = w.realSize.h0 w.logicalSize.h0 = w.gocuiSize.h0
w.logicalSize.w1 = w.realSize.w1 w.logicalSize.w1 = w.gocuiSize.w1
w.logicalSize.h1 = w.realSize.h1 w.logicalSize.h1 = w.gocuiSize.h1
w.showWidgetPlacement(logNow, "moveTo()") w.showWidgetPlacement(logNow, "moveTo()")
} }

View File

@ -43,17 +43,9 @@ func (w *cuiWidget) setStartWH() {
p := w.parent p := w.parent
switch p.widgetType { switch p.widgetType {
case toolkit.Box: case toolkit.Box:
if (w.isFake == false) {
w.isFake = true
w.setFake()
}
w.getBoxWH() w.getBoxWH()
return return
case toolkit.Grid: case toolkit.Grid:
if (w.isFake == false) {
w.isFake = true
w.setFake()
}
w.getGridWH() w.getGridWH()
return return
case toolkit.Group: case toolkit.Group:

View File

@ -98,7 +98,7 @@ type cuiWidget struct {
realWidth int realWidth int
realHeight int realHeight int
realSize rectType // the display size of this widget gocuiSize rectType // the display size of this widget
logicalSize rectType // the logical size. Includes all the child widgets logicalSize rectType // the logical size. Includes all the child widgets
// used to track the size of grids // used to track the size of grids

View File

@ -49,21 +49,10 @@ func (w *cuiWidget) showWidgets() {
} }
func (w *cuiWidget) redoTabs(draw bool) { func (w *cuiWidget) redoTabs(draw bool) {
log(logVerbose, "redoTabs() START", w.name)
if (w == nil) { if (w == nil) {
return return
} }
if (w.widgetType == toolkit.Root) { log(logVerbose, "redoTabs() START about to check for window and tab ", w.name)
w.logicalSize.w0 = 0
w.logicalSize.h0 = 0
w.logicalSize.w1 = 0
w.logicalSize.h1 = 0
w.nextW = 1
w.nextH = 1
}
log(logVerbose, "redoTabs() about to check for window and tab ", w.name)
w.text = w.name w.text = w.name
t := len(w.text) t := len(w.text)
if ((w.widgetType == toolkit.Window) || (w.widgetType == toolkit.Tab)) { if ((w.widgetType == toolkit.Window) || (w.widgetType == toolkit.Tab)) {
@ -71,10 +60,10 @@ func (w *cuiWidget) redoTabs(draw bool) {
w.realWidth = t + me.buttonPadding w.realWidth = t + me.buttonPadding
w.realHeight = me.defaultHeight w.realHeight = me.defaultHeight
w.realSize.w0 = me.rootNode.logicalSize.w1 w.gocuiSize.w0 = me.rootNode.logicalSize.w1
w.realSize.w1 = w.realSize.w0 + w.realWidth w.gocuiSize.w1 = w.gocuiSize.w0 + w.realWidth
w.realSize.h0 = 0 w.gocuiSize.h0 = 0
w.realSize.h1 = w.realHeight w.gocuiSize.h1 = w.realHeight
// start logical sizes windows and in the top left corner // start logical sizes windows and in the top left corner
w.logicalSize.w0 = 2 w.logicalSize.w0 = 2
@ -86,8 +75,8 @@ func (w *cuiWidget) redoTabs(draw bool) {
w.nextW = w.logicalSize.w0 w.nextW = w.logicalSize.w0
w.nextH = w.logicalSize.h0 w.nextH = w.logicalSize.h0
me.rootNode.logicalSize.w1 = w.realSize.w1 me.rootNode.logicalSize.w1 = w.gocuiSize.w1
me.rootNode.logicalSize.h1 = w.realSize.h1 me.rootNode.logicalSize.h1 = w.gocuiSize.h1
w.deleteView() w.deleteView()
w.drawView() w.drawView()

View File

@ -32,8 +32,8 @@ func (w *cuiWidget) textResize() {
} }
w.realWidth = width + 3 w.realWidth = width + 3
w.realHeight = me.defaultHeight + height w.realHeight = me.defaultHeight + height
w.realSize.w1 = w.realSize.w0 + w.realWidth w.gocuiSize.w1 = w.gocuiSize.w0 + w.realWidth
w.realSize.h1 = w.realSize.h0 + w.realHeight w.gocuiSize.h1 = w.gocuiSize.h0 + w.realHeight
w.showWidgetPlacement(logNow, "textResize()") w.showWidgetPlacement(logNow, "textResize()")
} }
@ -62,10 +62,10 @@ func (w *cuiWidget) drawView() {
return return
} }
a := w.realSize.w0 a := w.gocuiSize.w0
b := w.realSize.h0 b := w.gocuiSize.h0
c := w.realSize.w1 c := w.gocuiSize.w1
d := w.realSize.h1 d := w.gocuiSize.h1
w.v, err = me.baseGui.SetView(w.cuiName, a, b, c, d, 0) w.v, err = me.baseGui.SetView(w.cuiName, a, b, c, d, 0)
if err == nil { if err == nil {