diff options
| author | Jeff Carr <[email protected]> | 2023-03-23 12:35:12 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2023-03-23 12:35:12 -0500 |
| commit | d4787a1ebdd08359746516dbb72f1feaf95be5b6 (patch) | |
| tree | cb81756d61096ccf74af7c8cc9a15e4e00fe1da7 /toolkit/andlabs/plugin.go | |
| parent | 6a848bf40474365cc1c0b4da9e2f7e3e10b4d627 (diff) | |
Squashed commit of the following:v0.7.3
boxes now exist and are tracked in the binary tree
create for group and grid works
gocui plugin no longer works. TODO: fix in next release
converted everything from plugin to Action()
can remove send()
tab and window are now action()
flags moved to action()
ready for new release
pad() margion() border() all work
move worked!
go.wit.com attept 578th try
adds an early grid widget. won't work until chan
andlabs/ui grid (X,Y) works right
actually can put things in places in a grid
Queue() means shit doesn't look right on grids
lots of fucking around. why am I wasting time on image?
wow. the crazy doAppend() thing is gone
implement Action Show() and Hide()
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'toolkit/andlabs/plugin.go')
| -rw-r--r-- | toolkit/andlabs/plugin.go | 253 |
1 files changed, 202 insertions, 51 deletions
diff --git a/toolkit/andlabs/plugin.go b/toolkit/andlabs/plugin.go index 8cac830..60cdbfa 100644 --- a/toolkit/andlabs/plugin.go +++ b/toolkit/andlabs/plugin.go @@ -19,73 +19,224 @@ import "git.wit.org/wit/gui/toolkit" // TODO: make sure you can't escape this goroutine // func Send(p *toolkit.Widget, c *toolkit.Widget) { - if (p == nil) { - log(debugPlugin, "Send() parent = nil") - } else { - log(debugPlugin, "Send() parent =", p.Name, ",", p.Type) + log(debugPlugin, "Send() goodbye. not used anymore") +} + +func Action(a *toolkit.Action) { + if (a == nil) { + log(debugPlugin, "Action = nil") + return + } + f := func() { + rawAction(a) } - log(debugPlugin, "Send() child =", c.Name, ",", c.Action, ",", c.Type) - /* - if (c.Action == "SetMargin") { - log(debugError, "need to implement SetMargin here") - setMargin(c, c.B) + // f() + Queue(f) +} + +func rawAction(a *toolkit.Action) { + + log(debugAction, "Action() START a.Type =", a.Type) + log(debugAction, "Action() START a.S =", a.S) + log(debugAction, "Action() START a.Widget =", a.Widget) + + switch a.Type { + case toolkit.Add: + add(a) + case toolkit.Show: + a.Widget.B = true + show(a.Widget) + case toolkit.Hide: + a.Widget.B = false + show(a.Widget) + case toolkit.Enable: + a.Widget.B = true + enable(a.Widget) + case toolkit.Disable: + a.Widget.B = false + enable(a.Widget) + case toolkit.Get: + setText(a) + case toolkit.GetText: + switch a.Widget.Type { + case toolkit.Textbox: + t := mapToolkits[a.Widget] + a.S = t.s + } + case toolkit.Set: + setText(a) + case toolkit.SetFlag: + flag(a) + case toolkit.SetText: + setText(a) + case toolkit.AddText: + setText(a) + case toolkit.Margin: + pad(a) + case toolkit.Unmargin: + pad(a) + case toolkit.Pad: + pad(a) + case toolkit.Unpad: + pad(a) + case toolkit.Delete: + uiDelete(a) + case toolkit.Flag: + flag(a) + case toolkit.Move: + log(debugNow, "attempt to move() =", a.Type, a.Widget) + move(a) + default: + log(debugError, "Action() Unknown =", a.Type, a.Widget) + } + log(debugAction, "Action() END =", a.Type, a.Widget) +} + +func flag(a *toolkit.Action) { + // log(debugFlags, "plugin Send() flag parent =", p.Name, p.Type) + // log(debugFlags, "plugin Send() flag child =", c.Name, c.Type) + // log(debugFlags, "plugin Send() flag child.Action =", c.Action) + // log(debugFlags, "plugin Send() flag child.S =", c.S) + // log(debugFlags, "plugin Send() flag child.B =", c.B) + // log(debugFlags, "plugin Send() what to flag?") + // should set the checkbox to this value + switch a.S { + case "Toolkit": + debugToolkit = a.B + case "Change": + debugChange = a.B + case "Plugin": + debugPlugin = a.B + case "Flags": + debugFlags = a.B + case "Error": + debugError = a.B + case "Now": + debugNow = a.B + case "Show": + ShowDebug() + default: + log(debugError, "Can't set unknown flag", a.S) + } +} + +func setText(a *toolkit.Action) { + w := a.Widget + if (w == nil) { + log(debugError, "setText error. w.Widget == nil") + actionDump(debugError, a) return } - */ + t := mapToolkits[w] + log(debugChange, "setText() Attempt on", w.Type, "with", a.S) - switch c.Type { + switch w.Type { case toolkit.Window: - doWindow(c) + t.uiWindow.SetTitle(a.S) case toolkit.Tab: - doTab(p, c) case toolkit.Group: - doGroup(p, c) - case toolkit.Button: - doButton(p, c) + t.uiGroup.SetTitle(a.S) case toolkit.Checkbox: - doCheckbox(p, c) - case toolkit.Label: - doLabel(p, c) + switch a.Type { + case toolkit.SetText: + t.uiCheckbox.SetText(a.S) + case toolkit.Get: + w.B = t.uiCheckbox.Checked() + case toolkit.Set: + t.uiCheckbox.SetChecked(a.B) + w.B = a.B + default: + log(debugError, "setText() unknown", a.Type, "on checkbox", w.Name) + } case toolkit.Textbox: - doTextbox(p, c) + switch a.Type { + case toolkit.Set: + t.uiMultilineEntry.SetText(a.S) + case toolkit.SetText: + t.uiMultilineEntry.SetText(a.S) + case toolkit.Get: + w.S = t.s + case toolkit.GetText: + w.S = t.s + default: + log(debugError, "setText() unknown", a.Type, "on checkbox", w.Name) + } + case toolkit.Label: + t.uiLabel.SetText(a.S) + case toolkit.Button: + t.uiButton.SetText(a.S) case toolkit.Slider: - doSlider(p, c) + switch a.Type { + case toolkit.Get: + w.I = t.uiSlider.Value() + case toolkit.Set: + t.uiSlider.SetValue(a.I) + default: + log(debugError, "setText() unknown", a.Type, "on checkbox", w.Name) + } case toolkit.Spinner: - doSpinner(p, c) + switch a.Type { + case toolkit.Get: + w.I = t.uiSpinbox.Value() + case toolkit.Set: + t.uiSpinbox.SetValue(a.I) + default: + log(debugError, "setText() unknown", a.Type, "on checkbox", w.Name) + } case toolkit.Dropdown: - doDropdown(p, c) + switch a.Type { + case toolkit.AddText: + AddDropdownName(a) + case toolkit.Set: + var orig int + var i int = -1 + var s string + orig = t.uiCombobox.Selected() + log(debugChange, "try to set the Dropdown to", a.S, "from", orig) + // try to find the string + for i, s = range t.val { + log(debugChange, "i, s", i, s) + if (a.S == s) { + t.uiCombobox.SetSelected(i) + log(debugChange, "setText() Dropdown worked.", w.S) + return + } + } + log(debugError, "setText() Dropdown did not find:", a.S) + // if i == -1, then there are not any things in the menu to select + if (i == -1) { + return + } + // if the string was never set, then set the dropdown to the last thing added to the menu + if (orig == -1) { + t.uiCombobox.SetSelected(i) + } + case toolkit.Get: + w.S = t.s + case toolkit.GetText: + w.S = t.s + default: + log(debugError, "setText() unknown", a.Type, "on checkbox", w.Name) + } case toolkit.Combobox: - doCombobox(p, c) - case toolkit.Grid: - doGrid(p, c) - case toolkit.Flag: - // log(debugFlags, "plugin Send() flag parent =", p.Name, p.Type) - // log(debugFlags, "plugin Send() flag child =", c.Name, c.Type) - // log(debugFlags, "plugin Send() flag child.Action =", c.Action) - // log(debugFlags, "plugin Send() flag child.S =", c.S) - // log(debugFlags, "plugin Send() flag child.B =", c.B) - // log(debugFlags, "plugin Send() what to flag?") - // should set the checkbox to this value - switch c.S { - case "Toolkit": - debugToolkit = c.B - case "Change": - debugChange = c.B - case "Plugin": - debugPlugin = c.B - case "Flags": - debugFlags = c.B - case "Error": - debugError = c.B - case "Show": - ShowDebug() + switch a.Type { + case toolkit.AddText: + t.AddComboboxName(a.S) + case toolkit.Set: + t.uiEditableCombobox.SetText(a.S) + t.s = a.S + case toolkit.SetText: + t.uiEditableCombobox.SetText(a.S) + t.s = a.S + case toolkit.Get: + w.S = t.s + case toolkit.GetText: + w.S = t.s default: - log(debugError, "Can't set unknown flag", c.S) + log(debugError, "setText() unknown", a.Type, "on checkbox", w.Name) } default: - log(debugError, "plugin Send() unknown parent =", p.Name, p.Type) - log(debugError, "plugin Send() unknown child =", c.Name, c.Type) - log(debugError, "plugin Send() Don't know how to do", c.Type, "yet") + log(debugError, "plugin Send() Don't know how to setText on", w.Type, "yet", a.Type) } } |
