closer
This commit is contained in:
parent
c5e6c66338
commit
6370d87fc2
|
@ -24,14 +24,12 @@ var currentDrag *guiWidget
|
||||||
// this function uses the mouse position to highlight & unhighlight things
|
// this function uses the mouse position to highlight & unhighlight things
|
||||||
// this is run every time the user moves the mouse over the terminal window
|
// this is run every time the user moves the mouse over the terminal window
|
||||||
func mouseMove(g *gocui.Gui) {
|
func mouseMove(g *gocui.Gui) {
|
||||||
mx, my := g.MousePosition()
|
w, h := g.MousePosition()
|
||||||
|
|
||||||
w := mx
|
|
||||||
h := my
|
|
||||||
|
|
||||||
if me.supermouse {
|
if me.supermouse {
|
||||||
for _, tk := range findByXY(w, h) {
|
for _, tk := range findByXY(w, h) {
|
||||||
tk.dumpWidget("mouseMove()")
|
s := fmt.Sprintf("SM (%3d,%3d)", w, h)
|
||||||
|
tk.dumpWidget(s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +77,7 @@ func mouseMove(g *gocui.Gui) {
|
||||||
for _, view := range g.Views() {
|
for _, view := range g.Views() {
|
||||||
view.Highlight = false
|
view.Highlight = false
|
||||||
}
|
}
|
||||||
if v, err := g.ViewByPosition(mx, my); err == nil {
|
if v, err := g.ViewByPosition(w, h); err == nil {
|
||||||
v.Highlight = true
|
v.Highlight = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,7 +103,7 @@ func (tk *guiWidget) moveNew(g *gocui.Gui) {
|
||||||
log.Info("NOT MOVE FLAG", tk.node.WidgetType)
|
log.Info("NOT MOVE FLAG", tk.node.WidgetType)
|
||||||
}
|
}
|
||||||
tk.dumpWidget("moveNew() on " + tk.cuiName)
|
tk.dumpWidget("moveNew() on " + tk.cuiName)
|
||||||
outputW := 140
|
outputW := 180
|
||||||
outputH := 40
|
outputH := 40
|
||||||
g.SetView("msg", w-xOffset, h-yOffset, w-xOffset+outputW, h-yOffset+outputH+me.FramePadH, 0)
|
g.SetView("msg", w-xOffset, h-yOffset, w-xOffset+outputW, h-yOffset+outputH+me.FramePadH, 0)
|
||||||
me.startOutputW = w - xOffset
|
me.startOutputW = w - xOffset
|
||||||
|
|
17
find.go
17
find.go
|
@ -27,30 +27,31 @@ func findByXY(w int, h int) []*guiWidget {
|
||||||
rootW := me.treeRoot.TK.(*guiWidget)
|
rootW := me.treeRoot.TK.(*guiWidget)
|
||||||
|
|
||||||
// this searches the binary tree recursively (function is right below)
|
// this searches the binary tree recursively (function is right below)
|
||||||
return findByXYreal(rootW, w, h)
|
return rootW.findByXYreal(w, h)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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
|
||||||
// anything that matches is passed back as an array of widgets
|
// anything that matches is passed back as an array of widgets
|
||||||
func findByXYreal(widget *guiWidget, w int, h int) []*guiWidget {
|
func (tk *guiWidget) findByXYreal(w int, h int) []*guiWidget {
|
||||||
var widgets []*guiWidget
|
var widgets []*guiWidget
|
||||||
|
|
||||||
if !widget.Visible() {
|
if !tk.Visible() {
|
||||||
// ignore widgets that are not visible
|
// ignore widgets that are not visible
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// check the location to see if this is under (W,H)
|
// check the location to see if this is under (W,H)
|
||||||
// if it is, return this widget
|
// if it is, return this widget
|
||||||
if (widget.gocuiSize.w0 <= w) && (w <= widget.gocuiSize.w1) &&
|
if (tk.gocuiSize.w0 <= w) && (w <= tk.gocuiSize.w1) &&
|
||||||
(widget.gocuiSize.h0 <= h) && (h <= widget.gocuiSize.h1) {
|
(tk.gocuiSize.h0 <= h) && (h <= tk.gocuiSize.h1) {
|
||||||
widgets = append(widgets, widget)
|
widgets = append(widgets, tk)
|
||||||
// log.Log(GOCUI, "findByXY() found", widget.node.WidgetType, w, h)
|
// log.Log(GOCUI, "findByXY() found", widget.node.WidgetType, w, h)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
tk.verifyRect()
|
||||||
|
|
||||||
// search through the children widgets in the binary tree
|
// search through the children widgets in the binary tree
|
||||||
for _, child := range widget.children {
|
for _, child := range tk.children {
|
||||||
widgets = append(widgets, findByXYreal(child, w, h)...)
|
widgets = append(widgets, child.findByXYreal(w, h)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
return widgets
|
return widgets
|
||||||
|
|
Loading…
Reference in New Issue