diff options
| author | Jeff Carr <[email protected]> | 2022-11-13 08:53:03 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2022-11-13 08:53:03 -0600 |
| commit | 207cf7ea16f1da8fa9f893504d77a2856298cc22 (patch) | |
| tree | 54d513b83ce797be75268f7d8867e0b01ab8f23e /toolkit/andlabs2/common.go | |
| parent | ed382bec55be25039e4dcf020d1512139855c9bb (diff) | |
Massive refactor to use go plugins. This is neat.
update README.md
set xterm title. make os.Exit() default on window close
add a toolkit.Widget to the node structure
remove 'Greeter' symbol mapping scheme
removed the testing greeter code
plugins:
attempt to load plugins in a sensible order
andlabs/ui:
working andlabs/ui plugin (andlabs2)
buttons work in andlabs plugin
TODO: re-implement non-plugin version for Windows
mswindows doesn't support go plugins yet
gocui:
put the gocui console so file in the binary
does a full init of gocui plugin
Button() and Group() working very well with gogui
cleanly exit gocui
technically you can load two toolkits at the same time
kinda both working at the same time. esoteric
two working plugins at the same time
give up working on two gui's at the same time
this is fun, but _not interesting
wow. this actually works. NewButton() from both toolkits
examples:
all the examples run again
remove early helloplugin example
buttonplugin example cmd code
buttonplugin runs and ldd is minimum
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'toolkit/andlabs2/common.go')
| -rw-r--r-- | toolkit/andlabs2/common.go | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/toolkit/andlabs2/common.go b/toolkit/andlabs2/common.go new file mode 100644 index 0000000..fc6cbe8 --- /dev/null +++ b/toolkit/andlabs2/common.go @@ -0,0 +1,61 @@ +package main + +import "log" + +func init() { + if (DebugToolkit) { + log.Println("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) + } + if (t.OnChanged != nil) { + if (DebugToolkit) { + log.Println("gui.Toolkit.OnChanged() trying to run toolkit.OnChanged() entered val =", s) + } + t.OnChanged(&t) + return + } + if (t.Custom != nil) { + if (DebugToolkit) { + log.Println("gui.Toolkit.OnChanged() Running toolkit.Custom()") + t.Dump() + } + t.Custom() + return + } + if (DebugToolkit) { + log.Println("gui.Toolkit.OnChanged() ENDED without finding any callback") + } +} + +// does some sanity checks on the internal structs of the binary tree +// TODO: probably this should not panic unless it's running in devel mode (?) +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") + } + 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?") + // 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)") + forceDump(t) + return false + } + return false +} |
