toggle on/off windows works again

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-01-18 21:20:32 -06:00
parent 0adbbecdac
commit 040abfaa06
1 changed files with 23 additions and 75 deletions

View File

@ -153,55 +153,17 @@ func (n *node) move(newParent *node) {
} }
} }
func (n *node) Delete() { func widgetDelete(n *tree.Node) {
p := n.parent log.Log(NOW, "widgetDelete()", n.WidgetId)
log.Log(NOW, "uiDelete()", n.WidgetId, "to", p.WidgetId) var tk *guiWidget
tk = n.TK.(*guiWidget)
if n.WidgetType == widget.Window { if n.WidgetType == widget.Window {
log.Warn("DESTROY uiWindow here") log.Warn("DESTROY uiWindow here")
log.Warn("NEED TO REMOVE n from parent.Children") log.Warn("NEED TO REMOVE n from parent.Children")
n.tk.uiWindow.Destroy() tk.uiWindow.Destroy()
n.tk.uiWindow = nil tk.uiWindow = nil
for i, child := range p.children { n.DeleteNode()
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)
} }
} }
@ -214,8 +176,13 @@ func processAction(a *widget.Action) {
} }
switch a.WidgetType { switch a.WidgetType {
case widget.Root: case widget.Root:
me.treeRoot = me.myTree.AddNode(a) if me.treeRoot == nil {
log.Log(INFO, "doAction() found treeRoot") 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 return
} }
@ -230,18 +197,13 @@ func processAction(a *widget.Action) {
panic("me.treeRoot == nil") panic("me.treeRoot == nil")
} }
n := me.treeRoot.FindWidgetId(a.WidgetId)
if a.ActionType == widget.Add { if a.ActionType == widget.Add {
add(a) add(a)
return return
} }
if a.ActionType == widget.Dump { n := me.treeRoot.FindWidgetId(a.WidgetId)
log.Log(NOW, "processAction() Dump =", a.ActionType, a.WidgetType, n.State.ProgName)
return
}
if n == nil { if n == nil {
log.Error(errors.New("andlabs processAction() ERROR findWidgetId found nil"), a.ActionType, a.WidgetType) 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) 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)) 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 { switch a.ActionType {
case widget.Delete:
widgetDelete(n)
case widget.Show: case widget.Show:
show(n, true) show(n, true)
// n.show(true)
case widget.Hide: case widget.Hide:
show(n, false) show(n, false)
//n.show(false)
case widget.Enable: case widget.Enable:
enable(n, true) enable(n, true)
// n.enable(true)
case widget.Disable: case widget.Disable:
log.Warn("andlabs got disable for", n.WidgetId, n.State.ProgName) log.Warn("andlabs got disable for", n.WidgetId, n.State.ProgName)
enable(n, false) enable(n, false)
// n.enable(false)
case widget.Get: case widget.Get:
// n.setText(a)
setText(n, a) setText(n, a)
case widget.GetText: case widget.GetText:
switch a.WidgetType { switch a.WidgetType {
@ -276,27 +241,10 @@ func processAction(a *widget.Action) {
} }
case widget.Set: case widget.Set:
setText(n, a) setText(n, a)
// n.setText(a)
case widget.SetText: case widget.SetText:
setText(n, a) setText(n, a)
// n.setText(a)
case widget.AddText: case widget.AddText:
addText(n, a) 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: default:
log.Log(ERROR, "processAction() Unknown =", a.ActionType, a.WidgetType) log.Log(ERROR, "processAction() Unknown =", a.ActionType, a.WidgetType)
} }