code cleanups

This commit is contained in:
Jeff Carr 2025-02-09 12:21:43 -06:00
parent 87d31a3d94
commit c5cada3dc9
7 changed files with 63 additions and 54 deletions

View File

@ -81,7 +81,7 @@ func theNotsure(g *gocui.Gui, v *gocui.View) error {
win := findWindowUnderMouse()
if win != nil {
win.dumpWidget("found() win. redrawing window:")
win.redrawWindow(win.gocuiSize.w0, win.gocuiSize.h0)
win.makeWindowActive()
}
return nil
@ -119,8 +119,6 @@ func tabCycleWindows(g *gocui.Gui, v *gocui.View) error {
return nil
}
tk.makeWindowActive()
tk.redrawWindow(tk.gocuiSize.w0, tk.gocuiSize.h0)
setThingsOnTop() // sets help, Stdout, etc on the top after windows have been redrawn
return nil
}

View File

@ -110,41 +110,47 @@ func mouseDown(g *gocui.Gui, v *gocui.View) error {
log.Info("never found textbox at", w, h)
return nil
}
// figre out what window this is
tk := findWindowUnderMouse()
if tk == nil {
win := findWindowUnderMouse()
if win == nil {
log.Info("mouseDown() nothing to click on at", w, h)
return nil
}
tk.makeWindowActive()
// log.Info("SENDING mouseDown() to findWindowUnderMouse()")
if tk.node.WidgetType == widget.Window {
// check to see if this is a direct click on a widget
for _, tk := range tk.findByXYreal(w, h) {
// tk.dumpWidget("mouseDown()")
if tk.node.WidgetType == widget.Button {
// log.Info("SENDING CLICK TO Button")
tk.doWidgetClick(w, h)
return nil
}
if tk.node.WidgetType == widget.Checkbox {
// log.Info("SENDING CLICK TO Checkbox")
tk.doWidgetClick(w, h)
return nil
}
if tk.node.WidgetType == widget.Dropdown {
// log.Info("SENDING CLICK TO Dropdown")
tk.doWidgetClick(w, h)
return nil
}
if tk.node.WidgetType == widget.Textbox {
// log.Info("SENDING CLICK TO Textbox")
tk.doWidgetClick(w, h)
return nil
return nil
// me.mouse.currentDrag = tk
/*
if !tk.isWindowActive() {
tk.makeWindowActive()
return nil
}
// log.Info("SENDING mouseDown() to findWindowUnderMouse()")
if tk.node.WidgetType == widget.Window {
// check to see if this is a direct click on a widget
for _, tk := range tk.findByXYreal(w, h) {
// tk.dumpWidget("mouseDown()")
if tk.node.WidgetType == widget.Button {
// log.Info("SENDING CLICK TO Button")
tk.doWidgetClick(w, h)
return nil
}
if tk.node.WidgetType == widget.Checkbox {
// log.Info("SENDING CLICK TO Checkbox")
tk.doWidgetClick(w, h)
return nil
}
if tk.node.WidgetType == widget.Dropdown {
// log.Info("SENDING CLICK TO Dropdown")
tk.doWidgetClick(w, h)
return nil
}
if tk.node.WidgetType == widget.Textbox {
// log.Info("SENDING CLICK TO Textbox")
tk.doWidgetClick(w, h)
return nil
}
}
}
}
me.mouse.currentDrag = tk
return nil
*/
}

View File

@ -115,9 +115,7 @@ func doMouseClick(w int, h int) {
return
}
// log.Info("you clicked on a window, but not any widgets. check for title / close window here", win.cuiName)
win.redrawWindow(win.gocuiSize.w0, win.gocuiSize.h0)
me.stdout.outputOnTop = false
setThingsOnTop()
win.makeWindowActive()
return
}
@ -154,9 +152,7 @@ func doMouseDoubleClick(w int, h int) {
for _, tk := range findByXY(w, h) {
if tk.node.WidgetType == widget.Window {
tk.redrawWindow(tk.gocuiSize.w0, tk.gocuiSize.h0)
me.stdout.outputOnTop = false
setThingsOnTop()
tk.makeWindowActive()
return
}

View File

@ -143,11 +143,9 @@ func (tk *guiWidget) moveNew() {
// compute the new location based off how far the mouse has moved
// since the mouse button was pressed down
newW := tk.lastW + w - me.mouse.downW
newH := tk.lastH + h - me.mouse.downH
tk.redrawWindow(newW, newH)
setThingsOnTop() // sets help, Stdout, etc on the top after windows have been redrawn
tk.gocuiSize.w0 = tk.lastW + w - me.mouse.downW
tk.gocuiSize.h0 = tk.lastH + h - me.mouse.downH
tk.makeWindowActive()
return
}
if tk.node.WidgetType == widget.Flag {

View File

@ -306,12 +306,6 @@ func newWindowTrigger() {
relocateStdoutOffscreen()
}
tk.makeWindowActive()
// place the new window relative to the mouse
tk.redrawWindow(me.mouse.downW+8, me.mouse.downH-2)
// tk.redrawWindow(tk.gocuiSize.w0, tk.gocuiSize.h0)
setThingsOnTop() // sets help, Stdout, etc on the top after windows have been redrawn
// log.Log(NOW, "newWindowTrigger() after sleep")
}
}
}

View File

@ -118,6 +118,6 @@ func textboxClosed() {
me.textbox.callerTK.Size()
me.textbox.callerTK.placeWidgets(tk.gocuiSize.w0-4, tk.gocuiSize.h0-4)
// tk.dumpWidget("resize:" + tk.String())
win.redrawWindow(win.gocuiSize.w0, win.gocuiSize.h0)
win.makeWindowActive()
}
}

View File

@ -115,8 +115,7 @@ func redoWindows(nextW int, nextH int) {
// tk.dumpWidget(fmt.Sprintf("redoWindowsS (%d,%d)", nextW, nextH))
if tk.window.wasDragged {
// don't move windows around the user has dragged to a certain location
tk.redrawWindow(tk.gocuiSize.w0, tk.gocuiSize.h0)
setThingsOnTop() // sets help, Stdout, etc on the top after windows have been redrawn
tk.makeWindowActive()
} else {
w, _ := me.baseGui.Size()
if nextW > w-20 {
@ -175,12 +174,27 @@ func (win *guiWidget) addWindowFrame(wId int) *tree.Node {
return n
}
func (tk *guiWidget) isWindowActive() bool {
if !(tk.node.WidgetType == widget.Window || tk.node.WidgetType == widget.Stdout) {
// only allow Window or the Stdout widgets to be made active
return false
}
return tk.window.active
}
// always redraws at the corner of the gocuiSize box
func (tk *guiWidget) makeWindowActive() {
if !(tk.node.WidgetType == widget.Window || tk.node.WidgetType == widget.Stdout) {
// only allow Window or the Stdout widgets to be made active
return
}
if tk.node.WidgetType == widget.Stdout {
me.stdout.outputOnTop = true
} else {
// me.stdout.outputOnTop = false // ?
}
// disable and increment all the windows
for _, tk := range me.allwin {
tk.window.order += 1
@ -193,6 +207,9 @@ func (tk *guiWidget) makeWindowActive() {
tk.window.active = true
tk.window.order = 0
tk.redrawWindow(tk.gocuiSize.w0, tk.gocuiSize.h0)
setThingsOnTop() // sets help, Stdout, etc on the top after windows have been redrawn
/*
// print out the window list
for _, tk := range me.allwin {