diff options
| author | Jeff Carr <[email protected]> | 2025-01-29 07:31:26 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-01-29 12:27:10 -0600 |
| commit | ce11f999f9282e9489e77eb1f9d6c08ae9c9b725 (patch) | |
| tree | 33ae6c702d91c5eddfe4ecd0be68bf907733a394 | |
| parent | a16b53c2895669f7f21728334371ab79680699bf (diff) | |
start moving to protobuf. fix mouse clicks (kinda)
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | Makefile | 7 | ||||
| -rw-r--r-- | click.go | 22 | ||||
| -rw-r--r-- | main.go | 1 | ||||
| -rw-r--r-- | view.proto | 41 |
5 files changed, 66 insertions, 6 deletions
@@ -1,5 +1,6 @@ *.swp *.so +*.pb.go go.mod go.sum gocui @@ -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 @@ -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 } @@ -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 ( diff --git a/view.proto b/view.proto new file mode 100644 index 0000000..eeea1c4 --- /dev/null +++ b/view.proto @@ -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; +} |
