diff --git a/toolkit/andlabs/box.go b/toolkit/andlabs/box.go index 0a6b7e4..8698a74 100644 --- a/toolkit/andlabs/box.go +++ b/toolkit/andlabs/box.go @@ -12,7 +12,7 @@ func (p *node) newBox(n *node) { newt := new(andlabsT) var box *ui.Box - log(debugToolkit, "rawBox() create", newt.Name) + log(debugToolkit, "rawBox() create", n.Name) if (n.B) { box = ui.NewHorizontalBox() diff --git a/toolkit/andlabs/checkbox.go b/toolkit/andlabs/checkbox.go index b822ca1..4c690c1 100644 --- a/toolkit/andlabs/checkbox.go +++ b/toolkit/andlabs/checkbox.go @@ -13,8 +13,8 @@ func (p *node) newCheckbox(n *node) { newt.uiControl = newt.uiCheckbox newt.uiCheckbox.OnToggled(func(spin *ui.Checkbox) { - newt.b = newt.checked() - log(debugChange, "val =", newt.b) + n.B = newt.checked() + log(debugChange, "val =", n.B) n.doUserEvent() }) diff --git a/toolkit/andlabs/debug.go b/toolkit/andlabs/debug.go index 5ecd1fc..cc32b71 100644 --- a/toolkit/andlabs/debug.go +++ b/toolkit/andlabs/debug.go @@ -1,6 +1,6 @@ package main -// import "git.wit.org/wit/gui/toolkit" +import "git.wit.org/wit/gui/toolkit" var defaultBehavior bool = true @@ -50,7 +50,7 @@ func (t *andlabsT) Dump(b bool) { if ! b { return } - log(b, "Name = ", t.Name, t.Width, t.Height) + log(b, "Name = ", t.Width, t.Height) if (t.uiBox != nil) { log(b, "uiBox =", t.uiBox) } @@ -88,3 +88,25 @@ func GetDebugToolkit () bool { return debugToolkit } */ + +func flag(a *toolkit.Action) { + // 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) + } +} diff --git a/toolkit/andlabs/delete.go b/toolkit/andlabs/delete.go index f171344..82727fe 100644 --- a/toolkit/andlabs/delete.go +++ b/toolkit/andlabs/delete.go @@ -22,7 +22,7 @@ func (n *node) destroy() { switch n.WidgetType { case toolkit.Button: - log(true, "Should delete Button here:", ct.Name) + log(true, "Should delete Button here:", n.Name) log(true, "Parent:") pt.Dump(true) log(true, "Child:") @@ -30,7 +30,7 @@ func (n *node) destroy() { if (pt.uiBox == nil) { log(true, "Don't know how to destroy this") } else { - log(true, "Fuck it, destroy the whole box", pt.Name) + log(true, "Fuck it, destroy the whole box", n.parent.Name) // pt.uiBox.Destroy() // You have a bug: You cannot destroy a uiControl while it still has a parent. pt.uiBox.SetPadded(false) pt.uiBox.Delete(4) @@ -40,7 +40,7 @@ func (n *node) destroy() { } case toolkit.Window: - log(true, "Should delete Window here:", ct.Name) + log(true, "Should delete Window here:", n.Name) default: log(true, "Fuckit, let's destroy a button") if (ct.uiButton != nil) { diff --git a/toolkit/andlabs/dropdown.go b/toolkit/andlabs/dropdown.go index bf66e41..d98526a 100644 --- a/toolkit/andlabs/dropdown.go +++ b/toolkit/andlabs/dropdown.go @@ -22,10 +22,11 @@ func (p *node) newDropdown(n *node) { cb.OnSelected(func(spin *ui.Combobox) { i := spin.Selected() if (newt.val == nil) { - log(debugChange, "make map didn't work") - newt.text = "error" + log(logError, "make map didn't work") + n.S = "map did not work. ui.Combobox error" + } else { + n.S = newt.val[i] } - n.S = newt.val[i] n.doUserEvent() }) diff --git a/toolkit/andlabs/image.go b/toolkit/andlabs/image.go index 0b1f785..a565376 100644 --- a/toolkit/andlabs/image.go +++ b/toolkit/andlabs/image.go @@ -9,9 +9,8 @@ import ( func (p *node) newImage(n *node) { newt := new(andlabsT) var img *ui.Image - newt.Name = n.Name - log(debugToolkit, "rawImage() create", newt.Name) + log(debugToolkit, "rawImage() create", n.Name) img = ui.NewImage(16, 16) diff --git a/toolkit/andlabs/plugin.go b/toolkit/andlabs/setText.go similarity index 72% rename from toolkit/andlabs/plugin.go rename to toolkit/andlabs/setText.go index a1e69f5..11de327 100644 --- a/toolkit/andlabs/plugin.go +++ b/toolkit/andlabs/setText.go @@ -4,34 +4,6 @@ import ( "git.wit.org/wit/gui/toolkit" ) -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 (n *node) setText(a *toolkit.Action) { t := n.tk if (t == nil) { @@ -52,13 +24,12 @@ func (n *node) setText(a *toolkit.Action) { case toolkit.SetText: t.uiCheckbox.SetText(a.S) case toolkit.Get: - t.b = t.uiCheckbox.Checked() + n.B = t.uiCheckbox.Checked() case toolkit.Set: // TODO: commented out while working on chan - t.b = a.B - t.uiCheckbox.SetChecked(t.b) + t.uiCheckbox.SetChecked(a.B) default: - log(debugError, "setText() unknown", a.ActionType, "on checkbox", t.Name) + log(debugError, "setText() unknown", a.ActionType, "on checkbox", n.Name) } case toolkit.Textbox: switch a.ActionType { @@ -67,7 +38,7 @@ func (n *node) setText(a *toolkit.Action) { case toolkit.SetText: t.uiMultilineEntry.SetText(a.S) default: - log(debugError, "setText() unknown", a.ActionType, "on checkbox", t.Name) + log(debugError, "setText() unknown", a.ActionType, "on checkbox", n.Name) } case toolkit.Label: t.uiLabel.SetText(a.S) @@ -76,20 +47,20 @@ func (n *node) setText(a *toolkit.Action) { case toolkit.Slider: switch a.ActionType { case toolkit.Get: - t.i = t.uiSlider.Value() + n.I = t.uiSlider.Value() case toolkit.Set: t.uiSlider.SetValue(a.I) default: - log(debugError, "setText() unknown", a.ActionType, "on checkbox", t.Name) + log(debugError, "setText() unknown", a.ActionType, "on checkbox", n.Name) } case toolkit.Spinner: switch a.ActionType { case toolkit.Get: - t.i = t.uiSpinbox.Value() + n.I = t.uiSpinbox.Value() case toolkit.Set: t.uiSpinbox.SetValue(a.I) default: - log(debugError, "setText() unknown", a.ActionType, "on checkbox", t.Name) + log(debugError, "setText() unknown", a.ActionType, "on checkbox", n.Name) } case toolkit.Dropdown: switch a.ActionType { @@ -106,7 +77,7 @@ func (n *node) setText(a *toolkit.Action) { log(debugChange, "i, s", i, s) if (a.S == s) { t.uiCombobox.SetSelected(i) - log(debugChange, "setText() Dropdown worked.", t.s) + log(debugChange, "setText() Dropdown worked.", n.S) return } } @@ -124,7 +95,7 @@ func (n *node) setText(a *toolkit.Action) { case toolkit.GetText: // t.S = t.s default: - log(debugError, "setText() unknown", a.ActionType, "on checkbox", t.Name) + log(debugError, "setText() unknown", a.ActionType, "on checkbox", n.Name) } case toolkit.Combobox: switch a.ActionType { @@ -132,12 +103,12 @@ func (n *node) setText(a *toolkit.Action) { t.AddComboboxName(a.S) case toolkit.Set: t.uiEditableCombobox.SetText(a.S) - t.s = a.S + n.S = a.S case toolkit.SetText: t.uiEditableCombobox.SetText(a.S) - t.s = a.S + n.S = a.S default: - log(debugError, "setText() unknown", a.ActionType, "on checkbox", t.Name) + log(debugError, "setText() unknown", a.ActionType, "on checkbox", n.Name) } default: log(debugError, "plugin Send() Don't know how to setText on", n.WidgetType, "yet", a.ActionType) diff --git a/toolkit/andlabs/structs.go b/toolkit/andlabs/structs.go index c2f1d11..ac35183 100644 --- a/toolkit/andlabs/structs.go +++ b/toolkit/andlabs/structs.go @@ -38,12 +38,6 @@ type node struct { // stores the raw toolkit internals type andlabsT struct { - // wId int // widget ID - // WidgetType toolkit.WidgetType - - Name string - Text string - // Type toolkit.WidgetType Width int Height int @@ -66,8 +60,9 @@ type andlabsT struct { uiWindow *ui.Window uiMultilineEntry *ui.MultilineEntry uiEditableCombobox *ui.EditableCombobox - uiGrid *ui.Grid uiImage *ui.Image + + uiGrid *ui.Grid gridX int gridY int @@ -75,13 +70,8 @@ type andlabsT struct { // this is probably fucked up and in many ways wrong because of unsafe goroutine threading // but it's working for now due to the need for need for a correct interaction layer betten toolkits c int - i int - b bool - s string val map[int]string // andlabs/ui only accesses widget id numbers - boxC int // how many things on in a box - boxW map[int]int // find a widget in a box - text string + boxC int // how many things on in a box or how many tabs }