debugging cleanups
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
9dd8a8afc9
commit
7b611d3dda
34
click.go
34
click.go
|
@ -13,15 +13,15 @@ func (w *guiWidget) doWidgetClick() {
|
|||
/*
|
||||
case widget.Root:
|
||||
// THIS IS THE BEGINING OF THE LAYOUT
|
||||
log.Log(NOW, "doWidgetClick()", w.String())
|
||||
log.Log(GOCUI, "doWidgetClick()", w.String())
|
||||
wRoot := me.treeRoot.TK.(*guiWidget)
|
||||
wRoot.redoWindows(0, 0)
|
||||
case widget.Flag:
|
||||
log.Log(NOW, "doWidgetClick() FLAG widget name =", w.String())
|
||||
log.Log(NOW, "doWidgetClick() if this is the dropdown menu, handle it here?")
|
||||
log.Log(GOCUI, "doWidgetClick() FLAG widget name =", w.String())
|
||||
log.Log(GOCUI, "doWidgetClick() if this is the dropdown menu, handle it here?")
|
||||
*/
|
||||
case widget.Window:
|
||||
log.Log(NOW, "doWidgetClick() START on window", w.String())
|
||||
log.Log(GOCUI, "doWidgetClick() START on window", w.String())
|
||||
// if the user clicked on the current window, do nothing
|
||||
/* Ignore this for now and redraw the window anyway
|
||||
if me.currentWindow == w {
|
||||
|
@ -43,7 +43,7 @@ func (w *guiWidget) doWidgetClick() {
|
|||
me.currentWindow.isCurrent = true
|
||||
|
||||
// draw the current window
|
||||
log.Log(NOW, "doWidgetClick() set currentWindow to", w.String())
|
||||
log.Log(GOCUI, "doWidgetClick() set currentWindow to", w.String())
|
||||
w.setColor(&colorActiveW)
|
||||
w.DrawAt(3, 2)
|
||||
w.placeWidgets(3, 2) // compute the sizes & places for each widget
|
||||
|
@ -88,9 +88,9 @@ func (w *guiWidget) doWidgetClick() {
|
|||
case widget.Box:
|
||||
// w.showWidgetPlacement(logNow, "drawTree()")
|
||||
if w.node.State.Direction == widget.Horizontal {
|
||||
log.Log(NOW, "BOX IS HORIZONTAL", w.String())
|
||||
log.Log(GOCUI, "BOX IS HORIZONTAL", w.String())
|
||||
} else {
|
||||
log.Log(NOW, "BOX IS VERTICAL", w.String())
|
||||
log.Log(GOCUI, "BOX IS VERTICAL", w.String())
|
||||
}
|
||||
w.placeWidgets(w.startW, w.startH)
|
||||
w.toggleTree()
|
||||
|
@ -98,11 +98,11 @@ func (w *guiWidget) doWidgetClick() {
|
|||
// doUserEvent(n)
|
||||
me.myTree.SendFromUser(w.node)
|
||||
case widget.Combobox:
|
||||
log.Log(NOW, "do the combobox here")
|
||||
log.Log(GOCUI, "do the combobox here")
|
||||
w.showDropdown()
|
||||
me.dropdownW = w
|
||||
case widget.Dropdown:
|
||||
log.Log(NOW, "do the dropdown here")
|
||||
log.Log(GOCUI, "do the dropdown here")
|
||||
w.showDropdown()
|
||||
me.dropdownW = w
|
||||
default:
|
||||
|
@ -112,7 +112,7 @@ func (w *guiWidget) doWidgetClick() {
|
|||
func click(g *gocui.Gui, v *gocui.View) error {
|
||||
mouseW, mouseH := me.baseGui.MousePosition()
|
||||
|
||||
log.Log(NOW, "click() START gocui name:", v.Name())
|
||||
log.Log(GOCUI, "click() START gocui name:", v.Name())
|
||||
w := findUnderMouse()
|
||||
|
||||
// if the dropdown view is visable, process it no matter what
|
||||
|
@ -126,7 +126,7 @@ func click(g *gocui.Gui, v *gocui.View) error {
|
|||
if w == nil {
|
||||
log.Error(errors.New("click() could not find widget for view =" + v.Name()))
|
||||
} else {
|
||||
log.Log(NOW, "click() Found widget =", w.node.WidgetId, w.String(), ",", w.labelN)
|
||||
log.Log(GOCUI, "click() Found widget =", w.node.WidgetId, w.String(), ",", w.labelN)
|
||||
w.doWidgetClick()
|
||||
}
|
||||
|
||||
|
@ -134,7 +134,7 @@ func click(g *gocui.Gui, v *gocui.View) error {
|
|||
realTK := rootTK.findWidgetByView(v)
|
||||
if realTK == nil {
|
||||
log.Error(errors.New("toolkit click() out of reality with gocui. v.Name() not in binary tree " + v.Name()))
|
||||
log.Log(NOW, "click() END FAILURE ON gocui v.Name =", v.Name())
|
||||
log.Log(GOCUI, "click() END FAILURE ON gocui v.Name =", v.Name())
|
||||
// return nil // otherwise gocui exits
|
||||
}
|
||||
|
||||
|
@ -145,19 +145,19 @@ func click(g *gocui.Gui, v *gocui.View) error {
|
|||
return nil
|
||||
}
|
||||
if nameTK.v == nil {
|
||||
log.Log(NOW, "click() maybe this widget has had it's view distroyed?", nameTK.cuiName, nameTK.WidgetType)
|
||||
log.Log(NOW, "yep. it's gone now")
|
||||
log.Log(GOCUI, "click() maybe this widget has had it's view distroyed?", nameTK.cuiName, nameTK.WidgetType)
|
||||
log.Log(GOCUI, "yep. it's gone now")
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetCurrentView dies if it's sent an non-existent view
|
||||
if _, err := g.SetCurrentView(v.Name()); err != nil {
|
||||
log.Log(NOW, "click() END v.Name =", v.Name(), "err =", err)
|
||||
log.Log(GOCUI, "click() END v.Name =", v.Name(), "err =", err)
|
||||
// return err // return causes gocui.MainLoop() to exit. Do we ever want that to happen here?
|
||||
return nil
|
||||
}
|
||||
|
||||
log.Log(NOW, "click() END gocui name:", v.Name())
|
||||
log.Log(GOCUI, "click() END gocui name:", v.Name())
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -186,7 +186,6 @@ func findUnderMouse() *guiWidget {
|
|||
var found *guiWidget
|
||||
// widgets has everything that matches
|
||||
for _, w := range widgets {
|
||||
w.showWidgetPlacement("findUnderMouse() FOUND")
|
||||
// prioritize window buttons. This means if some code covers
|
||||
// up the window widgets, then it will ignore everything else
|
||||
// and allow the user (hopefully) to redraw or switch windows
|
||||
|
@ -194,6 +193,7 @@ func findUnderMouse() *guiWidget {
|
|||
if w.WidgetType == widget.Window {
|
||||
return w
|
||||
}
|
||||
// w.showWidgetPlacement("findUnderMouse() FOUND")
|
||||
found = w
|
||||
}
|
||||
return found
|
||||
|
|
32
dropdown.go
32
dropdown.go
|
@ -73,16 +73,16 @@ func (tk *guiWidget) showDropdown() {
|
|||
// var items []string
|
||||
// items = tk.node.State.Strings
|
||||
//for i, s := range items {
|
||||
for i, s := range tk.vals {
|
||||
log.Log(NOW, "showDropdown()", tk.String(), i, s)
|
||||
for i, s := range tk.node.Strings() {
|
||||
log.Log(GOCUI, "showDropdown()", tk.String(), i, s)
|
||||
ddItems += s + "\n"
|
||||
}
|
||||
|
||||
log.Log(NOW, "new dropdown items should be set to:", ddItems)
|
||||
log.Log(GOCUI, "new dropdown items should be set to:", ddItems)
|
||||
sizeW, sizeH := tk.Size()
|
||||
log.Log(NOW, "showDropdown() size W,H=", sizeW, sizeH)
|
||||
log.Log(GOCUI, "showDropdown() size W,H=", sizeW, sizeH)
|
||||
startW, startH := tk.Position()
|
||||
log.Log(NOW, "showDropdown() location W,H=", startW, startH)
|
||||
log.Log(GOCUI, "showDropdown() location W,H=", startW, startH)
|
||||
me.dropdownV.MoveToOffset(startW+3, startH+2)
|
||||
me.dropdownV.labelN = ddItems
|
||||
me.dropdownV.Show()
|
||||
|
@ -90,7 +90,7 @@ func (tk *guiWidget) showDropdown() {
|
|||
|
||||
func hideDDview() error {
|
||||
w, h := me.baseGui.MousePosition()
|
||||
log.Log(NOW, "hide dropdown menu() view msgMouseDown (w,h) =", w, h)
|
||||
log.Log(GOCUI, "hide dropdown menu() view msgMouseDown (w,h) =", w, h)
|
||||
if me.dropdownV == nil {
|
||||
return gocui.ErrUnknownView
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ func hideDDview() error {
|
|||
|
||||
func showDDview() error {
|
||||
w, h := me.baseGui.MousePosition()
|
||||
log.Log(NOW, "show dropdown menu() view msgMouseDown (w,h) =", w, h)
|
||||
log.Log(GOCUI, "show dropdown menu() view msgMouseDown (w,h) =", w, h)
|
||||
if me.dropdownV == nil {
|
||||
return gocui.ErrUnknownView
|
||||
}
|
||||
|
@ -119,21 +119,21 @@ func (w *guiWidget) dropdownClicked(mouseW, mouseH int) string {
|
|||
w.Hide()
|
||||
|
||||
startW, startH := w.Position()
|
||||
log.Log(NOW, "dropdownClicked() start (w,h) =", startW, startH)
|
||||
log.Log(NOW, "dropdownClicked() at (w,h) =", mouseW, mouseH)
|
||||
log.Log(GOCUI, "dropdownClicked() start (w,h) =", startW, startH)
|
||||
log.Log(GOCUI, "dropdownClicked() at (w,h) =", mouseW, mouseH)
|
||||
|
||||
itemNumber := mouseH - startH
|
||||
items := strings.Split(w.labelN, "\n")
|
||||
log.Log(NOW, "dropdownClicked() look for item", itemNumber, "len(items) =", len(items))
|
||||
log.Log(GOCUI, "dropdownClicked() look for item", itemNumber, "len(items) =", len(items))
|
||||
if itemNumber < 1 {
|
||||
return ""
|
||||
}
|
||||
|
||||
if len(items) >= itemNumber {
|
||||
log.Log(NOW, "dropdownClicked() found", items[itemNumber-1])
|
||||
log.Log(GOCUI, "dropdownClicked() found", items[itemNumber-1])
|
||||
if items[itemNumber-1] != "" {
|
||||
if me.dropdownW != nil {
|
||||
log.Log(NOW, "dropdownClicked() send event for", me.dropdownW.cuiName, me.dropdownW.WidgetType)
|
||||
log.Log(GOCUI, "dropdownClicked() send event for", me.dropdownW.cuiName, me.dropdownW.WidgetType)
|
||||
me.dropdownW.SetText(items[itemNumber-1])
|
||||
me.dropdownW.node.SetCurrentS(items[itemNumber-1])
|
||||
me.myTree.SendUserEvent(me.dropdownW.node)
|
||||
|
@ -146,11 +146,11 @@ func (w *guiWidget) dropdownClicked(mouseW, mouseH int) string {
|
|||
|
||||
func dropdownUnclicked(mouseX, mouseH int) {
|
||||
if me.dropdownV == nil {
|
||||
log.Log(NOW, "mouseUp() dropdownV = nil", mouseX, mouseH)
|
||||
log.Log(GOCUI, "mouseUp() dropdownV = nil", mouseX, mouseH)
|
||||
return
|
||||
}
|
||||
tk := me.dropdownV
|
||||
log.Log(NOW, "mouseUp() view msgMouseDown (check here for dropdown menu click) (w,h) =", mouseX, mouseH)
|
||||
log.Log(NOW, "mouseUp() ddview is the thing that was clicked", mouseX, mouseH)
|
||||
log.Log(NOW, "mouseUp() find out what the string is here", mouseX, mouseH, tk.gocuiSize.h1)
|
||||
log.Log(GOCUI, "mouseUp() view msgMouseDown (check here for dropdown menu click) (w,h) =", mouseX, mouseH)
|
||||
log.Log(GOCUI, "mouseUp() ddview is the thing that was clicked", mouseX, mouseH)
|
||||
log.Log(GOCUI, "mouseUp() find out what the string is here", mouseX, mouseH, tk.gocuiSize.h1)
|
||||
}
|
||||
|
|
8
log.go
8
log.go
|
@ -12,6 +12,7 @@ var outputS []string
|
|||
|
||||
var NOW *log.LogFlag
|
||||
var INFO *log.LogFlag
|
||||
var GOCUI *log.LogFlag
|
||||
|
||||
var SPEW *log.LogFlag
|
||||
var WARN *log.LogFlag
|
||||
|
@ -19,9 +20,14 @@ var WARN *log.LogFlag
|
|||
var ERROR *log.LogFlag
|
||||
|
||||
func init() {
|
||||
full := "go.wit.com/toolkits/gocui"
|
||||
full := "go.wit.com/gui"
|
||||
short := "gocui"
|
||||
|
||||
GOCUI = log.NewFlag("GOCUI", false, full, short, "gocui internals")
|
||||
|
||||
full = "go.wit.com/toolkits/gocui"
|
||||
short = "gocui"
|
||||
|
||||
NOW = log.NewFlag("NOW", true, full, short, "temp debugging stuff")
|
||||
INFO = log.NewFlag("INFO", false, full, short, "normal debugging stuff")
|
||||
|
||||
|
|
4
mouse.go
4
mouse.go
|
@ -27,7 +27,7 @@ func mouseMove(g *gocui.Gui) {
|
|||
|
||||
func msgDown(g *gocui.Gui, v *gocui.View) error {
|
||||
initialMouseX, initialMouseY = g.MousePosition()
|
||||
log.Log(NOW, "msgDown() X,Y", initialMouseX, initialMouseY)
|
||||
log.Log(GOCUI, "msgDown() X,Y", initialMouseX, initialMouseY)
|
||||
if vx, vy, _, _, err := g.ViewPosition("msg"); err == nil {
|
||||
xOffset = initialMouseX - vx
|
||||
yOffset = initialMouseY - vy
|
||||
|
@ -73,7 +73,7 @@ func mouseDown(g *gocui.Gui, v *gocui.View) error {
|
|||
} else if x+len(msg)+1 > maxX-1 {
|
||||
x = maxX - 1 - len(msg) - 1
|
||||
}
|
||||
log.Log(NOW, "mouseDown() about to write out message to 'globalDown' view. msg =", msg)
|
||||
log.Log(GOCUI, "mouseDown() about to write out message to 'globalDown' view. msg =", msg)
|
||||
if v, err := g.SetView("globalDown", x, my-1, x+len(msg)+1, my+1, 0); err != nil {
|
||||
if !errors.Is(err, gocui.ErrUnknownView) {
|
||||
return err
|
||||
|
|
|
@ -86,10 +86,8 @@ func newaction(n *tree.Node, atype widget.ActionType) {
|
|||
w := n.TK.(*guiWidget)
|
||||
switch atype {
|
||||
case widget.Show:
|
||||
log.Log(NOW, "Show() HERE. a.Hidden() was =", n.Hidden())
|
||||
w.Show()
|
||||
case widget.Hide:
|
||||
log.Log(NOW, "Hide() HERE. a.State.Hidden was =", n.Hidden())
|
||||
w.Hide()
|
||||
case widget.Move:
|
||||
log.Log(NOW, "attempt to move() =", atype, n.WidgetType, n.ProgName())
|
||||
|
|
23
widget.go
23
widget.go
|
@ -65,7 +65,7 @@ func setupCtrlDownWidget() {
|
|||
|
||||
func (w *guiWidget) deleteView() {
|
||||
// make sure the view isn't really there
|
||||
log.Log(NOW, "deleteView()", w.cuiName, w.WidgetType, w.node.WidgetId)
|
||||
log.Log(GOCUI, "deleteView()", w.cuiName, w.WidgetType, w.node.WidgetId)
|
||||
me.baseGui.DeleteView(w.cuiName)
|
||||
w.v = nil
|
||||
}
|
||||
|
@ -75,8 +75,8 @@ func (w *guiWidget) IsCurrent() bool {
|
|||
return w.isCurrent
|
||||
}
|
||||
if w.node.WidgetType == widget.Window {
|
||||
log.Log(NOW, "IsCurrent() found current window", w.cuiName, w.String())
|
||||
log.Log(NOW, "IsCurrent() window w.isCurrent =", w.isCurrent)
|
||||
log.Log(GOCUI, "IsCurrent() found current window", w.cuiName, w.String())
|
||||
log.Log(GOCUI, "IsCurrent() window w.isCurrent =", w.isCurrent)
|
||||
return w.isCurrent
|
||||
}
|
||||
if w.node.WidgetType == widget.Root {
|
||||
|
@ -125,15 +125,24 @@ func (w *guiWidget) Show() {
|
|||
return
|
||||
}
|
||||
|
||||
if w.node.WidgetType == widget.Dropdown {
|
||||
log.Log(NOW, "Show() dropdown", w.cuiName, w.String())
|
||||
log.Log(NOW, "Show() dropdown n.Strings() =", w.node.Strings())
|
||||
}
|
||||
if w.node.WidgetType == widget.Combobox {
|
||||
log.Log(NOW, "Show() dropdown", w.cuiName, w.String())
|
||||
log.Log(NOW, "Show() dropdown n.Strings() =", w.node.Strings())
|
||||
}
|
||||
|
||||
// if the widget is not in the current displayed windo
|
||||
// then ignore it
|
||||
log.Log(NOW, "Show() widget =", w.cuiName, w.String())
|
||||
log.Log(NOW, "Show() w.IsCurrent() returned", w.IsCurrent())
|
||||
log.Log(GOCUI, "Show() widget =", w.cuiName, w.String())
|
||||
log.Log(GOCUI, "Show() w.IsCurrent() returned", w.IsCurrent())
|
||||
if !w.IsCurrent() {
|
||||
log.Log(NOW, "Show() NOT drawing", w.cuiName, w.String())
|
||||
log.Log(GOCUI, "Show() NOT drawing", w.cuiName, w.String())
|
||||
return
|
||||
}
|
||||
log.Log(NOW, "Show() drawing", w.cuiName, w.String())
|
||||
log.Log(GOCUI, "Show() drawing", w.cuiName, w.String())
|
||||
|
||||
// finally, check if the widget State is hidden or not
|
||||
if w.node.Hidden() {
|
||||
|
|
Loading…
Reference in New Issue