diff options
| author | Jeff Carr <[email protected]> | 2023-03-03 14:41:38 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2023-03-03 14:41:38 -0600 |
| commit | 49202eeafdad8e5780fefdad3d2f87fd4354725e (patch) | |
| tree | 5d749b5d4835c7a0395bd1f87b5d2d1d91b14a08 /toolkit/andlabs/combobox.go | |
| parent | 80317ec89c94beadcbf3775f84c6010b5ceef302 (diff) | |
release as v0.6.5v0.6.5
good standard release
really clean interaction to plugin
really clean debug flags implementation
common doAppend() idea, but it probably won't work
re-implement combobox. this code base almost doesn't suck
slider & spinner set values now
tab set margin works
convert dropdown to Send()
lots of other changes to try to implement single line Entry()
I guess use golang file names even though internalally the go developers
use underscore chars in the actual go sources.
Maybe there is a reason for that?
go channel debug window does something
make a debug window for channels. add sample icons
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'toolkit/andlabs/combobox.go')
| -rw-r--r-- | toolkit/andlabs/combobox.go | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/toolkit/andlabs/combobox.go b/toolkit/andlabs/combobox.go new file mode 100644 index 0000000..08e7148 --- /dev/null +++ b/toolkit/andlabs/combobox.go @@ -0,0 +1,100 @@ +package main + +import ( + "github.com/andlabs/ui" + _ "github.com/andlabs/ui/winmanifest" + "git.wit.org/wit/gui/toolkit" +) + +func (t *andlabsT) newCombobox(w *toolkit.Widget) *andlabsT { + var newt andlabsT + log(debugToolkit, "newCombobox() START", w.Name) + + if t.broken() { + return nil + } + + newt.tw = w + s := ui.NewEditableCombobox() + newt.uiEditableCombobox = s + newt.uiBox = t.uiBox + t.uiBox.Append(s, stretchy) + + // initialize the index + newt.c = 0 + newt.val = make(map[int]string) + + s.OnChanged(func(spin *ui.EditableCombobox) { + newt.tw.S = spin.Text() + newt.commonChange(newt.tw) + }) + + return &newt +} + +func (t *andlabsT) AddComboboxName(title string) { + t.uiEditableCombobox.Append(title) + if (t.val == nil) { + log(debugToolkit, "make map didn't work") + return + } + t.val[t.c] = title + + // If this is the first menu added, set the dropdown to it + // if (t.c == 0) { + // } + t.c = t.c + 1 +} + +func newCombobox(parentW *toolkit.Widget, w *toolkit.Widget) { + log(debugToolkit, "newCombobox()", w.Name) + + t := mapToolkits[parentW] + if (t == nil) { + log(debugToolkit, "newCombobox() toolkit struct == nil. name=", parentW.Name, w.Name) + listMap(debugToolkit) + return + } + newt := t.newCombobox(w) + mapWidgetsToolkits(w, newt) +} + +func doCombobox(p *toolkit.Widget, c *toolkit.Widget) { + if broken(c) { + return + } + if (c.Action == "New") { + newCombobox(p, c) + return + } + ct := mapToolkits[c] + if (ct == nil) { + log(true, "Trying to do something on a widget that doesn't work or doesn't exist or something", c) + return + } + if ct.broken() { + log(true, "Combobox() ct.broken", ct) + return + } + if (ct.uiEditableCombobox == nil) { + log(true, "Combobox() uiEditableCombobox == nil", ct) + return + } + log(true, "Going to attempt:", c.Action) + switch c.Action { + case "Add": + ct.AddComboboxName(c.S) + case "Enable": + ct.uiEditableCombobox.Enable() + case "Disable": + ct.uiEditableCombobox.Disable() + case "Show": + ct.uiEditableCombobox.Show() + case "Hide": + ct.uiEditableCombobox.Hide() + case "Set": + ct.uiEditableCombobox.SetText(c.S) + default: + log(true, "Can't do", c.Action, "to a Combobox") + } +} |
