window is starting to draw!

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-01-28 11:44:36 -06:00
parent d5be773817
commit eca2f2aa48
6 changed files with 53 additions and 34 deletions

2
add.go
View File

@ -80,5 +80,5 @@ func addWidget(n *tree.Node) {
}
*/
}
showWidgetPlacement(n, true, "addWidget()")
nw.showWidgetPlacement(true, "addWidget()")
}

View File

@ -100,6 +100,7 @@ func (w *guiWidget) doWidgetClick() {
log.Log(NOW, "doWidgetClick() FLAG widget name =", w.String())
log.Log(NOW, "doWidgetClick() if this is the dropdown menu, handle it here?")
case widget.Window:
log.Log(NOW, "doWidgetClick() START on window", w.String())
if me.currentWindow == w.node {
return
}
@ -112,8 +113,12 @@ func (w *guiWidget) doWidgetClick() {
}
me.currentWindow = w.node
log.Log(NOW, "doWidgetClick() set currentWindow to", w.String())
w.setColor(&colorActiveW)
w.hideWidgets()
w.placeWidgets(me.RawW, me.RawH)
w.showWidgets()
/*
w.redoTabs(me.TabW, me.TabH)
for _, child := range w.children {
if child.currentTab == true {
@ -124,6 +129,7 @@ func (w *guiWidget) doWidgetClick() {
return
}
}
*/
/* FIXME: redo this
if ! n.hasTabs {
}
@ -310,18 +316,20 @@ func findUnderMouse() *tree.Node {
found = n
}
}
if n == me.ddview {
tk := me.ddview.TK.(*guiWidget)
log.Log(NOW, "findUnderMouse() found ddview")
if tk.Visible() {
log.Log(NOW, "findUnderMouse() and ddview is visable. hide it here. TODO: find highlighted row")
found = n
// find the actual value here and set the dropdown widget
me.baseGui.DeleteView("ddview")
} else {
log.Log(NOW, "findUnderMouse() I was lying, actually it's not found")
/*
if n == me.ddview {
tk := me.ddview.TK.(*guiWidget)
log.Log(NOW, "findUnderMouse() found ddview")
if tk.Visible() {
log.Log(NOW, "findUnderMouse() and ddview is visable. hide it here. TODO: find highlighted row")
found = n
// find the actual value here and set the dropdown widget
me.baseGui.DeleteView("ddview")
} else {
log.Log(NOW, "findUnderMouse() I was lying, actually it's not found")
}
}
}
*/
for _, child := range widget.children {
f(child.node)
@ -332,7 +340,8 @@ func findUnderMouse() *tree.Node {
// TODO: pop up menu with a list of them
for _, n := range widgets {
//log(logNow, "ctrlDown() FOUND widget", widget.id, widget.name)
showWidgetPlacement(n, true, "findUnderMouse() FOUND")
widget := n.TK.(*guiWidget)
widget.showWidgetPlacement(true, "findUnderMouse() FOUND")
}
return found
}

View File

@ -4,33 +4,22 @@ import (
"fmt"
"go.wit.com/log"
"go.wit.com/toolkits/tree"
"go.wit.com/widget"
)
func dumpTree(n *tree.Node, draw bool) {
w := n.TK.(*guiWidget)
log.Log(ERROR, "dumpTree n", n.WidgetId, n.WidgetType, n.String())
func (w *guiWidget) dumpTree(draw bool) {
log.Log(ERROR, "dumpTree w", w.node.WidgetId, w.WidgetType, w.String())
if w == nil {
log.Log(ERROR, "dumpTree n.TK == nil", n.WidgetId, n.WidgetType, n.String())
log.Log(ERROR, "dumpTree w.TK == nil", w.node.WidgetId, w.WidgetType, w.String())
return
}
showWidgetPlacement(n, true, "dumpTree()")
w.showWidgetPlacement(true, "dumpTree()")
for _, child := range w.children {
dumpTree(child.node, draw)
child.dumpTree(draw)
}
}
func showWidgetPlacement(n *tree.Node, b bool, s string) {
if n == nil {
log.Log(ERROR, "WTF w == nil")
return
}
w := n.TK.(*guiWidget)
w.showWidgetPlacement(b, s)
}
func (w *guiWidget) showWidgetPlacement(b bool, s string) {
var s1 string
var pId int

View File

@ -118,7 +118,8 @@ func addDebugKeys(g *gocui.Gui) {
// list all widgets with positions
g.SetKeybinding("", 'M', gocui.ModNone,
func(g *gocui.Gui, v *gocui.View) error {
dumpTree(me.treeRoot, true)
w := me.treeRoot.TK.(*guiWidget)
w.dumpTree(true)
return nil
})

20
tab.go
View File

@ -108,3 +108,23 @@ func (p *guiWidget) redoTabs(nextW int, nextH int) {
nextW += sizeW
}
}
func (p *guiWidget) drawWindow(nextW int, nextH int) {
for _, w := range p.children {
w.frame = true
w.gocuiSetWH(nextW, nextH)
w.deleteView()
// setCurrentTab(n)
// if (len(w.cuiName) < 4) {
// w.cuiName = "abcd"
// }
w.showView()
sizeW := w.Width() + me.TabPadW
sizeH := w.Height()
log.Log(NOW, "redoTabs() start nextW,H =", nextW, nextH, "gocuiSize.W,H =", sizeW, sizeH, w.String())
nextW += sizeW
}
}

View File

@ -42,7 +42,7 @@ func (w *guiWidget) textResize() bool {
changed = true
}
if changed {
showWidgetPlacement(w.node, true, "textResize() changed")
w.showWidgetPlacement(true, "textResize() changed")
}
return changed
}
@ -136,12 +136,12 @@ func (w *guiWidget) recreateView() {
w.v, err = me.baseGui.SetView(w.cuiName, a, b, c, d, 0)
if err == nil {
showWidgetPlacement(w.node, true, "recreateView()")
w.showWidgetPlacement(true, "recreateView()")
log.Log(ERROR, "recreateView() internal plugin error err = nil")
return
}
if !errors.Is(err, gocui.ErrUnknownView) {
showWidgetPlacement(w.node, true, "recreateView()")
w.showWidgetPlacement(true, "recreateView()")
log.Log(ERROR, "recreateView() internal plugin error error.IS()", err)
return
}
@ -174,7 +174,7 @@ func (w *guiWidget) recreateView() {
}
if w.String() == "CLOUDFLARE_EMAIL" {
w.showWidgetPlacement(true, "w.String()="+w.String()+" w.label="+w.labelN+" "+w.cuiName)
dumpTree(w.node, true)
w.dumpTree(true)
}
log.Log(ERROR, "recreateView() END")
}