correctly deprecate *widget to plugins
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
45d43c3616
commit
57283a4da7
|
@ -9,8 +9,6 @@ func (n *Node) NewButton(name string, custom func()) *Node {
|
|||
a.Name = name
|
||||
a.Text = name
|
||||
a.ActionType = toolkit.Add
|
||||
// deprecate this once andlabs is refactored
|
||||
a.Callback = callback
|
||||
newaction(&a, newNode, n)
|
||||
|
||||
return newNode
|
||||
|
|
10
plugin.go
10
plugin.go
|
@ -251,21 +251,15 @@ func loadfile(filename string) *plugin.Plugin {
|
|||
return plug
|
||||
}
|
||||
|
||||
// Sends a widget and what to do with it to the plugin
|
||||
// parent = n, child = c
|
||||
|
||||
// THIS COPIES THE WIDGET STRUCT 2023/03/16 as it's not crashing. Queue() is also being used
|
||||
// never mind that comment. no it doesn't
|
||||
// 2023/04/06 Queue() is also being used and channels are being used. memcopy() only
|
||||
func newaction(a *toolkit.Action, n *Node, where *Node) {
|
||||
if (n != nil) {
|
||||
a.Widget = &n.widget
|
||||
a.WidgetId = n.id
|
||||
a.WidgetType = n.widget.Type
|
||||
a.ActionType = a.ActionType
|
||||
}
|
||||
// action(&a, newNode, n)
|
||||
// newaction(&a, newNode, n)
|
||||
|
||||
// TODO: redo this grid logic
|
||||
if (where != nil) {
|
||||
log(debugGui, "Action() START on where X,Y, Next X,Y =", where.Name, where.X, where.Y, where.NextX, where.NextY)
|
||||
a.ParentId = where.id
|
||||
|
|
|
@ -8,9 +8,7 @@ import (
|
|||
|
||||
func (t *andlabsT) newCheckbox(a *toolkit.Action) *andlabsT {
|
||||
var newt andlabsT
|
||||
w := a.Widget
|
||||
log(debugToolkit, "newCheckbox()", a.Name, a.WidgetType)
|
||||
newt.tw = w
|
||||
newt.WidgetType = a.WidgetType
|
||||
newt.wId = a.WidgetId
|
||||
newt.Name = a.Name
|
||||
|
@ -21,7 +19,7 @@ func (t *andlabsT) newCheckbox(a *toolkit.Action) *andlabsT {
|
|||
|
||||
newt.uiCheckbox.OnToggled(func(spin *ui.Checkbox) {
|
||||
newt.b = newt.checked()
|
||||
log(debugChange, "val =", newt.tw.B)
|
||||
log(debugChange, "val =", newt.b)
|
||||
newt.doUserEvent()
|
||||
})
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package main
|
||||
|
||||
import "git.wit.org/wit/gui/toolkit"
|
||||
// import "git.wit.org/wit/gui/toolkit"
|
||||
|
||||
var defaultBehavior bool = true
|
||||
|
||||
|
@ -81,26 +81,6 @@ func (t *andlabsT) Dump(b bool) {
|
|||
if (t.uiCheckbox != nil) {
|
||||
log(b, "uiCheckbox =", t.uiCheckbox)
|
||||
}
|
||||
widgetDump(b, t.tw)
|
||||
}
|
||||
|
||||
func widgetDump(b bool, w *toolkit.Widget) {
|
||||
if (w == nil) {
|
||||
log(b, "widget = nil")
|
||||
return
|
||||
}
|
||||
|
||||
/*
|
||||
log(b, "widget.Name =", w.Name)
|
||||
log(b, "widget.Type =", w.Type)
|
||||
log(b, "widget.Custom =", w.Custom)
|
||||
log(b, "widget.B =", w.B)
|
||||
log(b, "widget.I =", w.I)
|
||||
log(b, "widget.Width =", w.Width)
|
||||
log(b, "widget.Height =", w.Height)
|
||||
log(b, "widget.X =", w.X)
|
||||
log(b, "widget.Y =", w.Y)
|
||||
*/
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -8,10 +8,8 @@ import (
|
|||
|
||||
func (t *andlabsT) newDropdown(a *toolkit.Action) *andlabsT {
|
||||
var newt andlabsT
|
||||
w := a.Widget
|
||||
log(debugToolkit, "gui.Toolbox.newDropdown() START", a.Name)
|
||||
|
||||
newt.tw = w
|
||||
newt.WidgetType = a.WidgetType
|
||||
newt.wId = a.WidgetId
|
||||
s := ui.NewCombobox()
|
||||
|
@ -35,7 +33,7 @@ func (t *andlabsT) newDropdown(a *toolkit.Action) *andlabsT {
|
|||
return &newt
|
||||
}
|
||||
|
||||
func (t *andlabsT) AddDropdownName(title string) {
|
||||
func (t *andlabsT) addDropdownName(title string) {
|
||||
t.uiCombobox.Append(title)
|
||||
if (t.val == nil) {
|
||||
log(debugToolkit, "make map didn't work")
|
||||
|
@ -64,7 +62,7 @@ func AddDropdownName(a *toolkit.Action) {
|
|||
listMap(debugToolkit)
|
||||
return
|
||||
}
|
||||
t.AddDropdownName(a.S)
|
||||
t.addDropdownName(a.S)
|
||||
}
|
||||
|
||||
func SetDropdownName(a *toolkit.Action, s string) {
|
||||
|
@ -78,7 +76,7 @@ func SetDropdownName(a *toolkit.Action, s string) {
|
|||
}
|
||||
t.SetDropdown(1)
|
||||
// TODO: send back to wit/gui goroutine with the chan
|
||||
t.tw.S = s
|
||||
t.s = s
|
||||
}
|
||||
|
||||
func newDropdown(a *toolkit.Action) {
|
||||
|
|
|
@ -21,7 +21,6 @@ func newGrid(a *toolkit.Action) {
|
|||
c := ui.NewGrid()
|
||||
newt.uiGrid = c
|
||||
newt.uiControl = c
|
||||
newt.tw = a.Widget
|
||||
newt.WidgetType = toolkit.Grid
|
||||
newt.gridX = 0
|
||||
newt.gridY = 0
|
||||
|
|
|
@ -31,15 +31,6 @@ func Action(a *toolkit.Action) {
|
|||
rawAction(a)
|
||||
}
|
||||
|
||||
/*
|
||||
if (callback == nil) {
|
||||
if (a.Callback != nil) {
|
||||
log(debugNow, "setting Callback", a.Callback)
|
||||
callback = a.Callback
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// f()
|
||||
Queue(f)
|
||||
}
|
||||
|
@ -48,7 +39,6 @@ func rawAction(a *toolkit.Action) {
|
|||
|
||||
log(debugAction, "Action() START a.ActionType =", a.ActionType)
|
||||
log(debugAction, "Action() START a.S =", a.S)
|
||||
log(debugAction, "Action() START a.Widget =", a.Widget)
|
||||
|
||||
log(logInfo, "Action() START a.WidgetId =", a.WidgetId, "a.ParentId =", a.ParentId)
|
||||
switch a.WidgetType {
|
||||
|
@ -61,21 +51,21 @@ func rawAction(a *toolkit.Action) {
|
|||
case toolkit.Add:
|
||||
add(a)
|
||||
case toolkit.Show:
|
||||
a.Widget.B = true
|
||||
a.B = true
|
||||
show(a)
|
||||
case toolkit.Hide:
|
||||
a.Widget.B = false
|
||||
a.B = false
|
||||
show(a)
|
||||
case toolkit.Enable:
|
||||
a.Widget.B = true
|
||||
a.B = true
|
||||
enable(a)
|
||||
case toolkit.Disable:
|
||||
a.Widget.B = false
|
||||
a.B = false
|
||||
enable(a)
|
||||
case toolkit.Get:
|
||||
setText(a)
|
||||
case toolkit.GetText:
|
||||
switch a.Widget.Type {
|
||||
switch a.WidgetType {
|
||||
case toolkit.Textbox:
|
||||
t := andlabs[a.WidgetId]
|
||||
a.S = t.s
|
||||
|
@ -97,12 +87,12 @@ func rawAction(a *toolkit.Action) {
|
|||
case toolkit.Delete:
|
||||
uiDelete(a)
|
||||
case toolkit.Move:
|
||||
log(debugNow, "attempt to move() =", a.ActionType, a.Widget)
|
||||
log(debugNow, "attempt to move() =", a.ActionType, a.WidgetType)
|
||||
move(a)
|
||||
default:
|
||||
log(debugError, "Action() Unknown =", a.ActionType, a.Widget)
|
||||
log(debugError, "Action() Unknown =", a.ActionType, a.WidgetType)
|
||||
}
|
||||
log(debugAction, "Action() END =", a.ActionType, a.Widget)
|
||||
log(debugAction, "Action() END =", a.ActionType, a.WidgetType)
|
||||
}
|
||||
|
||||
func flag(a *toolkit.Action) {
|
||||
|
@ -153,11 +143,11 @@ func setText(a *toolkit.Action) {
|
|||
case toolkit.SetText:
|
||||
t.uiCheckbox.SetText(a.S)
|
||||
case toolkit.Get:
|
||||
t.tw.B = t.uiCheckbox.Checked()
|
||||
t.b = t.uiCheckbox.Checked()
|
||||
case toolkit.Set:
|
||||
// TODO: commented out while working on chan
|
||||
// t.uiCheckbox.SetChecked(a.B)
|
||||
t.tw.B = a.B
|
||||
t.b = a.B
|
||||
t.uiCheckbox.SetChecked(t.b)
|
||||
default:
|
||||
log(debugError, "setText() unknown", a.ActionType, "on checkbox", t.Name)
|
||||
}
|
||||
|
@ -167,10 +157,6 @@ func setText(a *toolkit.Action) {
|
|||
t.uiMultilineEntry.SetText(a.S)
|
||||
case toolkit.SetText:
|
||||
t.uiMultilineEntry.SetText(a.S)
|
||||
case toolkit.Get:
|
||||
t.tw.S = t.s
|
||||
case toolkit.GetText:
|
||||
t.tw.S = t.s
|
||||
default:
|
||||
log(debugError, "setText() unknown", a.ActionType, "on checkbox", t.Name)
|
||||
}
|
||||
|
@ -181,7 +167,7 @@ func setText(a *toolkit.Action) {
|
|||
case toolkit.Slider:
|
||||
switch a.ActionType {
|
||||
case toolkit.Get:
|
||||
t.tw.I = t.uiSlider.Value()
|
||||
t.i = t.uiSlider.Value()
|
||||
case toolkit.Set:
|
||||
t.uiSlider.SetValue(a.I)
|
||||
default:
|
||||
|
@ -190,7 +176,7 @@ func setText(a *toolkit.Action) {
|
|||
case toolkit.Spinner:
|
||||
switch a.ActionType {
|
||||
case toolkit.Get:
|
||||
t.tw.I = t.uiSpinbox.Value()
|
||||
t.i = t.uiSpinbox.Value()
|
||||
case toolkit.Set:
|
||||
t.uiSpinbox.SetValue(a.I)
|
||||
default:
|
||||
|
@ -211,7 +197,7 @@ func setText(a *toolkit.Action) {
|
|||
log(debugChange, "i, s", i, s)
|
||||
if (a.S == s) {
|
||||
t.uiCombobox.SetSelected(i)
|
||||
log(debugChange, "setText() Dropdown worked.", t.tw.S)
|
||||
log(debugChange, "setText() Dropdown worked.", t.s)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
@ -225,9 +211,9 @@ func setText(a *toolkit.Action) {
|
|||
t.uiCombobox.SetSelected(i)
|
||||
}
|
||||
case toolkit.Get:
|
||||
t.tw.S = t.s
|
||||
// t.S = t.s
|
||||
case toolkit.GetText:
|
||||
t.tw.S = t.s
|
||||
// t.S = t.s
|
||||
default:
|
||||
log(debugError, "setText() unknown", a.ActionType, "on checkbox", t.Name)
|
||||
}
|
||||
|
@ -241,10 +227,6 @@ func setText(a *toolkit.Action) {
|
|||
case toolkit.SetText:
|
||||
t.uiEditableCombobox.SetText(a.S)
|
||||
t.s = a.S
|
||||
case toolkit.Get:
|
||||
t.tw.S = t.s
|
||||
case toolkit.GetText:
|
||||
t.tw.S = t.s
|
||||
default:
|
||||
log(debugError, "setText() unknown", a.ActionType, "on checkbox", t.Name)
|
||||
}
|
||||
|
|
|
@ -9,12 +9,10 @@ import (
|
|||
|
||||
func (t *andlabsT) newSlider(a *toolkit.Action) *andlabsT {
|
||||
var newt andlabsT
|
||||
w := a.Widget
|
||||
|
||||
s := ui.NewSlider(a.X, a.Y)
|
||||
newt.uiSlider = s
|
||||
newt.uiControl = s
|
||||
newt.tw = w
|
||||
newt.WidgetType = toolkit.Slider
|
||||
newt.wId = a.WidgetId
|
||||
|
||||
|
|
|
@ -9,13 +9,10 @@ import (
|
|||
|
||||
func (t *andlabsT) newSpinner(a *toolkit.Action) *andlabsT {
|
||||
var newt andlabsT
|
||||
w := a.Widget
|
||||
// log(debugToolkit, "newSpinner()", w.X, w.Y)
|
||||
|
||||
s := ui.NewSpinbox(a.X, a.Y)
|
||||
newt.uiSpinbox = s
|
||||
newt.uiControl = s
|
||||
newt.tw = w
|
||||
newt.wId = a.WidgetId
|
||||
newt.WidgetType = toolkit.Spinner
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ type andlabsT struct {
|
|||
Width int
|
||||
Height int
|
||||
|
||||
tw *toolkit.Widget
|
||||
// tw *toolkit.Widget
|
||||
parent *andlabsT
|
||||
|
||||
uiControl ui.Control
|
||||
|
|
|
@ -8,26 +8,26 @@ import (
|
|||
)
|
||||
|
||||
// func newTextbox(a *toolkit.Action) {
|
||||
func (t *andlabsT) newTextbox(w *toolkit.Widget) *andlabsT {
|
||||
func (t *andlabsT) newTextbox() *andlabsT {
|
||||
var newt andlabsT
|
||||
|
||||
c := ui.NewNonWrappingMultilineEntry()
|
||||
newt.uiMultilineEntry = c
|
||||
newt.uiControl = c
|
||||
|
||||
newt.tw = w
|
||||
newt.WidgetType = toolkit.Textbox
|
||||
|
||||
c.OnChanged(func(spin *ui.MultilineEntry) {
|
||||
t.s = spin.Text()
|
||||
newt.s = spin.Text()
|
||||
// this is still dangerous
|
||||
log(debugChange, "Not yet safe to trigger on change for ui.MultilineEntry")
|
||||
newt.s = spin.Text()
|
||||
newt.doUserEvent()
|
||||
})
|
||||
return &newt
|
||||
}
|
||||
|
||||
func newTextbox(a *toolkit.Action) {
|
||||
w := a.Widget
|
||||
log(debugToolkit, "newCombobox()", a.Name)
|
||||
|
||||
t := andlabs[a.ParentId]
|
||||
|
@ -36,7 +36,8 @@ func newTextbox(a *toolkit.Action) {
|
|||
listMap(debugToolkit)
|
||||
return
|
||||
}
|
||||
newt := t.newTextbox(w)
|
||||
newt := t.newTextbox()
|
||||
newt.Name = a.Name
|
||||
newt.wId = a.WidgetId
|
||||
place(a, t, newt)
|
||||
}
|
||||
|
|
|
@ -53,8 +53,7 @@ type Action struct {
|
|||
|
||||
// this should be the widget
|
||||
// if the action is New, Hide, Enable, etc
|
||||
Widget *Widget
|
||||
Callback func(int) bool
|
||||
// Widget *Widget
|
||||
|
||||
// This is how the values are passed back and forth
|
||||
// values from things like checkboxes & dropdown's
|
||||
|
|
Loading…
Reference in New Issue