diff options
| author | Jeff Carr <[email protected]> | 2025-04-30 14:40:23 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-04-30 14:40:23 -0500 |
| commit | d5e557190de2e2147f3335309f6ea4b66e72be4f (patch) | |
| tree | 17c8a3b6069d1750368e1e94adf8742b18ef02a3 | |
| parent | 65a18185792e92029eeb85dac79f6f63781fd042 (diff) | |
it is a tree, but the variable shouldn't be this
| -rw-r--r-- | node.go | 2 | ||||
| -rw-r--r-- | structs.go | 10 | ||||
| -rw-r--r-- | table.go | 36 | ||||
| -rw-r--r-- | window.go | 67 |
4 files changed, 55 insertions, 60 deletions
@@ -94,7 +94,7 @@ func (parent *Node) Append(n *Node) { n.widget = new(guipb.Widget) } n.widget.Id = int64(n.id) - n.widget.Type = n.TypePB() + // n.widget.Type = n.TypePB() } func (n *Node) TypePB() guipb.WidgetType { @@ -29,11 +29,11 @@ type guiConfig struct { // a toolkit requirement. never allow more than one per program initOnce sync.Once - rootNode *Node // This is the master node. The Binary Tree starts here - tree *guipb.Tree // the protobuf. switch to this. deprecate rootNode - widgets *guipb.Widgets // don't use this I think - counter int // used to make unique WidgetId's - tables []*guipb.Tables // a list of active protobuf tables + rootNode *Node // This is the master node. The Binary Tree starts here + // tree *guipb.Tree // the protobuf. switch to this. deprecate rootNode + widgets *guipb.Widgets // don't use this I think + counter int // used to make unique WidgetId's + tables []*guipb.Tables // a list of active protobuf tables // sets the chan for the plugins to call back too guiChan chan widget.Action @@ -10,36 +10,9 @@ import ( "go.wit.com/log" "go.wit.com/widget" "google.golang.org/protobuf/types/known/anypb" + "google.golang.org/protobuf/types/known/wrapperspb" ) -/* -// makes a grid inside an existing Widget -func (n *Node) NewTable(title string) *NodeTable { - t := new(NodeTable) - - t.grid = n.RawGrid().SetProgName("PB GRID") - - t.tb = t.grid.newNode(title, widget.Table) - t.tb.label = title - - return t -} - -type NodeColumn struct { - Title string - Vals []string -} - -type NodeTable struct { - grid *Node - tb *Node - Custom func() -} - -func (parent *Node) ShowTableCallback(pb *guipb.Table, f func(id int)) { -} -*/ - func (n *Node) findInTablePB(pb *guipb.Table, id int) *guipb.Widget { if n.tablepb == nil { log.Info("SOMETHING WAS WRONG. gui.findInTablePB() n.tablepb == nil for widget id", id) @@ -331,7 +304,12 @@ func (parent *Node) makeTableGrid(pb *guipb.Table) *Node { pbwidget := new(guipb.Widget) pbwidget.Id = int64(label.id) - pbwidget.Size = v + anyValue, err := anypb.New(wrapperspb.Int64(v)) + if err != nil { + log.Info("gui: failed to add time", err) + continue + } + pbwidget.Val = anyValue r.Widgets = append(r.Widgets, pbwidget) // log.Info("gui: added new int", pbwidget) } @@ -1,6 +1,7 @@ package gui import ( + "go.wit.com/lib/protobuf/guipb" "go.wit.com/log" "go.wit.com/widget" ) @@ -60,46 +61,49 @@ func (parent *Node) RawWindow(title string) *Node { return newNode } -/* -// TODO: should do this recursively -func (n *Node) UnDraw() *Node { +// TODO: send protobuf +func (n *Node) Draw() *Node { if !n.Ready() { return n } - n.hidden = true + n.hidden = false n.changed = true // inform the toolkits - sendAction(n, widget.Delete) + sendAction(n, widget.Add) return n } -*/ - -// TODO: should do this recursively (on a window only) -func (n *Node) Draw() *Node { - if !n.Ready() { - return n - } +func (n *Node) TestDrawPB(pb bool) { + n.visable = true n.hidden = false n.changed = true - // inform the toolkits - sendAction(n, widget.Add) - return n -} + if !pb { + log.Log(NOW, "TestDrawPB() using TestDraw()") + n.TestDraw() + return + } -// if the toolkit supports a gui with pixels, it might honor this. no promises -// consider this a 'recommendation' or developer 'preference' to the toolkit -/* -func (n *Node) PixelSize(w, h int) *Node { - n.width = w - n.height = w - return n + widgets := guipb.NewWidgets() + n.makePB(widgets.Tree) + + a := getNewAction(me.rootNode, widget.Show) + + a.WidgetPB, err = widgets.Marshal() + if err != nil { + log.Log(WARN, "unmarshal error", err) + return + } + + log.Log(NOW, "TestDrawPB() start") + sendActionToPlugin(a) + log.Log(NOW, "TestDrawPB() end") + return } -*/ +// TODO: remove this after switching to protobuf // when a window is redrawn, every widget in the window // needs to be sent to the toolkit func (n *Node) TestDraw() { @@ -118,6 +122,20 @@ func (n *Node) TestDraw() { return } +func (n *Node) makePB(parent *guipb.Widget) *guipb.Widget { + w := new(guipb.Widget) + w.Id = int64(n.id) + w.Name = n.label + + parent.Children = append(parent.Children, w) + + for _, child := range n.children { + w.Children = append(w.Children, child.makePB(w)) + } + + return w +} + func (n *Node) TestPB() { if n == nil { return @@ -133,6 +151,5 @@ func (n *Node) TestPB() { return } sendActionToPlugin(a) - return } |
