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)
|
||||
|
||||
if msgMouseDown {
|
||||
log.Info("setting mousedown to false")
|
||||
msgMouseDown = false
|
||||
} else if globalMouseDown {
|
||||
globalMouseDown = false
|
||||
g.DeleteView("globalDown")
|
||||
}
|
||||
/*
|
||||
if msgMouseDown {
|
||||
log.Info("setting mousedown to false")
|
||||
msgMouseDown = false
|
||||
} else if globalMouseDown {
|
||||
globalMouseDown = false
|
||||
g.DeleteView("globalDown")
|
||||
}
|
||||
*/
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -40,6 +45,7 @@ func mouseUp(g *gocui.Gui, v *gocui.View) error {
|
|||
// the right response for the toolkit user's app
|
||||
func mouseDown(g *gocui.Gui, v *gocui.View) error {
|
||||
mx, my := g.MousePosition()
|
||||
me.globalMouseDown = true
|
||||
|
||||
var found bool = false
|
||||
for _, tk := range findByXY(mx, my) {
|
||||
|
@ -85,7 +91,6 @@ func mouseDown(g *gocui.Gui, v *gocui.View) error {
|
|||
return msgDown(g, v)
|
||||
}
|
||||
}
|
||||
globalMouseDown = true
|
||||
|
||||
maxX, _ := g.Size()
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ func mouseMove(g *gocui.Gui) {
|
|||
}
|
||||
}
|
||||
|
||||
if msgMouseDown {
|
||||
if me.globalMouseDown {
|
||||
// log.Info("msgMouseDown == true")
|
||||
// plugin will segfault if you don't keep this inside a check for msgMouseDown
|
||||
// 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 {
|
||||
s := fmt.Sprintf("move(%dx%d) %s ###", w, h, tk.cuiName)
|
||||
tk.dumpWidget(s)
|
||||
outputW, outputH := tk.Size()
|
||||
g.SetView(tk.cuiName, w-xOffset, h-yOffset, w-xOffset+outputW, h-yOffset+outputH+me.FramePadH, 0)
|
||||
me.startOutputW = w - xOffset
|
||||
me.startOutputH = h - yOffset
|
||||
g.SetViewOnBottom(tk.cuiName)
|
||||
// g.SetViewOnBottom(tk.cuiName)
|
||||
return
|
||||
}
|
||||
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)
|
||||
me.startOutputW = w - xOffset
|
||||
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 {
|
||||
var f func(tk *guiWidget, r *rectType)
|
||||
newR := new(rectType)
|
||||
|
||||
outputW, outputH := w.Size()
|
||||
// initialize the values to opposite
|
||||
newR.w0 = outputW
|
||||
newR.h0 = outputH
|
||||
|
|
|
@ -13,9 +13,6 @@ import (
|
|||
"go.wit.com/widget"
|
||||
)
|
||||
|
||||
var outputW int = 180
|
||||
var outputH int = 40
|
||||
|
||||
func showMsg(g *gocui.Gui, v *gocui.View) error {
|
||||
var l string
|
||||
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 {
|
||||
maxX, maxY := g.Size()
|
||||
|
||||
var outputW int = 180
|
||||
var outputH int = 40
|
||||
|
||||
if me.treeRoot == nil {
|
||||
// keep skipping this until the binary tree is initialized
|
||||
return nil
|
||||
|
|
66
structs.go
66
structs.go
|
@ -40,42 +40,43 @@ type config struct {
|
|||
startOutputH int // ?
|
||||
helpLabel *gocui.View // ?
|
||||
// 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
|
||||
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
|
||||
PadW 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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
RawW int `default:"1"` // 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
|
||||
padded bool // add space between things like buttons
|
||||
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
|
||||
menubar bool // for windows
|
||||
stretchy bool // expand things like buttons to the maximum size
|
||||
margin bool // add space around the frames of windows
|
||||
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
|
||||
dtoggle bool // is a dropdown or combobox currently active?
|
||||
showHelp bool // toggle boolean for the help menu (deprecate?)
|
||||
ecount int // counts how many mouse and keyboard events have occurred
|
||||
supermouse bool // prints out every widget found while you move the mouse around
|
||||
depth int // used for listWidgets() debugging
|
||||
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
|
||||
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
|
||||
PadH int `default:"1" dense:"0"` // pad spacing
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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)
|
||||
RawH int `default:"5"` // the raw beginning of each window (or tab)
|
||||
FakeW int `default:"20"` // offset for the hidden widgets
|
||||
padded bool // add space between things like buttons
|
||||
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
|
||||
menubar bool // for windows
|
||||
stretchy bool // expand things like buttons to the maximum size
|
||||
margin bool // add space around the frames of windows
|
||||
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
|
||||
dtoggle bool // is a dropdown or combobox currently active?
|
||||
showHelp bool // toggle boolean for the help menu (deprecate?)
|
||||
ecount int // counts how many mouse and keyboard events have occurred
|
||||
supermouse bool // prints out every widget found while you move the mouse around
|
||||
depth int // used for listWidgets() debugging
|
||||
globalMouseDown bool // yep, mouse is pressed
|
||||
}
|
||||
|
||||
// deprecate these
|
||||
var (
|
||||
initialMouseX, initialMouseY, xOffset, yOffset int
|
||||
globalMouseDown, msgMouseDown bool
|
||||
msgMouseDown bool
|
||||
)
|
||||
|
||||
// this is the gocui way
|
||||
|
@ -131,6 +132,9 @@ func (w *guiWidget) Write(p []byte) (n int, err error) {
|
|||
me.writeMutex.Lock()
|
||||
defer me.writeMutex.Unlock()
|
||||
|
||||
// _, outputH := w.Size()
|
||||
outputH := 33 // special output length for "msg" window until I figure things out
|
||||
|
||||
tk := me.logStdout
|
||||
if tk.v == nil {
|
||||
// optionally write the output to /tmp
|
||||
|
|
Loading…
Reference in New Issue