From f3bb68396afa7452ecf1c8d4744c825a9d81057c Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sat, 25 Feb 2023 14:05:25 -0600 Subject: The debugging window is finally useful the gui enabled debugging works --gui-debug works from the command line The debug window can now select things debugging now includes widget types all the debug flags work finally working debugging flags via gui checkboxes add debian packaging rules use log() in the toolkit use a standard log() to simplify debugging flags add reference to 'GO Style Guide' use the same LICENSE from the GO developers. TODO: make this threadsafe TODO: fix plugin stuff Signed-off-by: Jeff Carr --- toolkit/andlabs/common.go | 72 +++++++++++++++++++++++++++++++---------------- 1 file changed, 48 insertions(+), 24 deletions(-) (limited to 'toolkit/andlabs/common.go') diff --git a/toolkit/andlabs/common.go b/toolkit/andlabs/common.go index fc6cbe8..94e19e1 100644 --- a/toolkit/andlabs/common.go +++ b/toolkit/andlabs/common.go @@ -1,37 +1,63 @@ package main -import "log" - +// This is important. This sets the defaults for the gui. Without this, there isn't correct padding, etc func init() { - if (DebugToolkit) { - log.Println("gui/toolkit init() Setting defaultBehavior = true") - } + // Can you pass values to a plugin init() ? Otherwise, there is no way to safely print + // log(debugToolkit, "gui/toolkit init() Setting defaultBehavior = true") setDefaultBehavior(true) } func (t andlabsT) commonChange(widget string) { s := t.String() - if (DebugToolkit) { - log.Println("gui.Toolkit.ui.OnChanged() =", s) - } + log(debugChange, "commonChange() START widget =", widget) + log(debugChange, "commonChange() t.String =", s) if (t.OnChanged != nil) { - if (DebugToolkit) { - log.Println("gui.Toolkit.OnChanged() trying to run toolkit.OnChanged() entered val =", s) - } - t.OnChanged(&t) + // log(debugChange, "commonChange() toolkit.OnChanged() START") + // t.OnChanged(&t) + exit("OnChanged is not implemented. TODO: FIX THIS") return } if (t.Custom != nil) { - if (DebugToolkit) { - log.Println("gui.Toolkit.OnChanged() Running toolkit.Custom()") - t.Dump() - } + log(debugChange, "commonChange() START toolkit.Custom()") t.Custom() + log(debugChange, "commonChange() END toolkit.Custom()") + return + } + if (widget == "Checkbox") { + log(debugChange, "commonChange() END Need to read the Checkbox value") + return + } + if (widget == "Dropdown") { + t.getDropdown() + if (t.tw == nil) { + log(debugChange, "commonChange() END tw.Custom == nil") + } + if (t.tw.Custom == nil) { + log(debugChange, "commonChange() END Dropdown (no custom())") + } + t.tw.Custom() + log(debugChange, "commonChange() END Dropdown") + return + } + log(debugChange, "commonChange() t.String =", s) + log(debugChange, "commonChange() ENDED without finding any callback") +} + +func (t *andlabsT) getDropdown() { + log(debugChange, "commonChange() Need to read the dropdown menu") + if (t.uiCombobox == nil) { + log(debugChange, "commonChange() END BAD NEWS. t.uiCombobox == nil") return } - if (DebugToolkit) { - log.Println("gui.Toolkit.OnChanged() ENDED without finding any callback") + i := t.uiCombobox.Selected() + log(debugChange, "commonChange() t.uiCombobox = ", i) + if (t.tw == nil) { + log(debugChange, "commonChange() END tw = nil") + return } + t.tw.S = t.String() + log(debugChange, "commonChange() END tw = ", t.tw) + return } // does some sanity checks on the internal structs of the binary tree @@ -39,21 +65,19 @@ func (t andlabsT) commonChange(widget string) { func (t *andlabsT) broken() bool { if (t.uiBox == nil) { if (t.uiWindow != nil) { - if (DebugToolkit) { - log.Println("gui.Toolkit.UiBox == nil. This is an empty window. Try to add a box") - } + log(debugToolkit, "gui.Toolkit.UiBox == nil. This is an empty window. Try to add a box") t.NewBox() return false } - log.Println("gui.Toolkit.UiBox == nil. I can't add a widget without a place to put it") - // log.Println("probably could just make a box here?") + log(debugToolkit, "gui.Toolkit.UiBox == nil. I can't add a widget without a place to put it") + // log(debugToolkit, "probably could just make a box here?") // corruption or something horrible? panic("wit/gui toolkit/andlabs func broken() invalid goroutine access into this toolkit?") panic("wit/gui toolkit/andlabs func broken() this probably should not cause the app to panic here (?)") return true } if (t.uiWindow == nil) { - log.Println("gui.Toolkit.UiWindow == nil. I can't add a widget without a place to put it (IGNORING FOR NOW)") + log(debugToolkit, "gui.Toolkit.UiWindow == nil. I can't add a widget without a place to put it (IGNORING FOR NOW)") forceDump(t) return false } -- cgit v1.2.3