2024-01-01 16:11:54 -06:00
|
|
|
package main
|
|
|
|
|
|
|
|
// if you include more than just this import
|
|
|
|
// then your plugin might be doing something un-ideal (just a guess from 2023/02/27)
|
2024-01-08 21:19:42 -06:00
|
|
|
import (
|
|
|
|
"go.wit.com/log"
|
|
|
|
"go.wit.com/gui/widget"
|
|
|
|
)
|
2024-01-01 16:11:54 -06:00
|
|
|
|
|
|
|
// delete the child widget from the parent
|
|
|
|
// p = parent, c = child
|
|
|
|
func (n *node) destroy() {
|
|
|
|
pId := n.parent.WidgetId
|
|
|
|
cId := n.WidgetId
|
2024-01-08 21:19:42 -06:00
|
|
|
log.Log(NOW, "delete()", pId, cId)
|
2024-01-01 16:11:54 -06:00
|
|
|
|
|
|
|
pt := n.parent.tk
|
|
|
|
ct := n.tk
|
|
|
|
if (ct == nil) {
|
2024-01-08 21:19:42 -06:00
|
|
|
log.Log(NOW, "delete FAILED (ct = mapToolkit[c] == nil) for c", pId, cId)
|
2024-01-01 16:11:54 -06:00
|
|
|
// this pukes out a whole universe of shit
|
|
|
|
// listMap()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
switch n.WidgetType {
|
2024-01-05 13:30:00 -06:00
|
|
|
case widget.Button:
|
2024-01-08 21:19:42 -06:00
|
|
|
log.Log(NOW, "Should delete Button here:", n.Name)
|
|
|
|
log.Log(NOW, "Parent:")
|
2024-01-01 16:11:54 -06:00
|
|
|
pt.Dump(true)
|
2024-01-08 21:19:42 -06:00
|
|
|
log.Log(NOW, "Child:")
|
2024-01-01 16:11:54 -06:00
|
|
|
ct.Dump(true)
|
|
|
|
if (pt.uiBox == nil) {
|
2024-01-08 21:19:42 -06:00
|
|
|
log.Log(NOW, "Don't know how to destroy this")
|
2024-01-01 16:11:54 -06:00
|
|
|
} else {
|
2024-01-08 21:19:42 -06:00
|
|
|
log.Log(NOW, "Fuck it, destroy the whole box", n.parent.Name)
|
2024-01-01 16:11:54 -06:00
|
|
|
// pt.uiBox.Destroy() // You have a bug: You cannot destroy a uiControl while it still has a parent.
|
|
|
|
pt.uiBox.SetPadded(false)
|
|
|
|
pt.uiBox.Delete(4)
|
|
|
|
ct.uiButton.Disable()
|
|
|
|
// ct.uiButton.Hide()
|
|
|
|
ct.uiButton.Destroy()
|
|
|
|
}
|
|
|
|
|
2024-01-05 13:30:00 -06:00
|
|
|
case widget.Window:
|
2024-01-08 21:19:42 -06:00
|
|
|
log.Log(NOW, "Should delete Window here:", n.Name)
|
2024-01-01 16:11:54 -06:00
|
|
|
default:
|
2024-01-08 21:19:42 -06:00
|
|
|
log.Log(NOW, "Fuckit, let's destroy a button")
|
2024-01-01 16:11:54 -06:00
|
|
|
if (ct.uiButton != nil) {
|
|
|
|
pt.uiBox.Delete(4)
|
|
|
|
ct.uiButton.Destroy()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|