summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2023-04-05 17:29:52 -0500
committerJeff Carr <[email protected]>2023-04-05 17:29:52 -0500
commit9c5eda73fa47dfd156c7de3292169150af2f46a8 (patch)
tree7b83a644451570c037401d55c425e5c2af50e560
parent89bff61cb1373035f7a20b05dd975f8dfbbb767a (diff)
gocui: more dumb and broken attempts at fixing this code
Signed-off-by: Jeff Carr <[email protected]>
-rw-r--r--toolkit/gocui/debug.go3
-rw-r--r--toolkit/gocui/place.go20
-rw-r--r--toolkit/gocui/plugin.go8
-rw-r--r--toolkit/gocui/tab.go25
4 files changed, 49 insertions, 7 deletions
diff --git a/toolkit/gocui/debug.go b/toolkit/gocui/debug.go
index aa12281..421b84c 100644
--- a/toolkit/gocui/debug.go
+++ b/toolkit/gocui/debug.go
@@ -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:
diff --git a/toolkit/gocui/place.go b/toolkit/gocui/place.go
index 5747284..bee9063 100644
--- a/toolkit/gocui/place.go
+++ b/toolkit/gocui/place.go
@@ -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
diff --git a/toolkit/gocui/plugin.go b/toolkit/gocui/plugin.go
index f1b6751..c41b558 100644
--- a/toolkit/gocui/plugin.go
+++ b/toolkit/gocui/plugin.go
@@ -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
diff --git a/toolkit/gocui/tab.go b/toolkit/gocui/tab.go
index 455be35..49cd105 100644
--- a/toolkit/gocui/tab.go
+++ b/toolkit/gocui/tab.go
@@ -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