getting pretty clean at this point

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2023-05-09 19:24:37 -05:00
parent 6b55526fee
commit c077a3d4e1
5 changed files with 61 additions and 78 deletions

View File

@ -123,7 +123,7 @@ Creates a window helpful for debugging this package
`func ExampleCatcher(f func())`
### func [Indent](/debug.go#L127)
### func [Indent](/debug.go#L124)
`func Indent(b bool, a ...interface{})`
@ -135,7 +135,7 @@ Creates a window helpful for debugging this package
`func SetFlag(s string, b bool)`
### func [ShowDebugValues](/debug.go#L85)
### func [ShowDebugValues](/debug.go#L82)
`func ShowDebugValues()`

View File

@ -10,60 +10,56 @@ import (
// functions for handling text related GUI elements
func (n *Node) Show() *Node {
var a toolkit.Action
a.ActionType = toolkit.Show
newaction(&a, n, nil)
a := newAction(n, toolkit.Show)
sendAction(a)
return n
}
func (n *Node) Hide() *Node {
var a toolkit.Action
a.ActionType = toolkit.Hide
newaction(&a, n, nil)
a := newAction(n, toolkit.Hide)
sendAction(a)
return n
}
func (n *Node) Enable() *Node {
var a toolkit.Action
a.ActionType = toolkit.Enable
newaction(&a, n, nil)
a := newAction(n, toolkit.Enable)
sendAction(a)
return n
}
func (n *Node) Disable() *Node {
var a toolkit.Action
a.ActionType = toolkit.Disable
newaction(&a, n, nil)
a := newAction(n, toolkit.Disable)
sendAction(a)
return n
}
func (n *Node) Add(str string) {
log(debugGui, "gui.Add() value =", str)
var a toolkit.Action
a.ActionType = toolkit.Add
a.S = str
newaction(&a, n, nil)
n.S = str
a := newAction(n, toolkit.Add)
sendAction(a)
}
func (n *Node) AddText(str string) {
log(debugChange, "AddText() value =", str)
n.Text = str
var a toolkit.Action
a.ActionType = toolkit.AddText
a.S = str
newaction(&a, n, nil)
n.S = str
a := newAction(n, toolkit.AddText)
sendAction(a)
}
func (n *Node) SetText(text string) *Node{
func (n *Node) SetText(text string) *Node {
log(debugChange, "SetText() value =", text)
n.Text = text
var a toolkit.Action
a.ActionType = toolkit.SetText
a.S = text
newaction(&a, n, nil)
n.S = text
a := newAction(n, toolkit.SetText)
sendAction(a)
return n
}
@ -93,13 +89,12 @@ func (n *Node) Set(val any) {
}
func (n *Node) AppendText(str string) {
var a toolkit.Action
a.ActionType = toolkit.SetText
tmp := n.S + str
log(debugChange, "AppendText() value =", tmp)
a.S = tmp
n.Text = tmp
newaction(&a, n, nil)
n.S = tmp
a := newAction(n, toolkit.SetText)
sendAction(a)
}
func (n *Node) GetText() string {
@ -152,30 +147,26 @@ func commonCallback(n *Node) {
}
func (n *Node) Margin() *Node {
var a toolkit.Action
a.ActionType = toolkit.Margin
newaction(&a, n, nil)
a := newAction(n, toolkit.Margin)
sendAction(a)
return n
}
func (n *Node) Unmargin() *Node {
var a toolkit.Action
a.ActionType = toolkit.Unmargin
newaction(&a, n, nil)
a := newAction(n, toolkit.Unmargin)
sendAction(a)
return n
}
func (n *Node) Pad() *Node {
var a toolkit.Action
a.ActionType = toolkit.Pad
newaction(&a, n, nil)
a := newAction(n, toolkit.Pad)
sendAction(a)
return n
}
func (n *Node) Unpad() *Node {
var a toolkit.Action
a.ActionType = toolkit.Unpad
newaction(&a, n, nil)
a := newAction(n, toolkit.Unpad)
sendAction(a)
return n
}

View File

@ -71,15 +71,12 @@ func SetFlag (s string, b bool) {
log(debugGui, "Can't set unknown flag", s)
}
var a toolkit.Action
a := new(toolkit.Action)
a.ActionType = toolkit.Set
a.WidgetType = toolkit.Flag
a.S = s
a.B = b
// a.Widget = &newNode.widget
// a.Where = &n.widget
// action(&a)
newaction(&a, nil, nil)
sendAction(a)
}
func ShowDebugValues() {
@ -118,10 +115,10 @@ func (n *Node) Dump() {
}
Indent(b, "NODE DUMP END")
var a toolkit.Action
a := new(toolkit.Action)
a.ActionType = toolkit.Dump
a.WidgetId = n.id
newaction(&a, activeWidget, nil)
sendAction(a)
}
func Indent(b bool, a ...interface{}) {

View File

@ -115,46 +115,38 @@ func DebugWidgetWindow(w *Node) {
g = bugWidget.NewGroup("change things")
g.NewButton("AddText()", func () {
var a toolkit.Action
a.ActionType = toolkit.AddText
a.S = activeLabelNewName.S
newaction(&a, activeWidget, nil)
activeWidget.S = activeLabelNewName.S
a := newAction(activeWidget, toolkit.AddText)
sendAction(a)
})
g.NewButton("SetText()", func () {
var a toolkit.Action
a.ActionType = toolkit.SetText
a.S = activeLabelNewName.S
newaction(&a, activeWidget, nil)
activeWidget.S = activeLabelNewName.S
a := newAction(activeWidget, toolkit.SetText)
sendAction(a)
})
g.NewButton("Margin()", func () {
var a toolkit.Action
a.ActionType = toolkit.Margin
newaction(&a, activeWidget, nil)
a := newAction(activeWidget, toolkit.Margin)
sendAction(a)
})
g.NewButton("Unmargin()", func () {
var a toolkit.Action
a.ActionType = toolkit.Unmargin
newaction(&a, activeWidget, nil)
a := newAction(activeWidget, toolkit.Unmargin)
sendAction(a)
})
g.NewButton("Pad()", func () {
var a toolkit.Action
a.ActionType = toolkit.Pad
newaction(&a, activeWidget, nil)
a := newAction(activeWidget, toolkit.Pad)
sendAction(a)
})
g.NewButton("Unpad()", func () {
var a toolkit.Action
a.ActionType = toolkit.Unpad
newaction(&a, activeWidget, nil)
a := newAction(activeWidget, toolkit.Unpad)
sendAction(a)
})
g.NewButton("Move(junk)", func () {
var a toolkit.Action
a.ActionType = toolkit.Move
newaction(&a, activeWidget, activeJunk)
a := newAction(activeWidget, toolkit.Move)
sendAction(a)
})
g.NewButton("Delete()", func () {
var a toolkit.Action
a.ActionType = toolkit.Delete
newaction(&a, activeWidget, activeJunk)
a := newAction(activeWidget, toolkit.Delete)
sendAction(a)
})
g = bugWidget.NewGroup("not working?")

View File

@ -203,6 +203,8 @@ func initToolkit(name string, filename string) *aplug {
return newPlug
}
// 2023/05/09 pretty clean
// 2023/04/06 Queue() is also being used and channels are being used. memcopy() only
func newAction(n *Node, atype toolkit.ActionType) *toolkit.Action {
var a toolkit.Action
a.ActionType = atype
@ -246,7 +248,7 @@ func sendAction(a *toolkit.Action) {
}
}
// 2023/04/06 Queue() is also being used and channels are being used. memcopy() only
/*
func newaction(a *toolkit.Action, n *Node, where *Node) {
// remove this
if (n != nil) {
@ -275,6 +277,7 @@ func newaction(a *toolkit.Action, n *Node, where *Node) {
sleep(.02)
}
}
*/
func (n *Node) InitEmbed(resFS embed.FS) *Node {
me.resFS = resFS