summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2023-04-23 07:37:24 -0500
committerJeff Carr <[email protected]>2023-04-23 07:37:24 -0500
commit2d4d2b6b3e115a86a10f98c20de0e4e82be519c2 (patch)
tree4cab36495872e70220e47b1790189249c3e2bcdc
parentaeb998eea5ef67c1c87664340b89b5e415fb0747 (diff)
actually ran again without crashing
Signed-off-by: Jeff Carr <[email protected]>
-rw-r--r--checkbox.go2
-rw-r--r--cmds/buttonplugin/main.go3
-rw-r--r--common.go4
-rw-r--r--debugFlags.go20
-rw-r--r--debugGolang.go2
-rw-r--r--debugWidget.go30
-rw-r--r--debugWindow.go6
-rw-r--r--node.go9
-rw-r--r--plugin.go8
-rw-r--r--structs.go2
-rw-r--r--toolkit/andlabs/plugin.go5
-rw-r--r--toolkit/widget.go2
12 files changed, 47 insertions, 46 deletions
diff --git a/checkbox.go b/checkbox.go
index 2ab3f44..8864109 100644
--- a/checkbox.go
+++ b/checkbox.go
@@ -3,7 +3,7 @@ package gui
import "git.wit.org/wit/gui/toolkit"
func (n *Node) Checked() bool {
- return n.widget.B
+ return n.B
}
func (n *Node) NewCheckbox(name string) *Node {
diff --git a/cmds/buttonplugin/main.go b/cmds/buttonplugin/main.go
index 01ce1c8..7c62b21 100644
--- a/cmds/buttonplugin/main.go
+++ b/cmds/buttonplugin/main.go
@@ -18,7 +18,8 @@ func main() {
// This will turn on all debugging
// gui.SetDebug(true)
- myGui = gui.New().LoadToolkit("gocui")
+ // myGui = gui.New().LoadToolkit("gocui")
+ myGui = gui.New().LoadToolkit("andlabs")
buttonWindow()
// This is just a optional goroutine to watch that things are alive
diff --git a/common.go b/common.go
index 4b5d721..36fd17a 100644
--- a/common.go
+++ b/common.go
@@ -103,7 +103,7 @@ func (n *Node) Set(val any) {
func (n *Node) AppendText(str string) {
var a toolkit.Action
a.ActionType = toolkit.SetText
- tmp := n.widget.S + str
+ tmp := n.S + str
log(debugChange, "AppendText() value =", tmp)
a.S = tmp
n.Text = tmp
@@ -111,7 +111,7 @@ func (n *Node) AppendText(str string) {
}
func (n *Node) GetText() string {
- return n.widget.S
+ return n.S
}
/*
diff --git a/debugFlags.go b/debugFlags.go
index 7b1d1c7..a62b6b9 100644
--- a/debugFlags.go
+++ b/debugFlags.go
@@ -35,15 +35,15 @@ func (n *Node) DebugFlags(makeWindow bool) {
cb1 := g.NewCheckbox("debug Gui")
g.NewLabel("like verbose=1")
cb1.Custom = func() {
- debugGui = cb1.widget.B
- log(debugGui, "Custom() n.widget =", cb1.Name, cb1.widget.B)
+ debugGui = cb1.B
+ log(debugGui, "Custom() n.widget =", cb1.Name, cb1.B)
}
// errors. by default these always output somewhere
cbE := g.NewCheckbox("debug Error")
g.NewLabel("(bad things. default=true)")
cbE.Custom = func() {
- SetFlag("Error", cbE.widget.B)
+ SetFlag("Error", cbE.B)
}
// debugging that will show you things like mouse clicks, user inputing text, etc
@@ -51,40 +51,40 @@ func (n *Node) DebugFlags(makeWindow bool) {
cb2 := g.NewCheckbox("debug Change")
g.NewLabel("keyboard and mouse events")
cb2.Custom = func() {
- SetFlag("Change", cb2.widget.B)
+ SetFlag("Change", cb2.B)
}
// supposed to tell if you are going to dump full variable output
cb3 := g.NewCheckbox("debug Dump")
g.NewLabel("show lots of output")
cb3.Custom = func() {
- SetFlag("Dump", cbE.widget.B)
+ SetFlag("Dump", cbE.B)
}
cb4 := g.NewCheckbox("debug Tabs")
g.NewLabel("tabs and windows")
cb4.Custom = func() {
- SetFlag("Tabs", cb4.widget.B)
+ SetFlag("Tabs", cb4.B)
}
cb6 := g.NewCheckbox("debug Node")
g.NewLabel("the binary tree)")
cb6.Custom = func() {
- SetFlag("Node", cb6.widget.B)
+ SetFlag("Node", cb6.B)
}
// should show you when things go into or come back from the plugin
cb5 := g.NewCheckbox("debug Plugin")
g.NewLabel("plugin interaction)")
cb5.Custom = func() {
- SetFlag("Plugin", cb5.widget.B)
+ SetFlag("Plugin", cb5.B)
}
// turns on debugging inside the plugin toolkit
cb7 := g.NewCheckbox("debug Toolkit")
g.NewLabel("the plugin internals)")
cb7.Custom = func() {
- // SetDebugToolkit(cb7.widget.B)
- SetFlag("Toolkit", cb7.widget.B)
+ // SetDebugToolkit(cb7.B)
+ SetFlag("Toolkit", cb7.B)
}
}
diff --git a/debugGolang.go b/debugGolang.go
index b98f82d..707b3d6 100644
--- a/debugGolang.go
+++ b/debugGolang.go
@@ -128,7 +128,7 @@ func (n *Node) DebugGolangWindow(makeWindow bool) {
og = w.NewGroup("output")
outputTextbox = og.NewTextbox("outputBox")
outputTextbox.Custom = func () {
- log("custom TextBox() for golang output a =", outputTextbox.widget.S, outputTextbox.id)
+ log("custom TextBox() for golang output a =", outputTextbox.S, outputTextbox.id)
}
}
diff --git a/debugWidget.go b/debugWidget.go
index 6c26e7a..faa2ff9 100644
--- a/debugWidget.go
+++ b/debugWidget.go
@@ -45,7 +45,7 @@ func setActiveWidget(w *Node) {
}
title := "ID =" + strconv.Itoa(w.id) + " " + w.Name
activeLabel.SetText(title)
- activeLabelType.SetText("widget.Type = " + w.widget.Type.String())
+ activeLabelType.SetText("widget.Type = " + w.WidgetType.String())
return
}
@@ -121,13 +121,13 @@ func DebugWidgetWindow(w *Node) {
g.NewButton("AddText()", func () {
var a toolkit.Action
a.ActionType = toolkit.AddText
- a.S = activeLabelNewName.widget.S
+ a.S = activeLabelNewName.S
newaction(&a, activeWidget, nil)
})
g.NewButton("SetText()", func () {
var a toolkit.Action
a.ActionType = toolkit.SetText
- a.S = activeLabelNewName.widget.S
+ a.S = activeLabelNewName.S
newaction(&a, activeWidget, nil)
})
g.NewButton("Margin()", func () {
@@ -177,7 +177,7 @@ func (n *Node) debugAddWidgetButtons() {
a.AddText("make something for tim for qflow")
a.AddText("and for riscv")
a.Custom = func () {
- log("custom dropdown() a =", a.Name, a.widget.S, "id=", a.id)
+ log("custom dropdown() a =", a.Name, a.S, "id=", a.id)
}
})
n.NewButton("Combobox", func () {
@@ -185,7 +185,7 @@ func (n *Node) debugAddWidgetButtons() {
a.AddText("mirrors.wit.com")
a.AddText("go.wit.com")
a.Custom = func () {
- log("custom combobox() a =", a.Name, a.widget.S, "id=", a.id)
+ log("custom combobox() a =", a.Name, a.S, "id=", a.id)
}
})
n.NewButton("Grid", func () {
@@ -248,10 +248,10 @@ func (n *Node) debugAddWidgetButton() {
activeLabelNewType.AddText("Dialog")
n.NewButton("Add", func () {
- name := activeLabelNewName.widget.S
- newX := activeLabelNewX.widget.I
- newY := activeLabelNewY.widget.I
- newB := activeLabelNewB.widget.B
+ name := activeLabelNewName.S
+ newX := activeLabelNewX.I
+ newY := activeLabelNewY.I
+ newB := activeLabelNewB.B
if (newY == -1) {
name = name + " (" + strconv.Itoa(activeWidget.NextX) + "," + strconv.Itoa(activeWidget.NextY) + ")"
@@ -260,7 +260,7 @@ func (n *Node) debugAddWidgetButton() {
name = name + " (" + strconv.Itoa(newX) + "," + strconv.Itoa(newY) + ")"
}
log("New Name =", name)
- log("New Type =", activeLabelNewType.widget.S)
+ log("New Type =", activeLabelNewType.S)
log("New X =", newX)
log("New Y =", newY)
log("activeWidget.NextX =", activeWidget.NextX)
@@ -268,10 +268,10 @@ func (n *Node) debugAddWidgetButton() {
log(debugNow, "Add() size (X,Y)", activeWidget.X, activeWidget.Y, "put next thing at (X,Y) =", activeWidget.NextX, activeWidget.NextY)
activeWidget.Dump(true)
- // activeWidget.widget.X = newX
- // activeWidget.widget.Y = newY
+ // activeWidget.X = newX
+ // activeWidget.Y = newY
- switch activeLabelNewType.widget.S {
+ switch activeLabelNewType.S {
case "Grid":
activeWidget.NewGrid(name, newX, newY)
case "Group":
@@ -286,14 +286,14 @@ func (n *Node) debugAddWidgetButton() {
case "Checkbox":
a := activeWidget.NewCheckbox(name)
a.Custom = func () {
- log("custom checkox func a=", a.widget.B, "id=", a.id)
+ log("custom checkox func a=", a.B, "id=", a.id)
}
case "Dropdown":
a := activeWidget.NewDropdown(name)
a.AddText(name + " yay")
a.AddText(name + " haha")
a.Custom = func () {
- log("WTF a=", a.widget.B, "id=", a.id)
+ log("WTF a=", a.B, "id=", a.id)
}
case "Combobox":
a := activeWidget.NewCombobox(name)
diff --git a/debugWindow.go b/debugWindow.go
index d7d7961..e55a911 100644
--- a/debugWindow.go
+++ b/debugWindow.go
@@ -36,8 +36,8 @@ func (n *Node) DebugTab(title string) *Node {
// generally useful debugging
cb := gog.NewCheckbox("Seperate windows")
cb.Custom = func() {
- makeTabs = cb.widget.B
- log(debugGui, "Custom() n.widget =", cb.Name, cb.widget.B)
+ makeTabs = cb.B
+ log(debugGui, "Custom() n.widget =", cb.Name, cb.B)
}
makeTabs = false
cb.Set(false)
@@ -134,7 +134,7 @@ func dropdownWindowWidgets(p *Node) {
dd := p.NewDropdown("Window Widgets Dropdown")
dd.Custom = func() {
- name := dd.widget.S
+ name := dd.S
activeWidget = mapWindows[name]
setActiveWidget(activeWidget)
}
diff --git a/node.go b/node.go
index 1454858..67c7943 100644
--- a/node.go
+++ b/node.go
@@ -10,15 +10,13 @@ func (n *Node) newNode(title string, t toolkit.WidgetType, custom func()) *Node
newN = addNode(title)
newN.WidgetType = t
- newN.widget.Type = t
- // newN.widget.Action = "New"
newN.Custom = custom
// TODO: This should not be defined for each widget. This has to be stupid
// or wait a second, is this where I send something to a channel?
- newN.widget.Custom = func() {
- log(debugChange, "Trying to find Window Close. widget.Type =", newN.widget.Type)
- if (newN.widget.Type == toolkit.Window) {
+ newN.Custom = func() {
+ log(debugChange, "Trying to find Window Close. widgetType =", newN.WidgetType)
+ if (newN.WidgetType == toolkit.Window) {
log(debugChange, "Need to delete newN here")
n.Delete(newN)
}
@@ -45,7 +43,6 @@ func addNode(title string) *Node {
n.Name = title
n.Text = title
n.id = Config.counter
- n.widget.Id = n.id
log(debugNode, "addNode = widget setid =", n.id)
Config.counter += 1
diff --git a/plugin.go b/plugin.go
index de8dd76..7dedd22 100644
--- a/plugin.go
+++ b/plugin.go
@@ -189,6 +189,7 @@ func sendCallback(p *aplug, funcName string) func(chan toolkit.Action) {
return newfunc
}
+/*
func loadFunc2(p *aplug, funcName string) func(*toolkit.Widget, *toolkit.Widget) {
var newfunc func(*toolkit.Widget, *toolkit.Widget)
var ok bool
@@ -207,6 +208,7 @@ func loadFunc2(p *aplug, funcName string) func(*toolkit.Widget, *toolkit.Widget)
}
return newfunc
}
+*/
// does this fix loadFuncE problems?
// TODO: still need to move to channels here
@@ -307,7 +309,7 @@ func loadfile(filename string) *plugin.Plugin {
func newaction(a *toolkit.Action, n *Node, where *Node) {
if (n != nil) {
a.WidgetId = n.id
- a.WidgetType = n.widget.Type
+ a.WidgetType = n.WidgetType
a.ActionType = a.ActionType
}
@@ -315,7 +317,7 @@ func newaction(a *toolkit.Action, n *Node, where *Node) {
if (where != nil) {
log(logInfo, "Action() START on where X,Y, Next X,Y =", where.Name, where.X, where.Y, where.NextX, where.NextY)
a.ParentId = where.id
- switch where.widget.Type {
+ switch where.WidgetType {
case toolkit.Grid:
// where.Dump(true)
log(logInfo, "Action() START on Grid (X,Y)", where.X, where.Y, "put next thing at (X,Y) =", where.NextX, where.NextY)
@@ -348,7 +350,7 @@ func newaction(a *toolkit.Action, n *Node, where *Node) {
}
// increment where to put the next widget in a grid or table
if (where != nil) {
- switch where.widget.Type {
+ switch where.WidgetType {
case toolkit.Grid:
log(logInfo, "Action() START size (X,Y)", where.X, where.Y, "put next thing at (X,Y) =", where.NextX, where.NextY)
where.NextY += 1
diff --git a/structs.go b/structs.go
index b6dcaff..b222138 100644
--- a/structs.go
+++ b/structs.go
@@ -62,7 +62,7 @@ type Node struct {
id int
initOnce sync.Once
- widget toolkit.Widget
+ // widget toolkit.Widget
WidgetType toolkit.WidgetType
// Title string // what is visable to the user
diff --git a/toolkit/andlabs/plugin.go b/toolkit/andlabs/plugin.go
index 15e9396..f9befd5 100644
--- a/toolkit/andlabs/plugin.go
+++ b/toolkit/andlabs/plugin.go
@@ -18,12 +18,13 @@ import "git.wit.org/wit/gui/toolkit"
//
// TODO: make sure you can't escape this goroutine
//
+/*
func Send(p *toolkit.Widget, c *toolkit.Widget) {
log(debugPlugin, "Send() goodbye. not used anymore")
}
+*/
-
-func oldAction(a *toolkit.Action) {
+func oldAction2(a *toolkit.Action) {
log(logNow, "Action() START")
if (a == nil) {
log(debugPlugin, "Action = nil")
diff --git a/toolkit/widget.go b/toolkit/widget.go
index 21f2f47..658475e 100644
--- a/toolkit/widget.go
+++ b/toolkit/widget.go
@@ -18,7 +18,7 @@ type ActionType int
// I'm using "Action". Maybe it should really be
// "Interaction" as per wikipedia [[User interface]]
// Could a protobuf be used here? (Can functions be passed?)
-type Widget struct {
+type Widget2 struct {
// Name string
Type WidgetType