summaryrefslogtreecommitdiff
path: root/window.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-04-30 14:40:23 -0500
committerJeff Carr <[email protected]>2025-04-30 14:40:23 -0500
commitd5e557190de2e2147f3335309f6ea4b66e72be4f (patch)
tree17c8a3b6069d1750368e1e94adf8742b18ef02a3 /window.go
parent65a18185792e92029eeb85dac79f6f63781fd042 (diff)
it is a tree, but the variable shouldn't be this
Diffstat (limited to 'window.go')
-rw-r--r--window.go67
1 files changed, 42 insertions, 25 deletions
diff --git a/window.go b/window.go
index ef4a804..c30f496 100644
--- a/window.go
+++ b/window.go
@@ -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
}