summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--debug.go8
-rw-r--r--eventBindings.go4
-rw-r--r--eventMouseMove.go2
-rw-r--r--find.go46
-rw-r--r--place.go14
-rw-r--r--window.go16
6 files changed, 52 insertions, 38 deletions
diff --git a/debug.go b/debug.go
index 34cf85f..86c71a4 100644
--- a/debug.go
+++ b/debug.go
@@ -27,7 +27,7 @@ func (w *guiWidget) dumpTree(s string) {
func (tk *guiWidget) dumpWidget(s string) {
var s1 string
var pId int
- tk.verifyRect()
+ // tk.verifyRect()
if tk.node.Parent == nil {
log.Log(INFO, "showWidgetPlacement() parent == nil", tk.node.WidgetId, tk.cuiName)
pId = 0
@@ -38,16 +38,12 @@ func (tk *guiWidget) dumpWidget(s string) {
sizeW, sizeH := tk.Size()
s1 += fmt.Sprintf("size=(%3d,%3d)", sizeW, sizeH)
if tk.Visible() {
- r := tk.getFullSize()
s1 += fmt.Sprintf("gocui=(%3d,%3d,%3d,%3d)",
tk.gocuiSize.w0, tk.gocuiSize.h0, tk.gocuiSize.w1, tk.gocuiSize.h1)
- // vx0, vy0, vx1, vy1, _ := me.baseGui.ViewPosition("msg")
- // vw0, vh0, vw1, vh1, _ := me.baseGui.ViewPosition(tk.v.Name())
- s1 += fmt.Sprintf(" full=(%3d,%3d,%3d,%3d)", r.w0, r.h0, r.w1, r.h1)
} else {
s1 += fmt.Sprintf(" %3s %3s %3s %3s ", "", "", "", "")
- s1 += fmt.Sprintf(" %3s %3s %3s %3s ", "", "", "", "")
}
+ s1 += fmt.Sprintf(" full=(%3d,%3d,%3d,%3d)", tk.full.w0, tk.full.h0, tk.full.w1, tk.full.h1)
if tk.node.Parent != nil {
if tk.node.Parent.WidgetType == widget.Grid {
s1 += fmt.Sprintf("At(%3d,%3d) ", tk.node.State.AtW, tk.node.State.AtH)
diff --git a/eventBindings.go b/eventBindings.go
index fc4b708..4e4072f 100644
--- a/eventBindings.go
+++ b/eventBindings.go
@@ -63,6 +63,7 @@ func setSuperMouse(g *gocui.Gui, v *gocui.View) error {
var wtf bool
+/*
func (tk *guiWidget) verifyRect() bool {
if !tk.Visible() {
// log.Info("verifyRect() tk is not visible", tk.cuiName)
@@ -106,6 +107,7 @@ func (tk *guiWidget) verifyRect() bool {
// log.Printf("verifyRect() OK cuiName=%s v.Name=%s", tk.cuiName, tk.v.Name())
return true
}
+*/
func (tk *guiWidget) makeTK(ddItems []string) {
items := strings.Join(ddItems, "\n")
@@ -230,7 +232,7 @@ func theFind(g *gocui.Gui, v *gocui.View) error {
for _, tk := range findByXY(w, h) {
// tk.v.BgColor = gocui.ColorGreen
tk.dumpWidget("theFind()")
- tk.verifyRect()
+ // tk.verifyRect()
}
return nil
}
diff --git a/eventMouseMove.go b/eventMouseMove.go
index e410f1d..12ab1cb 100644
--- a/eventMouseMove.go
+++ b/eventMouseMove.go
@@ -100,7 +100,7 @@ func (tk *guiWidget) moveNew() {
}
if tk.node.WidgetType == widget.Flag {
me.baseGui.SetView(tk.cuiName, w-3, h-3, w+20, h+20, 0)
- tk.verifyRect()
+ // tk.verifyRect()
s := fmt.Sprintf("move(%dx%d) %s ###", w, h, tk.cuiName)
tk.dumpWidget(s)
return
diff --git a/find.go b/find.go
index 9191b06..666e11b 100644
--- a/find.go
+++ b/find.go
@@ -4,8 +4,9 @@
package main
import (
+ "fmt"
+
"github.com/awesome-gocui/gocui"
- log "go.wit.com/log"
"go.wit.com/widget"
)
@@ -48,7 +49,7 @@ func (tk *guiWidget) findByXYreal(w int, h int) []*guiWidget {
// log.Log(GOCUI, "findByXY() found", widget.node.WidgetType, w, h)
}
}
- tk.verifyRect()
+ // tk.verifyRect()
// search through the children widgets in the binary tree
for _, child := range tk.children {
@@ -78,7 +79,7 @@ func (tk *guiWidget) findWindows() []*guiWidget {
return found
}
-func (tk *guiWidget) setFullSize() rectType {
+func (tk *guiWidget) setFullSize() bool {
r := tk.getFullSize()
var changed bool
@@ -99,15 +100,9 @@ func (tk *guiWidget) setFullSize() rectType {
changed = true
}
if changed {
- if tk.node.WidgetType == widget.Window {
- log.Info("REDRAW WINDOW IN setFullSize()")
- tk.full.w1 = r.w1 + 2
- tk.full.h1 = r.h1 + 1
- tk.Hide()
- tk.drawView()
- }
+ tk.dumpWidget(fmt.Sprintf("setFullSize(changed)"))
}
- return r
+ return changed
}
// this checks a widget to see if it is under (W,H), then checks the widget's children
@@ -115,28 +110,49 @@ func (tk *guiWidget) setFullSize() rectType {
func (tk *guiWidget) getFullSize() rectType {
var r rectType
- r.w0 = tk.gocuiSize.w0
- r.w1 = tk.gocuiSize.w1
- r.h0 = tk.gocuiSize.h0
- r.h1 = tk.gocuiSize.h1
+ if tk.v == nil {
+ r.w0 = tk.full.w0
+ r.w1 = tk.full.w1
+ r.h0 = tk.full.h0
+ r.h1 = tk.full.h1
+ } else {
+ r.w0 = tk.gocuiSize.w0
+ r.w1 = tk.gocuiSize.w1
+ r.h0 = tk.gocuiSize.h0
+ r.h1 = tk.gocuiSize.h1
+ }
// search through the children widgets in the binary tree
for _, child := range tk.children {
cr := child.getFullSize()
+ /* this didn't make things work either
+ if child.v == nil {
+ continue
+ }
+ */
+ // use the lowest width and hight from children widgets
if r.w0 > cr.w0 {
r.w0 = cr.w0
}
if r.h0 > cr.h0 {
r.h0 = cr.h0
}
+ // use the highest width and hight from children widgets
if r.w1 < cr.w1 {
r.w1 = cr.w1
}
if r.h1 < cr.h1 {
r.h1 = cr.h1
}
+
}
+ // try setting the full values here ? is this right?
+ tk.full.w0 = r.w0
+ tk.full.w1 = r.w1
+ tk.full.h0 = r.h0
+ tk.full.h1 = r.h1
+
return r
}
diff --git a/place.go b/place.go
index 12bb156..2c04f3d 100644
--- a/place.go
+++ b/place.go
@@ -39,6 +39,8 @@ func (w *guiWidget) placeBox(startW int, startH int) {
return
}
+ w.full.w0 = startW
+ w.full.h0 = startH
newW := startW
newH := startH
@@ -84,9 +86,14 @@ func (tk *guiWidget) placeWidgets(startW int, startH int) (int, int) {
return startW, startH
case widget.Tab:
case widget.Grid:
- return tk.placeGrid(startW, startH)
+ newW, newH := tk.placeGrid(startW, startH)
+ tk.full.w0 = newW
+ tk.full.h0 = newH
+ return newW, newH
case widget.Box:
tk.placeBox(startW, startH)
+ tk.full.w0 = startW
+ tk.full.h0 = startH
return 0, 0
case widget.Stdout:
tk.setStdoutWH(startW, startH)
@@ -94,6 +101,8 @@ func (tk *guiWidget) placeWidgets(startW int, startH int) (int, int) {
case widget.Group:
// move the group to the parent's next location
tk.gocuiSetWH(startW, startH)
+ tk.full.w0 = startW
+ tk.full.h0 = startH
newW := startW + me.GroupPadW
newH := startH + 1 // normal hight of the group label
@@ -126,6 +135,9 @@ func (w *guiWidget) placeGrid(startW int, startH int) (int, int) {
return 0, 0
}
+ w.full.w0 = startW
+ w.full.h0 = startH
+
// first compute the max sizes of the rows and columns
for _, child := range w.children {
childW, childH := child.placeWidgets(child.startW, child.startH)
diff --git a/window.go b/window.go
index b0fa9b3..99ecea6 100644
--- a/window.go
+++ b/window.go
@@ -33,21 +33,9 @@ func redoWindows(nextW int, nextH int) {
win.gocuiSize.w0 = nextW
win.gocuiSize.h0 = nextH
- tmp := fmt.Sprintf("redoWindowsS (%d,%d)", nextW, nextH)
- win.dumpWidget(tmp)
-
+ win.dumpWidget(fmt.Sprintf("redoWindowsS (%d,%d)", nextW, nextH))
win.redrawWindow(nextW, nextH)
- /*
-
- // this should make the window the full size and re-draw it
- win.setFullSize() // win.gocuiSetWH(nextW, nextH)
- win.Hide()
- win.DrawAt(nextW, nextH)
- win.Show()
- */
-
- tmp = fmt.Sprintf("redoWindowsE (%d,%d)", nextW, nextH)
- win.dumpWidget(tmp)
+ win.dumpWidget(fmt.Sprintf("redoWindowsE (%d,%d)", nextW, nextH))
// increment the width for the next window
nextW += win.gocuiSize.Width() + 4