summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--action.go98
1 files changed, 23 insertions, 75 deletions
diff --git a/action.go b/action.go
index 83f0afc..9ee1b3e 100644
--- a/action.go
+++ b/action.go
@@ -153,55 +153,17 @@ func (n *node) move(newParent *node) {
}
}
-func (n *node) Delete() {
- p := n.parent
- log.Log(NOW, "uiDelete()", n.WidgetId, "to", p.WidgetId)
+func widgetDelete(n *tree.Node) {
+ log.Log(NOW, "widgetDelete()", n.WidgetId)
+ var tk *guiWidget
+ tk = n.TK.(*guiWidget)
if n.WidgetType == widget.Window {
log.Warn("DESTROY uiWindow here")
log.Warn("NEED TO REMOVE n from parent.Children")
- n.tk.uiWindow.Destroy()
- n.tk.uiWindow = nil
- for i, child := range p.children {
- log.Warn("parent has child:", i, child.WidgetId, child.progname)
- if n == child {
- log.Warn("Found child ==", i, child.WidgetId, child.progname)
- log.Warn("Found n ==", i, n.WidgetId, n.progname)
- p.children = append(p.children[:i], p.children[i+1:]...)
- }
- // t.uiWindow.SetBorderless(false)
- }
- for i, child := range p.children {
- log.Warn("parent now has child:", i, child.WidgetId, child.progname)
- }
- return
- }
-
- switch p.WidgetType {
- case widget.Group:
- // tParent.uiGroup.SetMargined(true)
- case widget.Tab:
- // tabSetMargined(tParent.uiTab, true)
- case widget.Window:
- case widget.Grid:
- // t.uiGrid.SetPadded(true)
- case widget.Box:
- log.Log(NOW, "tWidget.boxC =", p.progname)
- log.Log(NOW, "is there a tParent parent? =", p.parent)
- if p.tk.boxC < 1 {
- log.Log(NOW, "Can not delete from Box. already empty. tWidget.boxC =", p.tk.boxC)
- return
- }
- p.tk.uiBox.Delete(0)
- p.tk.boxC -= 1
-
- // this didn't work:
- // tWidget.uiControl.Disable()
- // sleep(.8)
- // tParent.uiBox.Append(tWidget.uiControl, stretchy)
- default:
- log.Log(ERROR, "TODO: need to implement uiDelete() for widget =", n.WidgetId, n.WidgetType)
- log.Log(ERROR, "TODO: need to implement uiDelete() for parent =", p.WidgetId, p.WidgetType)
+ tk.uiWindow.Destroy()
+ tk.uiWindow = nil
+ n.DeleteNode()
}
}
@@ -214,8 +176,13 @@ func processAction(a *widget.Action) {
}
switch a.WidgetType {
case widget.Root:
- me.treeRoot = me.myTree.AddNode(a)
- log.Log(INFO, "doAction() found treeRoot")
+ if me.treeRoot == nil {
+ log.Log(INFO, "processAction() found the treeRoot")
+ me.treeRoot = me.myTree.AddNode(a)
+ } else {
+ log.Warn("processAction() Something terrible has happened")
+ log.Warn("processAction() treeNode was sent an action", a.ActionType, a)
+ }
return
}
@@ -230,18 +197,13 @@ func processAction(a *widget.Action) {
panic("me.treeRoot == nil")
}
- n := me.treeRoot.FindWidgetId(a.WidgetId)
if a.ActionType == widget.Add {
add(a)
return
}
- if a.ActionType == widget.Dump {
- log.Log(NOW, "processAction() Dump =", a.ActionType, a.WidgetType, n.State.ProgName)
- return
- }
-
+ n := me.treeRoot.FindWidgetId(a.WidgetId)
if n == nil {
log.Error(errors.New("andlabs processAction() ERROR findWidgetId found nil"), a.ActionType, a.WidgetType)
log.Log(NOW, "processAction() ERROR findWidgetId found nil for id =", a.WidgetId)
@@ -252,22 +214,25 @@ func processAction(a *widget.Action) {
panic("findWidgetId found nil for id = " + string(a.WidgetId))
}
+ if a.ActionType == widget.Dump {
+ log.Log(NOW, "processAction() Dump =", a.ActionType, a.WidgetType, n.State.ProgName)
+ return
+ }
+
+
switch a.ActionType {
+ case widget.Delete:
+ widgetDelete(n)
case widget.Show:
show(n, true)
- // n.show(true)
case widget.Hide:
show(n, false)
- //n.show(false)
case widget.Enable:
enable(n, true)
- // n.enable(true)
case widget.Disable:
log.Warn("andlabs got disable for", n.WidgetId, n.State.ProgName)
enable(n, false)
- // n.enable(false)
case widget.Get:
- // n.setText(a)
setText(n, a)
case widget.GetText:
switch a.WidgetType {
@@ -276,27 +241,10 @@ func processAction(a *widget.Action) {
}
case widget.Set:
setText(n, a)
- // n.setText(a)
case widget.SetText:
setText(n, a)
- // n.setText(a)
case widget.AddText:
addText(n, a)
- // n.addText(a)
- /*
- case widget.Margin:
- n.pad(true)
- case widget.Unmargin:
- n.pad(false)
- case widget.Pad:
- n.pad(true)
- case widget.Unpad:
- n.pad(false)
- case widget.Delete:
- n.Delete()
- case widget.Move:
- log.Log(NOW, "processAction() attempt to move() =", a.ActionType, a.WidgetType)
- */
default:
log.Log(ERROR, "processAction() Unknown =", a.ActionType, a.WidgetType)
}