Compare commits

..

No commits in common. "master" and "v0.0.9" have entirely different histories.

4 changed files with 46 additions and 117 deletions

View File

@ -1,20 +1 @@
# 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

View File

@ -5,71 +5,36 @@ 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
//
// experiments in various options. think about this more. message StringRow {
message ColAttr {
enum VarType {
ANY = 0;
INT = 1;
STRING = 2;
TIME = 3;
DURATION = 4;
BYTES = 5;
}
int32 pad = 1;
int32 width = 2;
bool click = 3;
VarType type = 4;
}
message StringCol {
Widget header = 1; Widget header = 1;
repeated Widget widgets = 2; repeated string vals = 2;
ColAttr attr = 3; repeated Widget widgets = 3;
repeated string vals = 4; // deprecate
} }
message ButtonCol { message ButtonRow {
Widget header = 1; Widget header = 1;
repeated Widget widgets = 2; repeated string vals = 2;
ColAttr attr = 3; repeated Widget widgets = 3;
repeated string vals = 4; // deprecate
} }
message IntCol { message IntRow {
Widget header = 1; Widget header = 1;
repeated Widget widgets = 2; repeated int64 vals = 2;
ColAttr attr = 3; repeated Widget widgets = 3;
repeated int64 vals = 4; // deprecate
} }
message TimeCol { message TimeRow {
Widget header = 1; Widget header = 1;
repeated Widget widgets = 2; repeated google.protobuf.Timestamp vals = 2;
ColAttr attr = 3; repeated Widget widgets = 3;
repeated google.protobuf.Timestamp vals = 4; // deprecate
} }
message BoolCol { message BoolRow {
Widget header = 1; Widget header = 1;
repeated Widget widgets = 2; 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`
@ -78,13 +43,11 @@ message Table { // `autogenpb:
Widget parent = 3; Widget parent = 3;
Widget grid = 4; Widget grid = 4;
repeated string order = 5; repeated string order = 5;
repeated StringCol stringCols = 6; repeated StringRow stringRows = 6;
repeated IntCol intCols = 7; repeated IntRow intRows = 7;
repeated TimeCol timeCols = 8; repeated TimeRow timeRows = 8;
repeated BoolCol boolCols = 9; repeated BoolRow boolRows = 9;
repeated ButtonCol buttonCols = 10; repeated ButtonRow buttonRows = 10;
repeated AnyCol anyCols = 11;
int64 height = 12; // the number of rows
} }
message Tables { // `autogenpb:marshal` message Tables { // `autogenpb:marshal`

View File

@ -1,10 +0,0 @@
// 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
}

View File

@ -7,6 +7,7 @@ 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;
@ -18,37 +19,31 @@ message Location {
int64 y = 2; int64 y = 2;
} }
message Tree { // `autogenpb:marshal`
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;
google.protobuf.Any val = 3; int64 size = 3;
google.protobuf.Any val = 4;
google.protobuf.Any TK = 5;
WidgetType Type = 6; WidgetType Type = 6;
Location location = 7; Location location = 7;
repeated Widget children = 8;
} }
message Widgets { // `autogenpb:marshal` message Widgets { // `autogenpb:marshal`
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; // this never gets used, but it's not worth violating the autogenpb standard 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 Tree tree = 4; // everything is sent from go.wit.com/gui here
} }
//
// Widget names should try to match [Wikipedia Graphical widget]
// TODO: fix autogenpb to look for enum
enum WidgetType { enum WidgetType {
Root = 0; // the master 'root' node of the binary tree Root = 0; // the master 'root' node of the binary tree
Flag = 1; // internal use Flag = 1; // internal use