gocui: more dumb and broken attempts at fixing this code

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2023-04-05 17:29:52 -05:00
parent 0fb9ab6702
commit 5146cdfa80
4 changed files with 49 additions and 7 deletions

View File

@ -46,8 +46,9 @@ func (w *cuiWidget) showWidgetPlacement(b bool, s string) {
pId = w.parent.id
}
s1 = fmt.Sprintf("(wId,pId)=(%2d,%2d) ", w.id, pId)
s1 += fmt.Sprintf("real()=(%2d,%2d,%2d,%2d) ", w.gocuiSize.w0, w.gocuiSize.h0, w.gocuiSize.w1, w.gocuiSize.h1)
s1 += fmt.Sprintf("W,H()=(%2d,%2d) ", w.startW, w.startH)
s1 += fmt.Sprintf("size()=(%2d,%2d) ", w.realWidth, w.realHeight)
s1 += fmt.Sprintf("real()=(%2d,%2d,%2d,%2d) ", w.gocuiSize.w0, w.gocuiSize.h0, w.gocuiSize.w1, w.gocuiSize.h1)
switch w.widgetType {
case toolkit.Grid:

View File

@ -15,15 +15,15 @@ func (w *cuiWidget) setFake() {
// setup fake labels for non-visable things off screen
w.realWidth = t + 2
w.realHeight = me.defaultHeight
w.gocuiSize.w0 = fakeStartWidth
w.gocuiSize.h0 = fakeStartHeight
w.gocuiSize.w1 = w.gocuiSize.w0 + w.realWidth
w.gocuiSize.h1 = w.gocuiSize.h0 + w.realHeight
w.startW = fakeStartWidth
w.startH = fakeStartHeight
fakeStartHeight += 3
if (fakeStartHeight > 24) {
fakeStartHeight = 3
fakeStartWidth += 20
}
w.setWH()
w.showWidgetPlacement(logNow, "setFake()")
}
@ -193,6 +193,18 @@ func (w *cuiWidget) redoBox(draw bool) {
}
}
func (w *cuiWidget) setWH() {
w.gocuiSize.w0 = w.startW
w.gocuiSize.h0 = w.startH
w.gocuiSize.w1 = w.gocuiSize.w0 + w.realWidth
w.gocuiSize.h1 = w.gocuiSize.h0 + w.realHeight
w.logicalSize.w0 = w.gocuiSize.w0
w.logicalSize.h0 = w.gocuiSize.h0
w.logicalSize.w1 = w.gocuiSize.w1
w.logicalSize.h1 = w.gocuiSize.h1
}
func (w *cuiWidget) moveTo(leftW int, topH int) {
if (w.isFake) {
// don't ever move these

View File

@ -22,22 +22,26 @@ func (w *cuiWidget) setStartWH() {
w.id = 0
w.isFake = true
w.setFake()
w.showWidgetPlacement(logNow, "Tree:")
w.showWidgetPlacement(logNow, "StartWH:")
return
case toolkit.Flag:
w.startW = 1
w.startH = 1
w.isFake = true
w.setFake()
w.showWidgetPlacement(logNow, "Tree:")
w.showWidgetPlacement(logNow, "StartWH:")
return
case toolkit.Window:
w.startW = 1
w.startH = 3
w.setTabWH()
w.showWidgetPlacement(logNow, "StartWH:")
return
case toolkit.Tab:
w.startW = 1
w.startH = 3
w.setTabWH()
w.showWidgetPlacement(logNow, "StartWH:")
return
}
p := w.parent

View File

@ -48,6 +48,31 @@ func (w *cuiWidget) showWidgets() {
}
}
func (w *cuiWidget) setTabWH() {
t := len(w.text)
w.realWidth = t + me.buttonPadding
w.realHeight = me.defaultHeight
startW := 1
startH := 1
for _, child := range me.rootNode.children {
if (w == child) {
w.startW = startW
w.startH = startH
w.moveTo(w.startW, w.startH)
w.showWidgetPlacement(logNow, "setTabWH:")
return
}
startW += child.realWidth
}
w.startW = startW
w.startH = startH
w.setWH()
w.showWidgetPlacement(logNow, "setTabWH:")
}
func (w *cuiWidget) redoTabs(draw bool) {
if (w == nil) {
return