From 49202eeafdad8e5780fefdad3d2f87fd4354725e Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Fri, 3 Mar 2023 14:41:38 -0600 Subject: release as v0.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 --- toolkit/andlabs/common.go | 143 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 141 insertions(+), 2 deletions(-) (limited to 'toolkit/andlabs/common.go') diff --git a/toolkit/andlabs/common.go b/toolkit/andlabs/common.go index 31b73e6..d2811cb 100644 --- a/toolkit/andlabs/common.go +++ b/toolkit/andlabs/common.go @@ -2,6 +2,7 @@ package main import ( "git.wit.org/wit/gui/toolkit" + "github.com/davecgh/go-spew/spew" ) // This is important. This sets the defaults for the gui. Without this, there isn't correct padding, etc @@ -11,7 +12,7 @@ func init() { setDefaultBehavior(true) } -func (t andlabsT) commonChange(tw *toolkit.Widget) { +func (t *andlabsT) commonChange(tw *toolkit.Widget) { log(debugChange, "commonChange() START widget =", t.Name, t.Type) if (tw == nil) { log(true, "commonChange() What the fuck. there is no widget t.tw == nil") @@ -35,7 +36,7 @@ func (t *andlabsT) broken() bool { if (t.uiBox == nil) { if (t.uiWindow != nil) { log(debugToolkit, "UiBox == nil. This is an empty window. Try to add a box") - t.NewBox() + t.newBox() return false } log(true, "UiBox == nil. I can't add a widget without a place to put it") @@ -60,3 +61,141 @@ func broken(w *toolkit.Widget) bool { } return false } + +func dump(p *toolkit.Widget, c *toolkit.Widget, b bool) { + log(b, "Parent:") + pt := mapToolkits[p] + if (pt == nil) { + log(b, "Trying to do something on a widget that doesn't work or doesn't exist or something", c) + return + } + pt.Dump(b) + + log(b, "Child:") + ct := mapToolkits[c] + if (ct == nil) { + log(b, "Trying to do something on a widget that doesn't work or doesn't exist or something", c) + return + } + ct.Dump(b) +} + +func setMarginNew(w *toolkit.Widget, b bool) { + wt := mapToolkits[w] + log(true, "START setMarginNew", w.Name) + if (wt == nil) { + return + } + if (wt.uiGroup != nil) { + log(true, "uiGroup.SetMargined(true)") + wt.uiGroup.SetMargined(b) + } + if (wt.uiTab != nil) { + i := wt.uiTab.NumPages() + log(true, "tab.NumPages() =", i) + for i > 0 { + i -= 1 + log(true, "uiTab.SetMargined(true) for i =", i) + wt.uiTab.SetMargined(i, b) + } + } else { + log(true, "no uitab") + } + if (wt.uiWindow != nil) { + log(true, "uiWindow.SetMargined(true)") + wt.uiWindow.SetMargined(b) + } + log(true, "END setMarginNew", w.Name) +} + +func setMargin(p *toolkit.Widget, c *toolkit.Widget, b bool) { + log(true, "Starting to implement SetMargin here") + dump(p, c, true) + + setMarginNew(c, b) + setMarginNew(p, b) +} + +func (t *andlabsT) String() string { + return t.GetText() +} + +func (t *andlabsT) GetText() string { + log(debugToolkit, "GetText() Enter debugToolkit=", debugToolkit) + if (t.uiEntry != nil) { + log(debugToolkit, "uiEntry.Text() =", t.uiEntry.Text()) + return t.uiEntry.Text() + } + if (t.uiMultilineEntry != nil) { + log(debugToolkit, "uiMultilineEntry.Text() =", t.uiMultilineEntry.Text()) + text := t.uiMultilineEntry.Text() + log(debugToolkit, "uiMultilineEntry.Text() =", text) + t.text = text + return text + } + if (t.uiCombobox != nil) { + log(debugToolkit, "uiCombobox() =", t.text) + return t.text + } + return "" +} + +func (t *andlabsT) SetText(s string) bool { + log(debugToolkit, "Text() SetText() Enter") + if (t.uiEntry != nil) { + log(debugToolkit, "Value() =", t.uiEntry.Text) + t.uiEntry.SetText(s) + return true + } + if (t.uiMultilineEntry != nil) { + log(debugToolkit, "Value() =", t.uiMultilineEntry.Text) + t.uiMultilineEntry.SetText(s) + return true + } + return false +} + +func sanity(t *andlabsT) bool { + if (debugToolkit) { + log(debugToolkit, "Value() Enter") + scs := spew.ConfigState{MaxDepth: 1} + scs.Dump(t) + } + if (t.uiEntry == nil) { + log(debugToolkit, "Value() =", t.uiEntry.Text) + return false + } + return true +} + +func (t *andlabsT) SetValue(i int) bool { + log(debugToolkit, "SetValue() START") + if (sanity(t)) { + return false + } + t.Dump(debugToolkit) + // panic("got to toolkit.SetValue") + return true +} + +func (t *andlabsT) Value() int { + if (debugToolkit) { + log(debugToolkit, "Value() Enter") + scs := spew.ConfigState{MaxDepth: 1} + scs.Dump(t) + } + if (t == nil) { + log(debugToolkit, "Value() can not get value t == nil") + return 0 + } + if (t.uiSlider != nil) { + log(debugToolkit, "Value() =", t.uiSlider.Value) + return t.uiSlider.Value() + } + if (t.uiSpinbox != nil) { + log(debugToolkit, "Value() =", t.uiSpinbox.Value) + return t.uiSpinbox.Value() + } + log(debugToolkit, "Value() Could not find a ui element to get a value from") + return 0 +} -- cgit v1.2.3