Compare commits
13 Commits
Author | SHA1 | Date |
---|---|---|
|
d2ad8b348a | |
|
ba36e04edf | |
|
6cfc61f4ad | |
|
eb37c0b449 | |
|
91ff254e25 | |
|
d3832dc7bb | |
|
6e9ac22c12 | |
|
13ffeae213 | |
|
3a51764f51 | |
|
8834548d07 | |
|
4a99fed196 | |
|
56559d9ee1 | |
|
59a796c1af |
8
Makefile
8
Makefile
|
@ -1,4 +1,4 @@
|
||||||
all: clean proto goimports vet
|
all: proto goimports vet
|
||||||
|
|
||||||
redo: clean proto goimports vet
|
redo: clean proto goimports vet
|
||||||
|
|
||||||
|
@ -9,8 +9,12 @@ vet:
|
||||||
goimports:
|
goimports:
|
||||||
goimports -w *.go
|
goimports -w *.go
|
||||||
|
|
||||||
proto:
|
proto: widget.pb.go table.pb.go
|
||||||
|
|
||||||
|
widget.pb.go: widget.proto
|
||||||
autogenpb --proto widget.proto
|
autogenpb --proto widget.proto
|
||||||
|
|
||||||
|
table.pb.go: table.proto
|
||||||
autogenpb --proto table.proto
|
autogenpb --proto table.proto
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
|
19
README.md
19
README.md
|
@ -1 +1,20 @@
|
||||||
# protobuf definition files for the GO gui plugins
|
# protobuf definition files for the GO gui plugins
|
||||||
|
|
||||||
|
Almost all of this code is autogenerated and there
|
||||||
|
are no docs yet. This is an abstraction GUI protobuf
|
||||||
|
that allows any protobuf .proto file to be turned
|
||||||
|
into a spreadsheet and passed to the GO plugin to
|
||||||
|
be displayed to the user.
|
||||||
|
|
||||||
|
The only functions written by hand are the Custom()
|
||||||
|
functions which pass mouse clicks on the spreadsheet
|
||||||
|
cells back to the application.
|
||||||
|
|
||||||
|
Rather than try to read this code,
|
||||||
|
it's better to look at an example
|
||||||
|
application that uses it. (forge, virtigo)
|
||||||
|
|
||||||
|
This code is what is called 'winning'
|
||||||
|
|
||||||
|
-- jcarr 2025/03/23
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
// Code generated by go.wit.com/apps/autogenpb DO NOT EDIT.
|
||||||
|
// This file was autogenerated with autogenpb 0.0.62 2025/02/24_1709_UTC
|
||||||
|
// go install go.wit.com/apps/autogenpb@latest
|
||||||
|
//
|
||||||
|
// define which structs (messages) you want to use in the .proto file
|
||||||
|
// Then sort.pb.go and marshal.pb.go files are autogenerated
|
||||||
|
//
|
||||||
|
// autogenpb uses it and has an example .proto file with instructions
|
||||||
|
//
|
||||||
|
|
||||||
|
package guipb
|
||||||
|
|
||||||
|
import "go.wit.com/log"
|
||||||
|
|
||||||
|
func (pb *Tables) Custom(w *Widget) {
|
||||||
|
log.Info("got to guipb.Custom() for pb", pb.GetUuid(), "widget id", w)
|
||||||
|
if mycustom != nil {
|
||||||
|
mycustom(w)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (pb *Table) Custom(w *Widget) {
|
||||||
|
log.Info("got to guipb.Custom() for pb", pb.GetUuid(), "widget id", w)
|
||||||
|
if mycustom != nil {
|
||||||
|
mycustom(w)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var mycustom func(*Widget)
|
||||||
|
|
||||||
|
func (pb *Table) RegisterCustom(f func(*Widget)) {
|
||||||
|
mycustom = f
|
||||||
|
}
|
97
table.proto
97
table.proto
|
@ -5,43 +5,86 @@ syntax = "proto3";
|
||||||
package gitpb;
|
package gitpb;
|
||||||
|
|
||||||
import "google/protobuf/timestamp.proto"; // Import the well-known type for Timestamp
|
import "google/protobuf/timestamp.proto"; // Import the well-known type for Timestamp
|
||||||
|
import "google/protobuf/any.proto"; // Import the well-known type for Timestamp
|
||||||
import "widget.proto"; // Import the well-known type for Timestamp
|
import "widget.proto"; // Import the well-known type for Timestamp
|
||||||
|
|
||||||
|
//
|
||||||
|
// this code was written this way to make it easy for me
|
||||||
|
// to originally implement and auto generate the needed code
|
||||||
|
// with autogenpb
|
||||||
|
//
|
||||||
|
|
||||||
message StringRow {
|
// experiments in various options. think about this more.
|
||||||
Widget header = 1;
|
|
||||||
repeated string vals = 2;
|
message ColAttr {
|
||||||
repeated Widget widgets = 3;
|
enum VarType {
|
||||||
|
ANY = 0;
|
||||||
|
INT = 1;
|
||||||
|
STRING = 2;
|
||||||
|
TIME = 3;
|
||||||
|
DURATION = 4;
|
||||||
|
BYTES = 5;
|
||||||
}
|
}
|
||||||
|
int32 pad = 1;
|
||||||
message IntRow {
|
int32 width = 2;
|
||||||
Widget header = 1;
|
bool click = 3;
|
||||||
repeated int64 vals = 2;
|
VarType type = 4;
|
||||||
repeated Widget widgets = 3;
|
|
||||||
}
|
}
|
||||||
|
message StringCol {
|
||||||
message TimeRow {
|
|
||||||
Widget header = 1;
|
|
||||||
repeated google.protobuf.Timestamp vals = 2;
|
|
||||||
repeated Widget widgets = 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
message BoolRow {
|
|
||||||
Widget header = 1;
|
Widget header = 1;
|
||||||
repeated Widget widgets = 2;
|
repeated Widget widgets = 2;
|
||||||
|
ColAttr attr = 3;
|
||||||
|
repeated string vals = 4; // deprecate
|
||||||
|
}
|
||||||
|
|
||||||
|
message ButtonCol {
|
||||||
|
Widget header = 1;
|
||||||
|
repeated Widget widgets = 2;
|
||||||
|
ColAttr attr = 3;
|
||||||
|
repeated string vals = 4; // deprecate
|
||||||
|
}
|
||||||
|
|
||||||
|
message IntCol {
|
||||||
|
Widget header = 1;
|
||||||
|
repeated Widget widgets = 2;
|
||||||
|
ColAttr attr = 3;
|
||||||
|
repeated int64 vals = 4; // deprecate
|
||||||
|
}
|
||||||
|
|
||||||
|
message TimeCol {
|
||||||
|
Widget header = 1;
|
||||||
|
repeated Widget widgets = 2;
|
||||||
|
ColAttr attr = 3;
|
||||||
|
repeated google.protobuf.Timestamp vals = 4; // deprecate
|
||||||
|
}
|
||||||
|
|
||||||
|
message BoolCol {
|
||||||
|
Widget header = 1;
|
||||||
|
repeated Widget widgets = 2;
|
||||||
|
ColAttr attr = 3;
|
||||||
|
repeated bool vals = 4; // deprecate
|
||||||
|
}
|
||||||
|
|
||||||
|
message AnyCol {
|
||||||
|
Widget header = 1;
|
||||||
|
repeated Widget widgets = 2;
|
||||||
|
ColAttr attr = 3;
|
||||||
|
repeated google.protobuf.Any vals = 4; // deprecate
|
||||||
}
|
}
|
||||||
|
|
||||||
message Table { // `autogenpb:marshal`
|
message Table { // `autogenpb:marshal`
|
||||||
string title = 1;
|
string uuid = 1;
|
||||||
Widget parent = 2;
|
string title = 2;
|
||||||
Widget grid = 3;
|
Widget parent = 3;
|
||||||
repeated string order = 4;
|
Widget grid = 4;
|
||||||
repeated StringRow StringRows = 5;
|
repeated string order = 5;
|
||||||
repeated IntRow IntRows = 6;
|
repeated StringCol stringCols = 6;
|
||||||
repeated TimeRow TimeRows = 7;
|
repeated IntCol intCols = 7;
|
||||||
repeated BoolRow BoolRows = 8;
|
repeated TimeCol timeCols = 8;
|
||||||
Widget window = 9; // deprecate this
|
repeated BoolCol boolCols = 9;
|
||||||
string uuid = 10;
|
repeated ButtonCol buttonCols = 10;
|
||||||
|
repeated AnyCol anyCols = 11;
|
||||||
|
int64 height = 12; // the number of rows
|
||||||
}
|
}
|
||||||
|
|
||||||
message Tables { // `autogenpb:marshal`
|
message Tables { // `autogenpb:marshal`
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
// Copyright 2025 WIT.COM Inc Licensed GPL 3.0
|
||||||
|
|
||||||
|
package guipb
|
||||||
|
|
||||||
|
func (x *Widget) IsButton() bool {
|
||||||
|
if _, ok := x.GetType().(*Widget_Button); ok {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
56
widget.proto
56
widget.proto
|
@ -7,35 +7,61 @@ package gitpb;
|
||||||
// import "google/protobuf/timestamp.proto"; // Import the well-known type for Timestamp
|
// import "google/protobuf/timestamp.proto"; // Import the well-known type for Timestamp
|
||||||
import "google/protobuf/any.proto"; // Import 'Any'
|
import "google/protobuf/any.proto"; // Import 'Any'
|
||||||
|
|
||||||
|
|
||||||
message Size {
|
message Size {
|
||||||
int64 width = 1;
|
int64 width = 1;
|
||||||
int64 height = 2;
|
int64 height = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// used for grid layouts
|
||||||
message Location {
|
message Location {
|
||||||
int64 x = 1;
|
int64 x = 1;
|
||||||
int64 y = 2;
|
int64 y = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
message Tree {
|
|
||||||
Widget parent = 1;
|
|
||||||
repeated Widget children = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
message Widget {
|
message Widget {
|
||||||
|
message Internal {
|
||||||
|
string progName = 1;
|
||||||
|
}
|
||||||
|
message Standard {
|
||||||
|
string progName = 1;
|
||||||
|
string name = 2;
|
||||||
|
}
|
||||||
|
oneof type {
|
||||||
|
Internal root = 9;
|
||||||
|
Standard button = 10;
|
||||||
|
Standard window = 11;
|
||||||
|
Standard tab = 12;
|
||||||
|
Standard checkbox = 13;
|
||||||
|
bytes tablePB = 14;
|
||||||
|
Standard textbox = 15;
|
||||||
|
}
|
||||||
int64 id = 1;
|
int64 id = 1;
|
||||||
string name = 2;
|
string name = 2;
|
||||||
int64 size = 3;
|
google.protobuf.Any val = 3;
|
||||||
google.protobuf.Any val = 4;
|
WidgetType Type = 6;
|
||||||
// Size size = 3;
|
Location location = 7;
|
||||||
// Location location = 4;
|
repeated Widget children = 8;
|
||||||
// string color = 5;
|
|
||||||
// google.protobuf.Any TK = 6;
|
|
||||||
}
|
}
|
||||||
|
message Widgets { // `autogenpb:marshal`
|
||||||
message Widgets {
|
|
||||||
string uuid = 1; // `autogenpb:uuid:0331fcd7-3c8c-43e4-be1b-77db6a6bc58c`
|
string uuid = 1; // `autogenpb:uuid:0331fcd7-3c8c-43e4-be1b-77db6a6bc58c`
|
||||||
string version = 2; // `autogenpb:version:v1`
|
string version = 2; // `autogenpb:version:v1`
|
||||||
repeated Widget Widgets = 3;
|
repeated Widget Widgets = 3; // this never gets used, but it's not worth violating the autogenpb standard
|
||||||
|
Widget tree = 4; // everything is sent from go.wit.com/gui here
|
||||||
|
}
|
||||||
|
|
||||||
|
enum WidgetType {
|
||||||
|
Root = 0; // the master 'root' node of the binary tree
|
||||||
|
Flag = 1; // internal use
|
||||||
|
Window = 2; //
|
||||||
|
Tab = 3; // a tab like in firefox
|
||||||
|
Box = 4; // must be either Vertical or Horizontal arrangment
|
||||||
|
Group = 5; // think 'Appetizers' on a restaurant menu
|
||||||
|
Grid = 6; // like drawers in a chest or post office boxes
|
||||||
|
Button = 7; // user can click on this
|
||||||
|
Checkbox = 8; // true or false
|
||||||
|
Dropdown = 9; //
|
||||||
|
Combobox = 10; // a dropdown menu that can be edited by the user
|
||||||
|
Label = 11; // a simple label
|
||||||
|
Textbox = 12; // enter text
|
||||||
|
TablePB = 13; // special case to allow the arbitrary GUI display of any other protobuf
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue