2023-03-23 12:35:12 -05:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"git.wit.org/wit/gui/toolkit"
|
|
|
|
)
|
|
|
|
|
2023-03-29 23:03:04 -05:00
|
|
|
func show(a *toolkit.Action) {
|
|
|
|
if (a == nil) {
|
2023-03-23 12:35:12 -05:00
|
|
|
log(debugError, "nil is probably already hidden")
|
|
|
|
return
|
|
|
|
}
|
2023-03-29 23:03:04 -05:00
|
|
|
log(debugError, "show()", a.WidgetId)
|
2023-03-23 12:35:12 -05:00
|
|
|
|
2023-03-29 23:03:04 -05:00
|
|
|
t := andlabs[a.WidgetId]
|
2023-03-23 12:35:12 -05:00
|
|
|
if (t == nil) {
|
2023-03-29 23:03:04 -05:00
|
|
|
log(debugError, "show() toolkit struct == nil. for", a.WidgetId)
|
2023-03-23 12:35:12 -05:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2023-03-29 23:03:04 -05:00
|
|
|
if (a.B) {
|
2023-03-23 12:35:12 -05:00
|
|
|
t.uiControl.Show()
|
|
|
|
} else {
|
|
|
|
t.uiControl.Hide()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-29 23:03:04 -05:00
|
|
|
func enable(a *toolkit.Action) {
|
|
|
|
if (a == nil) {
|
2023-03-23 12:35:12 -05:00
|
|
|
log(debugError, "nil is probably already hidden")
|
|
|
|
return
|
|
|
|
}
|
2023-03-29 23:03:04 -05:00
|
|
|
log(debugError, "enable() name =", a.WidgetId)
|
2023-03-23 12:35:12 -05:00
|
|
|
|
2023-03-29 23:03:04 -05:00
|
|
|
t := andlabs[a.WidgetId]
|
2023-03-23 12:35:12 -05:00
|
|
|
if (t == nil) {
|
2023-03-29 23:03:04 -05:00
|
|
|
log(debugToolkit, "enable() toolkit struct == nil. for id =", a.WidgetId)
|
2023-03-23 12:35:12 -05:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2023-03-29 23:03:04 -05:00
|
|
|
if (a.B) {
|
2023-03-23 12:35:12 -05:00
|
|
|
t.uiControl.Enable()
|
|
|
|
} else {
|
|
|
|
t.uiControl.Disable()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func pad(a *toolkit.Action) {
|
2023-03-29 23:03:04 -05:00
|
|
|
if (a == nil) {
|
2023-03-23 12:35:12 -05:00
|
|
|
log(debugError, "pad() ERROR: nil is probably already hidden")
|
|
|
|
return
|
|
|
|
}
|
2023-03-29 23:03:04 -05:00
|
|
|
log(debugError, "pad()")
|
2023-03-23 12:35:12 -05:00
|
|
|
|
2023-03-29 23:03:04 -05:00
|
|
|
t := andlabs[a.WidgetId]
|
2023-03-23 12:35:12 -05:00
|
|
|
if (t == nil) {
|
2023-03-29 23:03:04 -05:00
|
|
|
log(debugError, "pad() toolkit struct == nil. for", a.WidgetId)
|
2023-03-23 12:35:12 -05:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2023-04-03 10:26:47 -05:00
|
|
|
switch t.WidgetType {
|
2023-03-23 12:35:12 -05:00
|
|
|
case toolkit.Group:
|
2023-03-29 23:03:04 -05:00
|
|
|
switch a.ActionType {
|
2023-03-23 12:35:12 -05:00
|
|
|
case toolkit.Margin:
|
|
|
|
t.uiGroup.SetMargined(true)
|
|
|
|
case toolkit.Unmargin:
|
|
|
|
t.uiGroup.SetMargined(false)
|
|
|
|
case toolkit.Pad:
|
|
|
|
t.uiGroup.SetMargined(true)
|
|
|
|
case toolkit.Unpad:
|
|
|
|
t.uiGroup.SetMargined(false)
|
|
|
|
}
|
|
|
|
case toolkit.Tab:
|
2023-03-29 23:03:04 -05:00
|
|
|
switch a.ActionType {
|
2023-03-23 12:35:12 -05:00
|
|
|
case toolkit.Margin:
|
|
|
|
tabSetMargined(t.uiTab, true)
|
|
|
|
case toolkit.Unmargin:
|
|
|
|
tabSetMargined(t.uiTab, false)
|
|
|
|
case toolkit.Pad:
|
|
|
|
tabSetMargined(t.uiTab, true)
|
|
|
|
case toolkit.Unpad:
|
|
|
|
tabSetMargined(t.uiTab, false)
|
|
|
|
}
|
|
|
|
case toolkit.Window:
|
2023-03-29 23:03:04 -05:00
|
|
|
switch a.ActionType {
|
2023-03-23 12:35:12 -05:00
|
|
|
case toolkit.Margin:
|
|
|
|
t.uiWindow.SetMargined(true)
|
|
|
|
case toolkit.Unmargin:
|
|
|
|
t.uiWindow.SetMargined(false)
|
|
|
|
case toolkit.Pad:
|
|
|
|
t.uiWindow.SetBorderless(false)
|
|
|
|
case toolkit.Unpad:
|
|
|
|
t.uiWindow.SetBorderless(true)
|
|
|
|
}
|
|
|
|
case toolkit.Grid:
|
2023-03-29 23:03:04 -05:00
|
|
|
switch a.ActionType {
|
2023-03-23 12:35:12 -05:00
|
|
|
case toolkit.Margin:
|
|
|
|
t.uiGrid.SetPadded(true)
|
|
|
|
case toolkit.Unmargin:
|
|
|
|
t.uiGrid.SetPadded(false)
|
|
|
|
case toolkit.Pad:
|
|
|
|
t.uiGrid.SetPadded(true)
|
|
|
|
case toolkit.Unpad:
|
|
|
|
t.uiGrid.SetPadded(false)
|
|
|
|
}
|
|
|
|
case toolkit.Box:
|
2023-03-29 23:03:04 -05:00
|
|
|
switch a.ActionType {
|
2023-03-23 12:35:12 -05:00
|
|
|
case toolkit.Margin:
|
|
|
|
t.uiBox.SetPadded(true)
|
|
|
|
case toolkit.Unmargin:
|
|
|
|
t.uiBox.SetPadded(false)
|
|
|
|
case toolkit.Pad:
|
|
|
|
t.uiBox.SetPadded(true)
|
|
|
|
case toolkit.Unpad:
|
|
|
|
t.uiBox.SetPadded(false)
|
|
|
|
}
|
|
|
|
case toolkit.Textbox:
|
2023-03-29 23:03:04 -05:00
|
|
|
log(debugError, "TODO: implement expand for", a.ActionType)
|
|
|
|
log(debugError, "TODO: implement expand for", a.ActionType)
|
|
|
|
log(debugError, "TODO: implement expand for", a.ActionType)
|
|
|
|
log(debugError, "TODO: implement expand for", a.ActionType)
|
2023-03-23 12:35:12 -05:00
|
|
|
default:
|
2023-03-29 23:03:04 -05:00
|
|
|
log(debugError, "TODO: implement pad() for", a.ActionType)
|
2023-03-23 12:35:12 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func move(a *toolkit.Action) {
|
2023-03-29 23:03:04 -05:00
|
|
|
log(debugNow, "move()", a.WidgetId, "to", a.ParentId)
|
2023-03-23 12:35:12 -05:00
|
|
|
|
2023-03-29 23:03:04 -05:00
|
|
|
tWidget := andlabs[a.WidgetId]
|
2023-03-23 12:35:12 -05:00
|
|
|
if (tWidget == nil) {
|
2023-03-29 23:03:04 -05:00
|
|
|
log(debugError, "move() ERROR: toolkit struct == nil. for", a.WidgetId)
|
2023-03-23 12:35:12 -05:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2023-03-29 23:03:04 -05:00
|
|
|
tParent := andlabs[a.ParentId]
|
|
|
|
if (tParent == nil) {
|
|
|
|
log(debugError, "move() ERROR: toolkit struct == nil. for", a.ParentId)
|
2023-03-23 12:35:12 -05:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2023-04-03 10:26:47 -05:00
|
|
|
switch tParent.WidgetType {
|
2023-03-23 12:35:12 -05:00
|
|
|
case toolkit.Group:
|
2023-03-29 23:03:04 -05:00
|
|
|
switch a.ActionType {
|
2023-03-23 12:35:12 -05:00
|
|
|
case toolkit.Margin:
|
2023-03-29 23:03:04 -05:00
|
|
|
tParent.uiGroup.SetMargined(true)
|
2023-03-23 12:35:12 -05:00
|
|
|
}
|
|
|
|
case toolkit.Tab:
|
2023-03-29 23:03:04 -05:00
|
|
|
switch a.ActionType {
|
2023-03-23 12:35:12 -05:00
|
|
|
case toolkit.Margin:
|
2023-03-29 23:03:04 -05:00
|
|
|
// tabSetMargined(tParent.uiTab, true)
|
2023-03-23 12:35:12 -05:00
|
|
|
}
|
|
|
|
case toolkit.Window:
|
2023-03-29 23:03:04 -05:00
|
|
|
switch a.ActionType {
|
2023-03-23 12:35:12 -05:00
|
|
|
case toolkit.Pad:
|
|
|
|
// t.uiWindow.SetBorderless(false)
|
|
|
|
}
|
|
|
|
case toolkit.Grid:
|
2023-03-29 23:03:04 -05:00
|
|
|
switch a.ActionType {
|
2023-03-23 12:35:12 -05:00
|
|
|
case toolkit.Pad:
|
|
|
|
// t.uiGrid.SetPadded(true)
|
|
|
|
}
|
|
|
|
case toolkit.Box:
|
2023-03-29 23:03:04 -05:00
|
|
|
log(debugNow, "TODO: move() for a =", a.ActionType)
|
|
|
|
log(debugNow, "TODO: move() where =", a.ParentId)
|
|
|
|
log(debugNow, "TODO: move() for widget =", a.WidgetId)
|
2023-03-23 12:35:12 -05:00
|
|
|
|
|
|
|
stretchy = true
|
2023-03-29 23:03:04 -05:00
|
|
|
tParent.uiBox.Append(tWidget.uiControl, stretchy)
|
|
|
|
// log(debugNow, "is there a tParent parent? =", tParent.parent)
|
|
|
|
// tParent.uiBox.Delete(0)
|
2023-03-23 12:35:12 -05:00
|
|
|
|
|
|
|
// this didn't work:
|
|
|
|
// tWidget.uiControl.Disable()
|
|
|
|
// sleep(.8)
|
|
|
|
default:
|
2023-03-29 23:03:04 -05:00
|
|
|
log(debugError, "TODO: need to implement move() for a =", a.ActionType)
|
|
|
|
log(debugError, "TODO: need to implement move() for where =", a.ParentId)
|
|
|
|
log(debugError, "TODO: need to implement move() for widget =", a.WidgetId)
|
2023-03-23 12:35:12 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func uiDelete(a *toolkit.Action) {
|
2023-03-29 23:03:04 -05:00
|
|
|
if (andlabs[a.ParentId] == nil) {
|
2023-03-23 12:35:12 -05:00
|
|
|
log(debugError, "uiDelete() ERROR: can not uiDelete to nil")
|
|
|
|
return
|
|
|
|
}
|
2023-03-29 23:03:04 -05:00
|
|
|
if (andlabs[a.WidgetId] == nil) {
|
2023-03-23 12:35:12 -05:00
|
|
|
log(debugError, "uiDelete() ERROR: can not uiDelete nil")
|
|
|
|
return
|
|
|
|
}
|
2023-03-29 23:03:04 -05:00
|
|
|
log(debugNow, "uiDelete()", a.WidgetId, "to", a.ParentId)
|
2023-03-23 12:35:12 -05:00
|
|
|
|
2023-03-29 23:03:04 -05:00
|
|
|
tWidget := andlabs[a.WidgetId]
|
2023-03-23 12:35:12 -05:00
|
|
|
if (tWidget == nil) {
|
2023-03-29 23:03:04 -05:00
|
|
|
log(debugError, "uiDelete() ERROR: toolkit struct == nil. for", a.WidgetId)
|
2023-03-23 12:35:12 -05:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2023-03-29 23:03:04 -05:00
|
|
|
tParent := andlabs[a.ParentId]
|
|
|
|
if (tParent == nil) {
|
|
|
|
log(debugError, "uiDelete() ERROR: toolkit struct == nil. for", a.ParentId)
|
2023-03-23 12:35:12 -05:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2023-04-03 10:26:47 -05:00
|
|
|
switch tParent.WidgetType {
|
2023-03-23 12:35:12 -05:00
|
|
|
case toolkit.Group:
|
2023-03-29 23:03:04 -05:00
|
|
|
switch a.ActionType {
|
2023-03-23 12:35:12 -05:00
|
|
|
case toolkit.Margin:
|
2023-03-29 23:03:04 -05:00
|
|
|
tParent.uiGroup.SetMargined(true)
|
2023-03-23 12:35:12 -05:00
|
|
|
}
|
|
|
|
case toolkit.Tab:
|
2023-03-29 23:03:04 -05:00
|
|
|
switch a.ActionType {
|
2023-03-23 12:35:12 -05:00
|
|
|
case toolkit.Margin:
|
2023-03-29 23:03:04 -05:00
|
|
|
// tabSetMargined(tParent.uiTab, true)
|
2023-03-23 12:35:12 -05:00
|
|
|
}
|
|
|
|
case toolkit.Window:
|
2023-03-29 23:03:04 -05:00
|
|
|
switch a.ActionType {
|
2023-03-23 12:35:12 -05:00
|
|
|
case toolkit.Pad:
|
|
|
|
// t.uiWindow.SetBorderless(false)
|
|
|
|
}
|
|
|
|
case toolkit.Grid:
|
2023-03-29 23:03:04 -05:00
|
|
|
switch a.ActionType {
|
2023-03-23 12:35:12 -05:00
|
|
|
case toolkit.Pad:
|
|
|
|
// t.uiGrid.SetPadded(true)
|
|
|
|
}
|
|
|
|
case toolkit.Box:
|
2023-03-29 23:03:04 -05:00
|
|
|
log(debugNow, "tWidget.boxC =", tParent.Name)
|
|
|
|
log(debugNow, "is there a tParent parent? =", tParent.parent)
|
2023-03-23 12:35:12 -05:00
|
|
|
if (tWidget.boxC < 1) {
|
2023-03-29 23:03:04 -05:00
|
|
|
log(debugNow, "Can not delete from Box. already empty. tWidget.boxC =", tParent.boxC)
|
2023-03-23 12:35:12 -05:00
|
|
|
return
|
|
|
|
}
|
|
|
|
tWidget.uiBox.Delete(0)
|
|
|
|
tWidget.boxC -= 1
|
|
|
|
|
|
|
|
// this didn't work:
|
|
|
|
// tWidget.uiControl.Disable()
|
|
|
|
// sleep(.8)
|
2023-03-29 23:03:04 -05:00
|
|
|
// tParent.uiBox.Append(tWidget.uiControl, stretchy)
|
2023-03-23 12:35:12 -05:00
|
|
|
default:
|
2023-03-29 23:03:04 -05:00
|
|
|
log(debugError, "TODO: need to implement uiDelete() for a =", a.ActionType)
|
|
|
|
log(debugError, "TODO: need to implement uiDelete() for where =", a.ParentId)
|
|
|
|
log(debugError, "TODO: need to implement uiDelete() for widget =", a.WidgetId)
|
2023-03-23 12:35:12 -05:00
|
|
|
}
|
|
|
|
}
|