closer to mouse drag not being annoyingly wrong
This commit is contained in:
parent
d5d0262013
commit
ac9c6617e3
|
@ -23,15 +23,20 @@ func mouseUp(g *gocui.Gui, v *gocui.View) error {
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
log.Info("mouseUp() setting me.globalMouseDown = false")
|
||||||
|
me.globalMouseDown = false
|
||||||
|
|
||||||
dropdownUnclicked(w, h)
|
dropdownUnclicked(w, h)
|
||||||
|
|
||||||
if msgMouseDown {
|
/*
|
||||||
log.Info("setting mousedown to false")
|
if msgMouseDown {
|
||||||
msgMouseDown = false
|
log.Info("setting mousedown to false")
|
||||||
} else if globalMouseDown {
|
msgMouseDown = false
|
||||||
globalMouseDown = false
|
} else if globalMouseDown {
|
||||||
g.DeleteView("globalDown")
|
globalMouseDown = false
|
||||||
}
|
g.DeleteView("globalDown")
|
||||||
|
}
|
||||||
|
*/
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,6 +45,7 @@ func mouseUp(g *gocui.Gui, v *gocui.View) error {
|
||||||
// the right response for the toolkit user's app
|
// the right response for the toolkit user's app
|
||||||
func mouseDown(g *gocui.Gui, v *gocui.View) error {
|
func mouseDown(g *gocui.Gui, v *gocui.View) error {
|
||||||
mx, my := g.MousePosition()
|
mx, my := g.MousePosition()
|
||||||
|
me.globalMouseDown = true
|
||||||
|
|
||||||
var found bool = false
|
var found bool = false
|
||||||
for _, tk := range findByXY(mx, my) {
|
for _, tk := range findByXY(mx, my) {
|
||||||
|
@ -85,7 +91,6 @@ func mouseDown(g *gocui.Gui, v *gocui.View) error {
|
||||||
return msgDown(g, v)
|
return msgDown(g, v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
globalMouseDown = true
|
|
||||||
|
|
||||||
maxX, _ := g.Size()
|
maxX, _ := g.Size()
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ func mouseMove(g *gocui.Gui) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if msgMouseDown {
|
if me.globalMouseDown {
|
||||||
// log.Info("msgMouseDown == true")
|
// log.Info("msgMouseDown == true")
|
||||||
// plugin will segfault if you don't keep this inside a check for msgMouseDown
|
// plugin will segfault if you don't keep this inside a check for msgMouseDown
|
||||||
// don't move this code out of here
|
// don't move this code out of here
|
||||||
|
@ -75,13 +75,16 @@ func (tk *guiWidget) moveNew(g *gocui.Gui) {
|
||||||
if tk.node.WidgetType == widget.Label {
|
if tk.node.WidgetType == widget.Label {
|
||||||
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)
|
||||||
|
outputW, outputH := tk.Size()
|
||||||
g.SetView(tk.cuiName, w-xOffset, h-yOffset, w-xOffset+outputW, h-yOffset+outputH+me.FramePadH, 0)
|
g.SetView(tk.cuiName, w-xOffset, h-yOffset, w-xOffset+outputW, h-yOffset+outputH+me.FramePadH, 0)
|
||||||
me.startOutputW = w - xOffset
|
me.startOutputW = w - xOffset
|
||||||
me.startOutputH = h - yOffset
|
me.startOutputH = h - yOffset
|
||||||
g.SetViewOnBottom(tk.cuiName)
|
// g.SetViewOnBottom(tk.cuiName)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
tk.dumpWidget("moveNew() on " + tk.cuiName)
|
tk.dumpWidget("moveNew() on " + tk.cuiName)
|
||||||
|
outputW := 140
|
||||||
|
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
|
||||||
me.startOutputH = h - yOffset
|
me.startOutputH = h - yOffset
|
||||||
|
|
2
place.go
2
place.go
|
@ -192,6 +192,8 @@ func (w *guiWidget) placeGrid(startW int, startH int) (int, int) {
|
||||||
func (w *guiWidget) realGocuiSize() *rectType {
|
func (w *guiWidget) realGocuiSize() *rectType {
|
||||||
var f func(tk *guiWidget, r *rectType)
|
var f func(tk *guiWidget, r *rectType)
|
||||||
newR := new(rectType)
|
newR := new(rectType)
|
||||||
|
|
||||||
|
outputW, outputH := w.Size()
|
||||||
// initialize the values to opposite
|
// initialize the values to opposite
|
||||||
newR.w0 = outputW
|
newR.w0 = outputW
|
||||||
newR.h0 = outputH
|
newR.h0 = outputH
|
||||||
|
|
|
@ -13,9 +13,6 @@ import (
|
||||||
"go.wit.com/widget"
|
"go.wit.com/widget"
|
||||||
)
|
)
|
||||||
|
|
||||||
var outputW int = 180
|
|
||||||
var outputH int = 40
|
|
||||||
|
|
||||||
func showMsg(g *gocui.Gui, v *gocui.View) error {
|
func showMsg(g *gocui.Gui, v *gocui.View) error {
|
||||||
var l string
|
var l string
|
||||||
var err error
|
var err error
|
||||||
|
@ -39,6 +36,9 @@ func showMsg(g *gocui.Gui, v *gocui.View) error {
|
||||||
func makeOutputWidget(g *gocui.Gui, stringFromMouseClick string) *gocui.View {
|
func makeOutputWidget(g *gocui.Gui, stringFromMouseClick string) *gocui.View {
|
||||||
maxX, maxY := g.Size()
|
maxX, maxY := g.Size()
|
||||||
|
|
||||||
|
var outputW int = 180
|
||||||
|
var outputH int = 40
|
||||||
|
|
||||||
if me.treeRoot == nil {
|
if me.treeRoot == nil {
|
||||||
// keep skipping this until the binary tree is initialized
|
// keep skipping this until the binary tree is initialized
|
||||||
return nil
|
return nil
|
||||||
|
|
66
structs.go
66
structs.go
|
@ -40,42 +40,43 @@ type config struct {
|
||||||
startOutputH int // ?
|
startOutputH int // ?
|
||||||
helpLabel *gocui.View // ?
|
helpLabel *gocui.View // ?
|
||||||
// dropdownV *guiWidget // this is a floating widget that we show whenever the user clicks on a
|
// dropdownV *guiWidget // this is a floating widget that we show whenever the user clicks on a
|
||||||
dropdownW *guiWidget // grab the dropdown choices from this widget
|
dropdownW *guiWidget // grab the dropdown choices from this widget
|
||||||
FramePadW int `default:"1" dense:"0"` // When the widget has a frame, like a button, it adds 2 lines runes on each side
|
FramePadW int `default:"1" dense:"0"` // When the widget has a frame, like a button, it adds 2 lines runes on each side
|
||||||
FramePadH int `default:"1" dense:"0"` // When the widget has a frame, like a button, it adds 2 lines runes on each side
|
FramePadH int `default:"1" dense:"0"` // When the widget has a frame, like a button, it adds 2 lines runes on each side
|
||||||
PadW int `default:"1" dense:"0"` // pad spacing
|
PadW int `default:"1" dense:"0"` // pad spacing
|
||||||
PadH int `default:"1" dense:"0"` // pad spacing
|
PadH int `default:"1" dense:"0"` // pad spacing
|
||||||
WindowW int `default:"8" dense:"0"` // how far down to start Window or Tab headings
|
WindowW int `default:"8" dense:"0"` // how far down to start Window or Tab headings
|
||||||
WindowH int `default:"-1"` // how far down to start Window or Tab headings
|
WindowH int `default:"-1"` // how far down to start Window or Tab headings
|
||||||
TabW int `default:"5" dense:"0"` // how far down to start Window or Tab headings
|
TabW int `default:"5" dense:"0"` // how far down to start Window or Tab headings
|
||||||
TabH int `default:"1" dense:"0"` // how far down to start Window or Tab headings
|
TabH int `default:"1" dense:"0"` // how far down to start Window or Tab headings
|
||||||
WindowPadW int `default:"8" dense:"0"` // additional amount of space to put between window & tab widgets
|
WindowPadW int `default:"8" dense:"0"` // additional amount of space to put between window & tab widgets
|
||||||
TabPadW int `default:"4" dense:"0"` // additional amount of space to put between window & tab widgets
|
TabPadW int `default:"4" dense:"0"` // additional amount of space to put between window & tab widgets
|
||||||
GroupPadW int `default:"2" dense:"1"` // additional amount of space to indent on a group
|
GroupPadW int `default:"2" dense:"1"` // additional amount of space to indent on a group
|
||||||
BoxPadW int `default:"2" dense:"1"` // additional amount of space to indent on a box
|
BoxPadW int `default:"2" dense:"1"` // additional amount of space to indent on a box
|
||||||
GridPadW int `default:"2" dense:"1"` // additional amount of space to indent on a grid
|
GridPadW int `default:"2" dense:"1"` // additional amount of space to indent on a grid
|
||||||
RawW int `default:"1"` // the raw beginning of each window (or tab)
|
RawW int `default:"1"` // the raw beginning of each window (or tab)
|
||||||
RawH int `default:"5"` // the raw beginning of each window (or tab)
|
RawH int `default:"5"` // the raw beginning of each window (or tab)
|
||||||
FakeW int `default:"20"` // offset for the hidden widgets
|
FakeW int `default:"20"` // offset for the hidden widgets
|
||||||
padded bool // add space between things like buttons
|
padded bool // add space between things like buttons
|
||||||
bookshelf bool // do you want things arranged in the box like a bookshelf or a stack?
|
bookshelf bool // do you want things arranged in the box like a bookshelf or a stack?
|
||||||
canvas bool // if set to true, the windows are a raw canvas
|
canvas bool // if set to true, the windows are a raw canvas
|
||||||
menubar bool // for windows
|
menubar bool // for windows
|
||||||
stretchy bool // expand things like buttons to the maximum size
|
stretchy bool // expand things like buttons to the maximum size
|
||||||
margin bool // add space around the frames of windows
|
margin bool // add space around the frames of windows
|
||||||
writeMutex sync.Mutex // writeMutex protects writes to *guiWidget (it's global right now maybe)
|
writeMutex sync.Mutex // writeMutex protects writes to *guiWidget (it's global right now maybe)
|
||||||
fakefile *FakeFile // JUNK? used to attempt to write to the stdout window
|
fakefile *FakeFile // JUNK? used to attempt to write to the stdout window
|
||||||
dtoggle bool // is a dropdown or combobox currently active?
|
dtoggle bool // is a dropdown or combobox currently active?
|
||||||
showHelp bool // toggle boolean for the help menu (deprecate?)
|
showHelp bool // toggle boolean for the help menu (deprecate?)
|
||||||
ecount int // counts how many mouse and keyboard events have occurred
|
ecount int // counts how many mouse and keyboard events have occurred
|
||||||
supermouse bool // prints out every widget found while you move the mouse around
|
supermouse bool // prints out every widget found while you move the mouse around
|
||||||
depth int // used for listWidgets() debugging
|
depth int // used for listWidgets() debugging
|
||||||
|
globalMouseDown bool // yep, mouse is pressed
|
||||||
}
|
}
|
||||||
|
|
||||||
// deprecate these
|
// deprecate these
|
||||||
var (
|
var (
|
||||||
initialMouseX, initialMouseY, xOffset, yOffset int
|
initialMouseX, initialMouseY, xOffset, yOffset int
|
||||||
globalMouseDown, msgMouseDown bool
|
msgMouseDown bool
|
||||||
)
|
)
|
||||||
|
|
||||||
// this is the gocui way
|
// this is the gocui way
|
||||||
|
@ -131,6 +132,9 @@ func (w *guiWidget) Write(p []byte) (n int, err error) {
|
||||||
me.writeMutex.Lock()
|
me.writeMutex.Lock()
|
||||||
defer me.writeMutex.Unlock()
|
defer me.writeMutex.Unlock()
|
||||||
|
|
||||||
|
// _, outputH := w.Size()
|
||||||
|
outputH := 33 // special output length for "msg" window until I figure things out
|
||||||
|
|
||||||
tk := me.logStdout
|
tk := me.logStdout
|
||||||
if tk.v == nil {
|
if tk.v == nil {
|
||||||
// optionally write the output to /tmp
|
// optionally write the output to /tmp
|
||||||
|
|
Loading…
Reference in New Issue