From 47b15946de10a75cda026a7317a90d4857b453c8 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sat, 13 Jan 2024 22:02:12 -0600 Subject: work on hiding widgets When widgets are hidden, their state works exactly the same as normal, but updates are not sent to the toolkits Signed-off-by: Jeff Carr --- window.go | 41 ++++++++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 9 deletions(-) (limited to 'window.go') diff --git a/window.go b/window.go index c2e2b38..4bda74e 100644 --- a/window.go +++ b/window.go @@ -18,10 +18,8 @@ func (parent *Node) NewWindow(title string) *Node { newNode.progname = title newNode.value = title - if ! newNode.hidden { - a := newAction(newNode, widget.Add) - sendAction(a) - } + // inform the toolkits + sendAction(newNode, widget.Add) return newNode } @@ -40,26 +38,51 @@ func (parent *Node) RawWindow(title string) *Node { // TODO: should do this recursively func (n *Node) UnDraw() *Node { - if ! n.hidden { - n.Hide() - } + if ! n.Ready() { return n } + n.hidden = true + n.changed = true + + // inform the toolkits + sendAction(n, widget.Delete) return n } // TODO: should do this recursively func (n *Node) Draw() *Node { + if ! n.Ready() { return n } + n.hidden = false + n.changed= true - a := newAction(n, widget.Add) - sendAction(a) + // inform the toolkits + sendAction(n, widget.Add) return n } // 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 } +*/ + +func (n *Node) TestDraw() { + if (n == nil) { + return + } + + // enable and + n.hidden = false + n.changed = true + log.Warn("TestDraw() sending widget.Add", n.id, n.WidgetType, n.progname) + sendAction(n, widget.Add) + + for _, child := range n.children { + child.TestDraw() + } + return +} -- cgit v1.2.3