From 1cb395d4e29239a6d0c50ff37e16c143844dac75 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Fri, 21 Feb 2025 05:41:54 -0600 Subject: start thinking about a raw grid widget --- Makefile | 2 +- table.go | 30 ++++++++++++++++++++++-------- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 83bbf8d..1728c7c 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ all: @echo "It creates a binary tree of widgets (Windows, Buttons, etc)" @echo "This is the interface to the GUI GO plugin (ncurses, GTK, etc)" @echo - @echo "todo: rewrite this using protobufs" + @echo "note: Feb 2025. this is experimental. being rewritten to use protobufs" @echo @make goimports vet diff --git a/table.go b/table.go index ee2eb94..df499b8 100644 --- a/table.go +++ b/table.go @@ -53,14 +53,27 @@ func RefreshTime(t *time.Duration) { } */ -func NewTable(title string) *NodeTable { +// shortcut. makes a window with just a grid in it +func NewTableWindow(title string) *NodeTable { t := new(NodeTable) /* t.pb = new(guipb.Table) t.pb.Title = title */ - t.n = me.rootNode.newNode(title, widget.Table) - t.n.label = title + t.tb = me.rootNode.newNode(title, widget.Table) + t.tb.label = title + + return t +} + +// makes a grid inside an existing Widget +func (n *Node) NewTable(title string) *NodeTable { + t := new(NodeTable) + + t.grid = n.RawGrid() + + t.tb = t.grid.newNode(title, widget.Table) + t.tb.label = title return t } @@ -71,8 +84,9 @@ type NodeColumn struct { } type NodeTable struct { - n *Node - // pb *guipb.Table + grid *Node + tb *Node + Custom func() } func ShowTable(pb *guipb.Table) { @@ -130,7 +144,7 @@ func makeTableWidgets(pb *guipb.Table) { pbwidget.Id = int64(label.id) pbwidget.Name = v r.Widgets = append(r.Widgets, pbwidget) - log.Info("gui: added new string", pbwidget) + // log.Info("gui: added new string", pbwidget) } } @@ -144,7 +158,7 @@ func makeTableWidgets(pb *guipb.Table) { pbwidget.Id = int64(label.id) pbwidget.Size = v r.Widgets = append(r.Widgets, pbwidget) - log.Info("gui: added new int", pbwidget) + // log.Info("gui: added new int", pbwidget) } } @@ -163,7 +177,7 @@ func makeTableWidgets(pb *guipb.Table) { } pbwidget.Val = anyValue r.Widgets = append(r.Widgets, pbwidget) - log.Info("gui: added new val", pbwidget) + // log.Info("gui: added new val", pbwidget) } } } -- cgit v1.2.3