2024-01-01 16:11:54 -06:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2024-01-05 13:24:20 -06:00
|
|
|
"go.wit.com/gui/widget"
|
2024-01-01 16:11:54 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
func (n *node) show(b bool) {
|
|
|
|
}
|
|
|
|
|
|
|
|
func (n *node) enable(b bool) {
|
|
|
|
}
|
|
|
|
|
2024-01-05 13:24:20 -06:00
|
|
|
func (n *node) pad(at widget.ActionType) {
|
2024-01-01 16:11:54 -06:00
|
|
|
switch n.WidgetType {
|
2024-01-05 13:24:20 -06:00
|
|
|
case widget.Group:
|
2024-01-01 16:11:54 -06:00
|
|
|
switch at {
|
2024-01-05 13:24:20 -06:00
|
|
|
case widget.Margin:
|
2024-01-01 16:11:54 -06:00
|
|
|
// SetMargined(true)
|
2024-01-05 13:24:20 -06:00
|
|
|
case widget.Unmargin:
|
2024-01-01 16:11:54 -06:00
|
|
|
// SetMargined(false)
|
2024-01-05 13:24:20 -06:00
|
|
|
case widget.Pad:
|
2024-01-01 16:11:54 -06:00
|
|
|
// SetMargined(true)
|
2024-01-05 13:24:20 -06:00
|
|
|
case widget.Unpad:
|
2024-01-01 16:11:54 -06:00
|
|
|
// SetMargined(false)
|
|
|
|
}
|
2024-01-05 13:24:20 -06:00
|
|
|
case widget.Tab:
|
|
|
|
case widget.Window:
|
|
|
|
case widget.Grid:
|
|
|
|
case widget.Box:
|
|
|
|
case widget.Textbox:
|
2024-01-01 16:11:54 -06:00
|
|
|
log(logError, "TODO: implement ActionType =", at)
|
|
|
|
default:
|
|
|
|
log(logError, "TODO: implement pad() for", at)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (n *node) move(newParent *node) {
|
|
|
|
p := n.parent
|
|
|
|
|
|
|
|
switch p.WidgetType {
|
2024-01-05 13:24:20 -06:00
|
|
|
case widget.Group:
|
|
|
|
case widget.Tab:
|
2024-01-01 16:11:54 -06:00
|
|
|
// tabSetMargined(tParent.uiTab, true)
|
2024-01-05 13:24:20 -06:00
|
|
|
case widget.Window:
|
2024-01-01 16:11:54 -06:00
|
|
|
// t.uiWindow.SetBorderless(false)
|
2024-01-05 13:24:20 -06:00
|
|
|
case widget.Grid:
|
2024-01-01 16:11:54 -06:00
|
|
|
// t.uiGrid.SetPadded(true)
|
2024-01-05 13:24:20 -06:00
|
|
|
case widget.Box:
|
2024-01-01 16:11:54 -06:00
|
|
|
log(logInfo, "TODO: move() where =", p.ParentId)
|
|
|
|
log(logInfo, "TODO: move() for widget =", n.WidgetId)
|
|
|
|
default:
|
|
|
|
log(logError, "TODO: need to implement move() for type =", n.WidgetType)
|
|
|
|
log(logError, "TODO: need to implement move() for where =", p.ParentId)
|
|
|
|
log(logError, "TODO: need to implement move() for widget =", n.WidgetId)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (n *node) Delete() {
|
|
|
|
p := n.parent
|
|
|
|
log(logNow, "uiDelete()", n.WidgetId, "to", p.WidgetId)
|
|
|
|
|
|
|
|
switch p.WidgetType {
|
2024-01-05 13:24:20 -06:00
|
|
|
case widget.Group:
|
2024-01-01 16:11:54 -06:00
|
|
|
// tParent.uiGroup.SetMargined(true)
|
2024-01-05 13:24:20 -06:00
|
|
|
case widget.Tab:
|
2024-01-01 16:11:54 -06:00
|
|
|
// tabSetMargined(tParent.uiTab, true)
|
2024-01-05 13:24:20 -06:00
|
|
|
case widget.Window:
|
2024-01-01 16:11:54 -06:00
|
|
|
// t.uiWindow.SetBorderless(false)
|
2024-01-05 13:24:20 -06:00
|
|
|
case widget.Grid:
|
2024-01-01 16:11:54 -06:00
|
|
|
// t.uiGrid.SetPadded(true)
|
2024-01-05 13:24:20 -06:00
|
|
|
case widget.Box:
|
2024-01-01 16:11:54 -06:00
|
|
|
log(logNow, "tWidget.boxC =", p.Name)
|
|
|
|
log(logNow, "is there a tParent parent? =", p.parent)
|
|
|
|
// this didn't work:
|
|
|
|
// tWidget.uiControl.Disable()
|
|
|
|
// sleep(.8)
|
|
|
|
// tParent.uiBox.Append(tWidget.uiControl, stretchy)
|
|
|
|
default:
|
|
|
|
log(logError, "TODO: need to implement uiDelete() for widget =", n.WidgetId, n.WidgetType)
|
|
|
|
log(logError, "TODO: need to implement uiDelete() for parent =", p.WidgetId, p.WidgetType)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-05 13:24:20 -06:00
|
|
|
func doAction(a *widget.Action) {
|
2024-01-01 16:11:54 -06:00
|
|
|
log(logNow, "doAction() START a.ActionType =", a.ActionType)
|
|
|
|
log(logNow, "doAction() START a.S =", a.S)
|
|
|
|
|
2024-01-05 13:24:20 -06:00
|
|
|
if (a.ActionType == widget.InitToolkit) {
|
2024-01-01 16:11:54 -06:00
|
|
|
// TODO: make sure to only do this once
|
|
|
|
// go uiMain.Do(func() {
|
|
|
|
// ui.Main(demoUI)
|
|
|
|
// go catchActionChannel()
|
|
|
|
// })
|
|
|
|
// try doing this on toolkit load in init()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
log(logNow, "doAction() START a.WidgetId =", a.WidgetId, "a.ParentId =", a.ParentId)
|
|
|
|
switch a.WidgetType {
|
2024-01-05 13:24:20 -06:00
|
|
|
case widget.Root:
|
2024-01-01 16:11:54 -06:00
|
|
|
me.rootNode = addNode(a)
|
|
|
|
log(logNow, "doAction() found rootNode")
|
|
|
|
return
|
2024-01-05 13:24:20 -06:00
|
|
|
case widget.Flag:
|
2024-01-01 16:11:54 -06:00
|
|
|
// flag(&a)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
n := me.rootNode.findWidgetId(a.WidgetId)
|
|
|
|
|
|
|
|
switch a.ActionType {
|
2024-01-05 13:24:20 -06:00
|
|
|
case widget.Add:
|
2024-01-01 16:11:54 -06:00
|
|
|
addNode(a)
|
2024-01-05 13:24:20 -06:00
|
|
|
case widget.Show:
|
2024-01-01 16:11:54 -06:00
|
|
|
n.show(true)
|
2024-01-05 13:24:20 -06:00
|
|
|
case widget.Hide:
|
2024-01-01 16:11:54 -06:00
|
|
|
n.show(false)
|
2024-01-05 13:24:20 -06:00
|
|
|
case widget.Enable:
|
2024-01-01 16:11:54 -06:00
|
|
|
n.enable(true)
|
2024-01-05 13:24:20 -06:00
|
|
|
case widget.Disable:
|
2024-01-01 16:11:54 -06:00
|
|
|
n.enable(false)
|
2024-01-05 13:24:20 -06:00
|
|
|
case widget.Get:
|
2024-01-01 16:11:54 -06:00
|
|
|
// n.setText(a.S)
|
2024-01-05 13:24:20 -06:00
|
|
|
case widget.GetText:
|
2024-01-01 16:11:54 -06:00
|
|
|
switch a.WidgetType {
|
2024-01-05 13:24:20 -06:00
|
|
|
case widget.Textbox:
|
2024-01-01 16:11:54 -06:00
|
|
|
a.S = n.S
|
|
|
|
}
|
2024-01-05 13:24:20 -06:00
|
|
|
case widget.Set:
|
2024-01-01 16:11:54 -06:00
|
|
|
// n.setText(a.S)
|
2024-01-05 13:24:20 -06:00
|
|
|
case widget.SetText:
|
2024-01-01 16:11:54 -06:00
|
|
|
// n.setText(a.S)
|
2024-01-05 13:24:20 -06:00
|
|
|
case widget.AddText:
|
2024-01-01 16:11:54 -06:00
|
|
|
// n.setText(a.S)
|
2024-01-05 13:24:20 -06:00
|
|
|
case widget.Margin:
|
|
|
|
n.pad(widget.Unmargin)
|
|
|
|
case widget.Unmargin:
|
|
|
|
n.pad(widget.Margin)
|
|
|
|
case widget.Pad:
|
|
|
|
n.pad(widget.Pad)
|
|
|
|
case widget.Unpad:
|
|
|
|
n.pad(widget.Unpad)
|
|
|
|
case widget.Delete:
|
2024-01-01 16:11:54 -06:00
|
|
|
n.Delete()
|
2024-01-05 13:24:20 -06:00
|
|
|
case widget.Move:
|
2024-01-01 16:11:54 -06:00
|
|
|
log(logNow, "doAction() attempt to move() =", a.ActionType, a.WidgetType)
|
|
|
|
newParent := me.rootNode.findWidgetId(a.ParentId)
|
|
|
|
n.move(newParent)
|
|
|
|
default:
|
|
|
|
log(logError, "doAction() Unknown =", a.ActionType, a.WidgetType)
|
|
|
|
}
|
|
|
|
log(logInfo, "doAction() END =", a.ActionType, a.WidgetType)
|
|
|
|
}
|