prepare for protobuf

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-02-05 15:02:09 -06:00
parent 8fcf5f668b
commit a57a8b5a63
11 changed files with 33 additions and 29 deletions

View File

@ -60,7 +60,10 @@ func getNewAction(n *Node, atype widget.ActionType) *widget.Action {
// set state
a.State.ProgName = n.progname
a.State.Label = n.label
a.State.Value = n.value
// a.State.Value = n.value
a.State.DefaultS = n.defaultS
a.State.CurrentS = n.currentS
a.State.NewString = n.newString
a.State.Checked = n.checked
a.State.Visable = n.visable
@ -79,7 +82,7 @@ func getNewAction(n *Node, atype widget.ActionType) *widget.Action {
a.State.Range.High = n.Y
a.ProgName = n.progname
a.Value = n.value
// a.Value = n.value
a.Direction = n.direction
// These should be improved/deprecated based on the gui/widget docs

View File

@ -17,7 +17,7 @@ func (n *Node) addText(newS string) {
}
}
n.strings[newS] = highest + 1 // TODO: use the int's for the order
n.value = newS
n.newString = newS
/*
// time.Sleep(time.Duration(1000 * time.Nanosecond)) // doesn't work
// maybe this stupid chipset is defective. TODO: try on different hardware

View File

@ -99,7 +99,7 @@ func (n *Node) Bool() bool {
default:
}
return widget.GetBool(n.value)
return false
}
func (n *Node) Int() int {
@ -107,14 +107,13 @@ func (n *Node) Int() int {
return -1
}
return widget.GetInt(n.value)
return -1
}
func (n *Node) SetBool(b bool) {
switch n.WidgetType {
case widget.Checkbox:
n.checked = b
n.value = b
default:
log.Warn("WidgetType not bool", n.WidgetType, n.id)
}
@ -123,7 +122,7 @@ func (n *Node) SetBool(b bool) {
func (n *Node) SetInt(i int) {
switch n.WidgetType {
default:
n.value = i
// n.value = i
// log.Warn("WidgetType not bool", n.WidgetType, n.id)
}
}
@ -144,7 +143,7 @@ func (n *Node) String() string {
default:
}
return widget.GetString(n.value)
return widget.GetString(n.currentS)
}
func (n *Node) Strings() []string {
@ -181,8 +180,8 @@ func (n *Node) AppendText(str string) {
if !n.Ready() {
return
}
tmp := widget.GetString(n.value) + str
n.value = tmp
tmp := n.currentS + str
n.newString = tmp
n.changed = true
// inform the toolkits

View File

@ -64,10 +64,10 @@ func (n *Node) dumpWidget(b bool) string {
if b {
switch n.WidgetType {
case widget.Combobox:
logindent(b, listChildrenDepth, defaultPadding, " Dropdown", n.value)
logindent(b, listChildrenDepth, defaultPadding, " Dropdown", n.currentS)
logindent(b, listChildrenDepth, defaultPadding, " Dropdown", n.strings)
case widget.Dropdown:
logindent(b, listChildrenDepth, defaultPadding, " Dropdown", n.value)
logindent(b, listChildrenDepth, defaultPadding, " Dropdown", n.currentS)
logindent(b, listChildrenDepth, defaultPadding, " Dropdown", n.strings)
case widget.Grid:
logindent(b, listChildrenDepth, defaultPadding, " GridSize =", n.X, n.Y)

View File

@ -143,7 +143,7 @@ func (n *Node) gotUserEvent(a widget.Action) {
default:
}
n.value = a.Value
n.currentS = a.State.CurrentS
log.Log(CHANGE, "gotUserEvent() n.Bool() =", n.Bool(), "n.String() =", n.String())
if n.Custom == nil {
log.Log(CHANGE, "a Custom() function was not set for this widget")

View File

@ -13,7 +13,7 @@ and it initializes basic default values
there isn't much to see here.
*/
func (n *Node) newNode(title string, t widget.WidgetType) *Node {
func (n *Node) newNode(s string, t widget.WidgetType) *Node {
if n == nil {
log.Warn("newNode got parent == nil")
panic("gui newNode")
@ -21,8 +21,11 @@ func (n *Node) newNode(title string, t widget.WidgetType) *Node {
var newN *Node
newN = addNode()
newN.progname = title
newN.value = title
newN.progname = s
newN.label = s
newN.defaultS = s
newN.newString = s
newN.currentS = s
newN.WidgetType = t
newN.strings = make(map[string]int)

View File

@ -16,10 +16,6 @@ func (n *Node) SetLabel(label string) *Node {
n.label = label
case widget.Button:
n.label = label
case widget.Combobox:
n.label = label
case widget.Dropdown:
n.label = label
case widget.Label:
n.label = label
case widget.Group:
@ -30,7 +26,7 @@ func (n *Node) SetLabel(label string) *Node {
}
n.changed = true
log.Log(CHANGE, "SetLabel() value =", label)
log.Log(CHANGE, "SetLabel() =", label)
// inform the toolkits
sendAction(n, widget.SetText)
@ -40,7 +36,7 @@ func (n *Node) SetLabel(label string) *Node {
// What "SetText" means depends on the type of widget
// should this be a different name?
func (n *Node) SetText(text string) *Node {
n.value = text
n.newString = text
n.changed = true
log.Log(CHANGE, "SetText() text =", text)
@ -54,15 +50,15 @@ func (n *Node) SetText(text string) *Node {
case widget.Group:
n.label = text
case widget.Combobox:
n.label = text
n.newString = text
case widget.Dropdown:
n.label = text
n.newString = text
case widget.Window:
n.label = text
default:
}
// inform the toolkits
sendAction(n, widget.Set)
sendAction(n, widget.SetText)
return n
}

View File

@ -96,7 +96,10 @@ type Node struct {
WidgetType widget.WidgetType
// most widgets need one value, this is current alue
value any
// value any
defaultS string
newString string
currentS string
//
label string

View File

@ -8,7 +8,7 @@ import (
func (parent *Node) NewTextbox(name string) *Node {
newNode := parent.newNode(name, widget.Textbox)
newNode.value = name
newNode.defaultS = name
newNode.progname = name
newNode.Custom = func() {
@ -22,7 +22,7 @@ func (parent *Node) NewTextbox(name string) *Node {
func (parent *Node) NewEntryLine(name string) *Node {
newNode := parent.newNode(name, widget.Textbox)
newNode.value = name
newNode.defaultS = name
newNode.progname = name
newNode.X = 1

View File

@ -19,6 +19,7 @@ func Watchdog() {
myTicker(10*time.Second, "WATCHDOG", func() {
i += 1
log.Log(INFO, "myTicker() ticked", i)
me.rootNode.ListToolkits()
})
}

View File

@ -29,7 +29,6 @@ func (parent *Node) NewWindow(title string) *Node {
log.Log(INFO, "NewWindow()", title)
newNode.progname = title
newNode.label = title
newNode.value = title
newNode.margin = true
newNode.visable = true
newNode.hidden = false