still notsure
This commit is contained in:
parent
6237bf89c3
commit
a81e931b9a
8
debug.go
8
debug.go
|
@ -27,7 +27,7 @@ func (w *guiWidget) dumpTree(s string) {
|
||||||
func (tk *guiWidget) dumpWidget(s string) {
|
func (tk *guiWidget) dumpWidget(s string) {
|
||||||
var s1 string
|
var s1 string
|
||||||
var pId int
|
var pId int
|
||||||
tk.verifyRect()
|
// tk.verifyRect()
|
||||||
if tk.node.Parent == nil {
|
if tk.node.Parent == nil {
|
||||||
log.Log(INFO, "showWidgetPlacement() parent == nil", tk.node.WidgetId, tk.cuiName)
|
log.Log(INFO, "showWidgetPlacement() parent == nil", tk.node.WidgetId, tk.cuiName)
|
||||||
pId = 0
|
pId = 0
|
||||||
|
@ -38,16 +38,12 @@ func (tk *guiWidget) dumpWidget(s string) {
|
||||||
sizeW, sizeH := tk.Size()
|
sizeW, sizeH := tk.Size()
|
||||||
s1 += fmt.Sprintf("size=(%3d,%3d)", sizeW, sizeH)
|
s1 += fmt.Sprintf("size=(%3d,%3d)", sizeW, sizeH)
|
||||||
if tk.Visible() {
|
if tk.Visible() {
|
||||||
r := tk.getFullSize()
|
|
||||||
s1 += fmt.Sprintf("gocui=(%3d,%3d,%3d,%3d)",
|
s1 += fmt.Sprintf("gocui=(%3d,%3d,%3d,%3d)",
|
||||||
tk.gocuiSize.w0, tk.gocuiSize.h0, tk.gocuiSize.w1, tk.gocuiSize.h1)
|
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 {
|
} else {
|
||||||
s1 += fmt.Sprintf(" %3s %3s %3s %3s ", "", "", "", "")
|
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 != nil {
|
||||||
if tk.node.Parent.WidgetType == widget.Grid {
|
if tk.node.Parent.WidgetType == widget.Grid {
|
||||||
s1 += fmt.Sprintf("At(%3d,%3d) ", tk.node.State.AtW, tk.node.State.AtH)
|
s1 += fmt.Sprintf("At(%3d,%3d) ", tk.node.State.AtW, tk.node.State.AtH)
|
||||||
|
|
|
@ -63,6 +63,7 @@ func setSuperMouse(g *gocui.Gui, v *gocui.View) error {
|
||||||
|
|
||||||
var wtf bool
|
var wtf bool
|
||||||
|
|
||||||
|
/*
|
||||||
func (tk *guiWidget) verifyRect() bool {
|
func (tk *guiWidget) verifyRect() bool {
|
||||||
if !tk.Visible() {
|
if !tk.Visible() {
|
||||||
// log.Info("verifyRect() tk is not visible", tk.cuiName)
|
// 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())
|
// log.Printf("verifyRect() OK cuiName=%s v.Name=%s", tk.cuiName, tk.v.Name())
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
func (tk *guiWidget) makeTK(ddItems []string) {
|
func (tk *guiWidget) makeTK(ddItems []string) {
|
||||||
items := strings.Join(ddItems, "\n")
|
items := strings.Join(ddItems, "\n")
|
||||||
|
@ -230,7 +232,7 @@ func theFind(g *gocui.Gui, v *gocui.View) error {
|
||||||
for _, tk := range findByXY(w, h) {
|
for _, tk := range findByXY(w, h) {
|
||||||
// tk.v.BgColor = gocui.ColorGreen
|
// tk.v.BgColor = gocui.ColorGreen
|
||||||
tk.dumpWidget("theFind()")
|
tk.dumpWidget("theFind()")
|
||||||
tk.verifyRect()
|
// tk.verifyRect()
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,7 +100,7 @@ func (tk *guiWidget) moveNew() {
|
||||||
}
|
}
|
||||||
if tk.node.WidgetType == widget.Flag {
|
if tk.node.WidgetType == widget.Flag {
|
||||||
me.baseGui.SetView(tk.cuiName, w-3, h-3, w+20, h+20, 0)
|
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)
|
s := fmt.Sprintf("move(%dx%d) %s ###", w, h, tk.cuiName)
|
||||||
tk.dumpWidget(s)
|
tk.dumpWidget(s)
|
||||||
return
|
return
|
||||||
|
|
46
find.go
46
find.go
|
@ -4,8 +4,9 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"github.com/awesome-gocui/gocui"
|
"github.com/awesome-gocui/gocui"
|
||||||
log "go.wit.com/log"
|
|
||||||
"go.wit.com/widget"
|
"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)
|
// log.Log(GOCUI, "findByXY() found", widget.node.WidgetType, w, h)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tk.verifyRect()
|
// tk.verifyRect()
|
||||||
|
|
||||||
// search through the children widgets in the binary tree
|
// search through the children widgets in the binary tree
|
||||||
for _, child := range tk.children {
|
for _, child := range tk.children {
|
||||||
|
@ -78,7 +79,7 @@ func (tk *guiWidget) findWindows() []*guiWidget {
|
||||||
return found
|
return found
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tk *guiWidget) setFullSize() rectType {
|
func (tk *guiWidget) setFullSize() bool {
|
||||||
r := tk.getFullSize()
|
r := tk.getFullSize()
|
||||||
|
|
||||||
var changed bool
|
var changed bool
|
||||||
|
@ -99,15 +100,9 @@ func (tk *guiWidget) setFullSize() rectType {
|
||||||
changed = true
|
changed = true
|
||||||
}
|
}
|
||||||
if changed {
|
if changed {
|
||||||
if tk.node.WidgetType == widget.Window {
|
tk.dumpWidget(fmt.Sprintf("setFullSize(changed)"))
|
||||||
log.Info("REDRAW WINDOW IN setFullSize()")
|
|
||||||
tk.full.w1 = r.w1 + 2
|
|
||||||
tk.full.h1 = r.h1 + 1
|
|
||||||
tk.Hide()
|
|
||||||
tk.drawView()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return r
|
return changed
|
||||||
}
|
}
|
||||||
|
|
||||||
// this checks a widget to see if it is under (W,H), then checks the widget's children
|
// 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 {
|
func (tk *guiWidget) getFullSize() rectType {
|
||||||
var r rectType
|
var r rectType
|
||||||
|
|
||||||
r.w0 = tk.gocuiSize.w0
|
if tk.v == nil {
|
||||||
r.w1 = tk.gocuiSize.w1
|
r.w0 = tk.full.w0
|
||||||
r.h0 = tk.gocuiSize.h0
|
r.w1 = tk.full.w1
|
||||||
r.h1 = tk.gocuiSize.h1
|
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
|
// search through the children widgets in the binary tree
|
||||||
for _, child := range tk.children {
|
for _, child := range tk.children {
|
||||||
cr := child.getFullSize()
|
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 {
|
if r.w0 > cr.w0 {
|
||||||
r.w0 = cr.w0
|
r.w0 = cr.w0
|
||||||
}
|
}
|
||||||
if r.h0 > cr.h0 {
|
if r.h0 > cr.h0 {
|
||||||
r.h0 = cr.h0
|
r.h0 = cr.h0
|
||||||
}
|
}
|
||||||
|
// use the highest width and hight from children widgets
|
||||||
if r.w1 < cr.w1 {
|
if r.w1 < cr.w1 {
|
||||||
r.w1 = cr.w1
|
r.w1 = cr.w1
|
||||||
}
|
}
|
||||||
if r.h1 < cr.h1 {
|
if r.h1 < cr.h1 {
|
||||||
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
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
14
place.go
14
place.go
|
@ -39,6 +39,8 @@ func (w *guiWidget) placeBox(startW int, startH int) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
w.full.w0 = startW
|
||||||
|
w.full.h0 = startH
|
||||||
newW := startW
|
newW := startW
|
||||||
newH := startH
|
newH := startH
|
||||||
|
|
||||||
|
@ -84,9 +86,14 @@ func (tk *guiWidget) placeWidgets(startW int, startH int) (int, int) {
|
||||||
return startW, startH
|
return startW, startH
|
||||||
case widget.Tab:
|
case widget.Tab:
|
||||||
case widget.Grid:
|
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:
|
case widget.Box:
|
||||||
tk.placeBox(startW, startH)
|
tk.placeBox(startW, startH)
|
||||||
|
tk.full.w0 = startW
|
||||||
|
tk.full.h0 = startH
|
||||||
return 0, 0
|
return 0, 0
|
||||||
case widget.Stdout:
|
case widget.Stdout:
|
||||||
tk.setStdoutWH(startW, startH)
|
tk.setStdoutWH(startW, startH)
|
||||||
|
@ -94,6 +101,8 @@ func (tk *guiWidget) placeWidgets(startW int, startH int) (int, int) {
|
||||||
case widget.Group:
|
case widget.Group:
|
||||||
// move the group to the parent's next location
|
// move the group to the parent's next location
|
||||||
tk.gocuiSetWH(startW, startH)
|
tk.gocuiSetWH(startW, startH)
|
||||||
|
tk.full.w0 = startW
|
||||||
|
tk.full.h0 = startH
|
||||||
|
|
||||||
newW := startW + me.GroupPadW
|
newW := startW + me.GroupPadW
|
||||||
newH := startH + 1 // normal hight of the group label
|
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
|
return 0, 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
w.full.w0 = startW
|
||||||
|
w.full.h0 = startH
|
||||||
|
|
||||||
// first compute the max sizes of the rows and columns
|
// first compute the max sizes of the rows and columns
|
||||||
for _, child := range w.children {
|
for _, child := range w.children {
|
||||||
childW, childH := child.placeWidgets(child.startW, child.startH)
|
childW, childH := child.placeWidgets(child.startW, child.startH)
|
||||||
|
|
16
window.go
16
window.go
|
@ -33,21 +33,9 @@ func redoWindows(nextW int, nextH int) {
|
||||||
win.gocuiSize.w0 = nextW
|
win.gocuiSize.w0 = nextW
|
||||||
win.gocuiSize.h0 = nextH
|
win.gocuiSize.h0 = nextH
|
||||||
|
|
||||||
tmp := fmt.Sprintf("redoWindowsS (%d,%d)", nextW, nextH)
|
win.dumpWidget(fmt.Sprintf("redoWindowsS (%d,%d)", nextW, nextH))
|
||||||
win.dumpWidget(tmp)
|
|
||||||
|
|
||||||
win.redrawWindow(nextW, nextH)
|
win.redrawWindow(nextW, nextH)
|
||||||
/*
|
win.dumpWidget(fmt.Sprintf("redoWindowsE (%d,%d)", 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)
|
|
||||||
|
|
||||||
// increment the width for the next window
|
// increment the width for the next window
|
||||||
nextW += win.gocuiSize.Width() + 4
|
nextW += win.gocuiSize.Width() + 4
|
||||||
|
|
Loading…
Reference in New Issue