start moving to protobuf. fix mouse clicks (kinda)
This commit is contained in:
parent
a16b53c289
commit
ce11f999f9
|
@ -1,5 +1,6 @@
|
|||
*.swp
|
||||
*.so
|
||||
*.pb.go
|
||||
go.mod
|
||||
go.sum
|
||||
gocui
|
||||
|
|
7
Makefile
7
Makefile
|
@ -4,7 +4,7 @@ BUILDTIME = $(shell date +%Y.%m.%d)
|
|||
all: clean gocui.so
|
||||
@#ldd gocui.so
|
||||
|
||||
gocui.so:
|
||||
gocui.so: view.pb.go goimports
|
||||
GO111MODULE=off go build -v -work -buildmode=plugin -o gocui.so \
|
||||
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
|
||||
|
||||
|
@ -20,6 +20,8 @@ custom:
|
|||
|
||||
clean:
|
||||
rm -f gocui gocui.so
|
||||
rm -f *.pb.go
|
||||
go-mod-clean --purge
|
||||
|
||||
# Test the README.md & doc.go file
|
||||
# this runs pkgsite, the binary that does dev.go.dev
|
||||
|
@ -41,3 +43,6 @@ redomod:
|
|||
rm -f go.*
|
||||
GO111MODULE= go mod init
|
||||
GO111MODULE= go mod tidy
|
||||
|
||||
view.pb.go: view.proto
|
||||
autogenpb --proto view.proto
|
||||
|
|
22
click.go
22
click.go
|
@ -112,10 +112,10 @@ func (w *guiWidget) doWidgetClick() {
|
|||
func click(g *gocui.Gui, v *gocui.View) error {
|
||||
mouseW, mouseH := me.baseGui.MousePosition()
|
||||
|
||||
log.Log(GOCUI, "click() START gocui name:", v.Name())
|
||||
log.Log(GOCUI, "click() START gocui name:", v.Name(), mouseW, mouseH)
|
||||
w := findUnderMouse()
|
||||
|
||||
// if the dropdown view is visable, process it no matter what
|
||||
// if the dropdown view is visible, process it no matter what
|
||||
if me.dropdownV.Visible() {
|
||||
me.dropdownV.dropdownClicked(mouseW, mouseH)
|
||||
}
|
||||
|
@ -183,8 +183,8 @@ func findUnderMouse() *guiWidget {
|
|||
rootW := me.treeRoot.TK.(*guiWidget)
|
||||
f(rootW)
|
||||
|
||||
// search through all the widgets that were below the mouse click
|
||||
var found *guiWidget
|
||||
// widgets has everything that matches
|
||||
for _, w := range widgets {
|
||||
// prioritize window buttons. This means if some code covers
|
||||
// up the window widgets, then it will ignore everything else
|
||||
|
@ -193,9 +193,23 @@ func findUnderMouse() *guiWidget {
|
|||
if w.WidgetType == widget.Window {
|
||||
return w
|
||||
}
|
||||
// w.showWidgetPlacement("findUnderMouse() FOUND")
|
||||
}
|
||||
|
||||
// return anything else that is interactive
|
||||
for _, w := range widgets {
|
||||
if w.WidgetType == widget.Button {
|
||||
return w
|
||||
}
|
||||
if w.WidgetType == widget.Combobox {
|
||||
return w
|
||||
}
|
||||
if w.WidgetType == widget.Checkbox {
|
||||
return w
|
||||
}
|
||||
w.showWidgetPlacement("findUnderMouse() found something unknown")
|
||||
found = w
|
||||
}
|
||||
// maybe something else was found
|
||||
return found
|
||||
}
|
||||
|
||||
|
|
1
main.go
1
main.go
|
@ -4,7 +4,6 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package main;
|
||||
|
||||
import "google/protobuf/timestamp.proto"; // Import the well-known type for Timestamp
|
||||
|
||||
// maybe put all the gocui specific stuff here.
|
||||
message GocuiState { // `autogenpb:nomutex`
|
||||
bool visible = 1;
|
||||
bool internal = 2;
|
||||
int64 w0 = 3;
|
||||
int64 h0 = 4;
|
||||
int64 w1 = 5;
|
||||
int64 h1 = 6;
|
||||
}
|
||||
|
||||
message ViewSettings { // `autogenpb:nomutex`
|
||||
bool pack = 1;
|
||||
int64 framesize = 5;
|
||||
}
|
||||
|
||||
message Tree {
|
||||
View parent = 1;
|
||||
repeated View children = 2;
|
||||
}
|
||||
|
||||
// this is the gocui 'view' in binary tree form
|
||||
message View {
|
||||
int64 widgetId = 3; // `autogenpb:unique` `autogenpb:sort`
|
||||
string name = 4; // `autogenpb:unique` `autogenpb:sort`
|
||||
GocuiState state = 7;
|
||||
}
|
||||
|
||||
message Views { // `autogenpb:marshal` `autogenpb:mutex`
|
||||
string uuid = 1; // `autogenpb:uuid:d19c1fbb-32c2-4957-aee6-f8128a511dca`
|
||||
string version = 2; // `autogenpb:version:v0.0.1`
|
||||
repeated View Views = 3;
|
||||
Tree tree = 4;
|
||||
map<string, string> junk = 5;
|
||||
ViewSettings settings = 6;
|
||||
}
|
Loading…
Reference in New Issue