summaryrefslogtreecommitdiff
path: root/action.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-02-05 12:26:05 -0600
committerJeff Carr <[email protected]>2024-02-05 12:26:05 -0600
commit3f54db0421ccb712cd8ce63ee94ad4898f0b8995 (patch)
treee218bcc7d40d537398019b322363491c617c7ea9 /action.go
parent2b3296fd5663398d425b1ba7059aa112c28c0bc8 (diff)
refactor to new tree functionsv0.20.1
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'action.go')
-rw-r--r--action.go127
1 files changed, 71 insertions, 56 deletions
diff --git a/action.go b/action.go
index 4bbdf1a..d2ea570 100644
--- a/action.go
+++ b/action.go
@@ -8,84 +8,99 @@ package main
import (
"go.wit.com/log"
+ "go.wit.com/toolkits/tree"
"go.wit.com/widget"
)
-func doAction(a widget.Action) {
- log.Log(INFO, "doAction() START a.ActionType =", a.ActionType)
- log.Log(INFO, "doAction() START a.ProgName =", a.ProgName)
- if a.ActionType == widget.ToolkitInit {
+func Add(n *tree.Node) {
+ log.Log(INFO, "Add() END =", n.WidgetType, n.String())
+ if n == nil {
+ log.Warn("Tree Error: Add() sent n == nil")
return
}
-
- log.Log(INFO, "doAction() START a.WidgetId =", a.WidgetId, "a.ParentId =", a.ParentId)
- switch a.WidgetType {
+ switch n.WidgetType {
case widget.Root:
- me.treeRoot = me.myTree.AddNode(&a)
- log.Log(INFO, "doAction() found treeRoot")
+ me.treeRoot = n
+ log.Log(INFO, "Add() found treeRoot")
return
}
- switch a.ActionType {
- case widget.Add:
- me.myTree.AddNode(&a)
- return
- }
+ log.Log(INFO, "Add() END =", n.WidgetType, n.String())
+}
- n := me.treeRoot.FindWidgetId(a.WidgetId)
+func newaction(n *tree.Node, atype widget.ActionType) {
+ log.Log(INFO, "newaction() START", atype)
if n == nil {
- log.Warn("FindId() n == nil", a.WidgetId, a.ActionType)
- log.Warn("FindId() n == nil", a.WidgetId, a.ActionType)
- log.Warn("FindId() n == nil", a.WidgetId, a.ActionType)
- log.Warn("Aaaaa!, return")
+ log.Warn("Tree Error: Add() sent n == nil")
return
}
-
- switch a.ActionType {
+ if n.TK == nil {
+ log.Warn("Tree sent an action on a widget we didn't seem to have.")
+ // do this init here again? Probably something
+ // went wrong and we should reset the our while gocui.View tree
+ // n.TK = initWidget(n)
+ }
+ // w := n.TK.(*guiWidget)
+ switch atype {
case widget.Show:
- n.State.Hidden = true
+ log.Log(NOW, "Show() HERE. a.Hidden() was =", n.Hidden())
+ // w.Show()
case widget.Hide:
- n.State.Hidden = false
+ log.Log(NOW, "Hide() HERE. a.State.Hidden was =", n.Hidden())
+ // w.Hide()
+ case widget.Move:
+ log.Log(NOW, "attempt to move() =", atype, n.WidgetType, n.ProgName())
case widget.Enable:
- n.State.Enable = true
+ // w.enable = true
+ // w.enableColor()
case widget.Disable:
- n.State.Enable = false
- case widget.Get:
- log.Warn("value =", n.State.Value)
- case widget.GetText:
- log.Warn("value =", n.String())
- case widget.Set:
- n.State.Value = a.State.Value
- case widget.SetText:
- log.Warn("GOT TO SetText()", a.WidgetId)
- log.Warn("GOT TO SetText()", a.WidgetId)
- log.Warn("GOT TO SetText()", a.WidgetId)
- log.Warn("GOT TO SetText()", a.WidgetId)
- if n == nil {
- log.Warn("HOT DIGGITY. n == nil")
- }
- n.State.Value = a.State.Value
- case widget.AddText:
- n.State.Strings = append(a.State.Strings, widget.GetString(a.State.Value))
- case widget.Margin:
- n.State.Pad = true
- case widget.Unmargin:
- n.State.Pad = false
- case widget.Pad:
- n.State.Pad = true
- case widget.Unpad:
- n.State.Pad = false
+ // w.enable = false
+ // w.disableColor()
case widget.Delete:
- log.Warn("doAction() TODO: Delete()")
+ log.Info("newaction() DeleteNode()")
n.DeleteNode()
- case widget.Move:
- log.Warn("doAction() TODO: Move()")
case widget.ToolkitClose:
- log.Warn("doAction() toolkit closed. are the channels cleand up?")
+ log.Info("newaction() toolkit closed. are the channels cleand up?")
return
default:
- log.Log(ERROR, "doAction() Unknown =", a.ActionType, a.WidgetType)
+ log.Log(ERROR, "newaction() UNHANDLED Action Type =", atype, "WidgetType =", n.WidgetType, "Name =", n.ProgName())
+ }
+ log.Log(INFO, "newaction() END", atype, n.String())
+}
+
+func SetTitle(n *tree.Node, s string) {
+ SetText(n, s)
+}
+
+func SetLabel(n *tree.Node, s string) {
+ SetText(n, s)
+}
+
+func SetText(n *tree.Node, s string) {
+ if n == nil {
+ log.Warn("Tree Error: Add() sent n == nil")
+ return
+ }
+ if n.TK == nil {
+ log.Warn("Tree sent an action on a widget we didn't seem to have.")
+ return
+ }
+ // w := n.TK.(*guiWidget)
+ // w.SetText(s)
+ log.Info("SetText()", n.WidgetType, n.String())
+}
+
+func AddText(n *tree.Node, s string) {
+ if n == nil {
+ log.Warn("Tree Error: Add() sent n == nil")
+ return
+ }
+ if n.TK == nil {
+ log.Warn("Tree sent an action on a widget we didn't seem to have.")
+ return
}
- log.Log(INFO, "doAction() END =", a.ActionType, a.WidgetType)
+ log.Info("AddText()", n.WidgetType, n.String())
+ // w := n.TK.(*guiWidget)
+ // w.AddText(s)
}