actually ran again without crashing
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
aeeacf535d
commit
1986bd286d
|
@ -3,7 +3,7 @@ package gui
|
||||||
import "git.wit.org/wit/gui/toolkit"
|
import "git.wit.org/wit/gui/toolkit"
|
||||||
|
|
||||||
func (n *Node) Checked() bool {
|
func (n *Node) Checked() bool {
|
||||||
return n.widget.B
|
return n.B
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *Node) NewCheckbox(name string) *Node {
|
func (n *Node) NewCheckbox(name string) *Node {
|
||||||
|
|
|
@ -18,7 +18,8 @@ func main() {
|
||||||
// This will turn on all debugging
|
// This will turn on all debugging
|
||||||
// gui.SetDebug(true)
|
// gui.SetDebug(true)
|
||||||
|
|
||||||
myGui = gui.New().LoadToolkit("gocui")
|
// myGui = gui.New().LoadToolkit("gocui")
|
||||||
|
myGui = gui.New().LoadToolkit("andlabs")
|
||||||
buttonWindow()
|
buttonWindow()
|
||||||
|
|
||||||
// This is just a optional goroutine to watch that things are alive
|
// This is just a optional goroutine to watch that things are alive
|
||||||
|
|
|
@ -103,7 +103,7 @@ func (n *Node) Set(val any) {
|
||||||
func (n *Node) AppendText(str string) {
|
func (n *Node) AppendText(str string) {
|
||||||
var a toolkit.Action
|
var a toolkit.Action
|
||||||
a.ActionType = toolkit.SetText
|
a.ActionType = toolkit.SetText
|
||||||
tmp := n.widget.S + str
|
tmp := n.S + str
|
||||||
log(debugChange, "AppendText() value =", tmp)
|
log(debugChange, "AppendText() value =", tmp)
|
||||||
a.S = tmp
|
a.S = tmp
|
||||||
n.Text = tmp
|
n.Text = tmp
|
||||||
|
@ -111,7 +111,7 @@ func (n *Node) AppendText(str string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *Node) GetText() string {
|
func (n *Node) GetText() string {
|
||||||
return n.widget.S
|
return n.S
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -35,15 +35,15 @@ func (n *Node) DebugFlags(makeWindow bool) {
|
||||||
cb1 := g.NewCheckbox("debug Gui")
|
cb1 := g.NewCheckbox("debug Gui")
|
||||||
g.NewLabel("like verbose=1")
|
g.NewLabel("like verbose=1")
|
||||||
cb1.Custom = func() {
|
cb1.Custom = func() {
|
||||||
debugGui = cb1.widget.B
|
debugGui = cb1.B
|
||||||
log(debugGui, "Custom() n.widget =", cb1.Name, cb1.widget.B)
|
log(debugGui, "Custom() n.widget =", cb1.Name, cb1.B)
|
||||||
}
|
}
|
||||||
|
|
||||||
// errors. by default these always output somewhere
|
// errors. by default these always output somewhere
|
||||||
cbE := g.NewCheckbox("debug Error")
|
cbE := g.NewCheckbox("debug Error")
|
||||||
g.NewLabel("(bad things. default=true)")
|
g.NewLabel("(bad things. default=true)")
|
||||||
cbE.Custom = func() {
|
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
|
// 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")
|
cb2 := g.NewCheckbox("debug Change")
|
||||||
g.NewLabel("keyboard and mouse events")
|
g.NewLabel("keyboard and mouse events")
|
||||||
cb2.Custom = func() {
|
cb2.Custom = func() {
|
||||||
SetFlag("Change", cb2.widget.B)
|
SetFlag("Change", cb2.B)
|
||||||
}
|
}
|
||||||
|
|
||||||
// supposed to tell if you are going to dump full variable output
|
// supposed to tell if you are going to dump full variable output
|
||||||
cb3 := g.NewCheckbox("debug Dump")
|
cb3 := g.NewCheckbox("debug Dump")
|
||||||
g.NewLabel("show lots of output")
|
g.NewLabel("show lots of output")
|
||||||
cb3.Custom = func() {
|
cb3.Custom = func() {
|
||||||
SetFlag("Dump", cbE.widget.B)
|
SetFlag("Dump", cbE.B)
|
||||||
}
|
}
|
||||||
|
|
||||||
cb4 := g.NewCheckbox("debug Tabs")
|
cb4 := g.NewCheckbox("debug Tabs")
|
||||||
g.NewLabel("tabs and windows")
|
g.NewLabel("tabs and windows")
|
||||||
cb4.Custom = func() {
|
cb4.Custom = func() {
|
||||||
SetFlag("Tabs", cb4.widget.B)
|
SetFlag("Tabs", cb4.B)
|
||||||
}
|
}
|
||||||
|
|
||||||
cb6 := g.NewCheckbox("debug Node")
|
cb6 := g.NewCheckbox("debug Node")
|
||||||
g.NewLabel("the binary tree)")
|
g.NewLabel("the binary tree)")
|
||||||
cb6.Custom = func() {
|
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
|
// should show you when things go into or come back from the plugin
|
||||||
cb5 := g.NewCheckbox("debug Plugin")
|
cb5 := g.NewCheckbox("debug Plugin")
|
||||||
g.NewLabel("plugin interaction)")
|
g.NewLabel("plugin interaction)")
|
||||||
cb5.Custom = func() {
|
cb5.Custom = func() {
|
||||||
SetFlag("Plugin", cb5.widget.B)
|
SetFlag("Plugin", cb5.B)
|
||||||
}
|
}
|
||||||
|
|
||||||
// turns on debugging inside the plugin toolkit
|
// turns on debugging inside the plugin toolkit
|
||||||
cb7 := g.NewCheckbox("debug Toolkit")
|
cb7 := g.NewCheckbox("debug Toolkit")
|
||||||
g.NewLabel("the plugin internals)")
|
g.NewLabel("the plugin internals)")
|
||||||
cb7.Custom = func() {
|
cb7.Custom = func() {
|
||||||
// SetDebugToolkit(cb7.widget.B)
|
// SetDebugToolkit(cb7.B)
|
||||||
SetFlag("Toolkit", cb7.widget.B)
|
SetFlag("Toolkit", cb7.B)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,7 +128,7 @@ func (n *Node) DebugGolangWindow(makeWindow bool) {
|
||||||
og = w.NewGroup("output")
|
og = w.NewGroup("output")
|
||||||
outputTextbox = og.NewTextbox("outputBox")
|
outputTextbox = og.NewTextbox("outputBox")
|
||||||
outputTextbox.Custom = func () {
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ func setActiveWidget(w *Node) {
|
||||||
}
|
}
|
||||||
title := "ID =" + strconv.Itoa(w.id) + " " + w.Name
|
title := "ID =" + strconv.Itoa(w.id) + " " + w.Name
|
||||||
activeLabel.SetText(title)
|
activeLabel.SetText(title)
|
||||||
activeLabelType.SetText("widget.Type = " + w.widget.Type.String())
|
activeLabelType.SetText("widget.Type = " + w.WidgetType.String())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,13 +121,13 @@ func DebugWidgetWindow(w *Node) {
|
||||||
g.NewButton("AddText()", func () {
|
g.NewButton("AddText()", func () {
|
||||||
var a toolkit.Action
|
var a toolkit.Action
|
||||||
a.ActionType = toolkit.AddText
|
a.ActionType = toolkit.AddText
|
||||||
a.S = activeLabelNewName.widget.S
|
a.S = activeLabelNewName.S
|
||||||
newaction(&a, activeWidget, nil)
|
newaction(&a, activeWidget, nil)
|
||||||
})
|
})
|
||||||
g.NewButton("SetText()", func () {
|
g.NewButton("SetText()", func () {
|
||||||
var a toolkit.Action
|
var a toolkit.Action
|
||||||
a.ActionType = toolkit.SetText
|
a.ActionType = toolkit.SetText
|
||||||
a.S = activeLabelNewName.widget.S
|
a.S = activeLabelNewName.S
|
||||||
newaction(&a, activeWidget, nil)
|
newaction(&a, activeWidget, nil)
|
||||||
})
|
})
|
||||||
g.NewButton("Margin()", func () {
|
g.NewButton("Margin()", func () {
|
||||||
|
@ -177,7 +177,7 @@ func (n *Node) debugAddWidgetButtons() {
|
||||||
a.AddText("make something for tim for qflow")
|
a.AddText("make something for tim for qflow")
|
||||||
a.AddText("and for riscv")
|
a.AddText("and for riscv")
|
||||||
a.Custom = func () {
|
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 () {
|
n.NewButton("Combobox", func () {
|
||||||
|
@ -185,7 +185,7 @@ func (n *Node) debugAddWidgetButtons() {
|
||||||
a.AddText("mirrors.wit.com")
|
a.AddText("mirrors.wit.com")
|
||||||
a.AddText("go.wit.com")
|
a.AddText("go.wit.com")
|
||||||
a.Custom = func () {
|
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 () {
|
n.NewButton("Grid", func () {
|
||||||
|
@ -248,10 +248,10 @@ func (n *Node) debugAddWidgetButton() {
|
||||||
activeLabelNewType.AddText("Dialog")
|
activeLabelNewType.AddText("Dialog")
|
||||||
|
|
||||||
n.NewButton("Add", func () {
|
n.NewButton("Add", func () {
|
||||||
name := activeLabelNewName.widget.S
|
name := activeLabelNewName.S
|
||||||
newX := activeLabelNewX.widget.I
|
newX := activeLabelNewX.I
|
||||||
newY := activeLabelNewY.widget.I
|
newY := activeLabelNewY.I
|
||||||
newB := activeLabelNewB.widget.B
|
newB := activeLabelNewB.B
|
||||||
|
|
||||||
if (newY == -1) {
|
if (newY == -1) {
|
||||||
name = name + " (" + strconv.Itoa(activeWidget.NextX) + "," + strconv.Itoa(activeWidget.NextY) + ")"
|
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) + ")"
|
name = name + " (" + strconv.Itoa(newX) + "," + strconv.Itoa(newY) + ")"
|
||||||
}
|
}
|
||||||
log("New Name =", name)
|
log("New Name =", name)
|
||||||
log("New Type =", activeLabelNewType.widget.S)
|
log("New Type =", activeLabelNewType.S)
|
||||||
log("New X =", newX)
|
log("New X =", newX)
|
||||||
log("New Y =", newY)
|
log("New Y =", newY)
|
||||||
log("activeWidget.NextX =", activeWidget.NextX)
|
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)
|
log(debugNow, "Add() size (X,Y)", activeWidget.X, activeWidget.Y, "put next thing at (X,Y) =", activeWidget.NextX, activeWidget.NextY)
|
||||||
activeWidget.Dump(true)
|
activeWidget.Dump(true)
|
||||||
|
|
||||||
// activeWidget.widget.X = newX
|
// activeWidget.X = newX
|
||||||
// activeWidget.widget.Y = newY
|
// activeWidget.Y = newY
|
||||||
|
|
||||||
switch activeLabelNewType.widget.S {
|
switch activeLabelNewType.S {
|
||||||
case "Grid":
|
case "Grid":
|
||||||
activeWidget.NewGrid(name, newX, newY)
|
activeWidget.NewGrid(name, newX, newY)
|
||||||
case "Group":
|
case "Group":
|
||||||
|
@ -286,14 +286,14 @@ func (n *Node) debugAddWidgetButton() {
|
||||||
case "Checkbox":
|
case "Checkbox":
|
||||||
a := activeWidget.NewCheckbox(name)
|
a := activeWidget.NewCheckbox(name)
|
||||||
a.Custom = func () {
|
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":
|
case "Dropdown":
|
||||||
a := activeWidget.NewDropdown(name)
|
a := activeWidget.NewDropdown(name)
|
||||||
a.AddText(name + " yay")
|
a.AddText(name + " yay")
|
||||||
a.AddText(name + " haha")
|
a.AddText(name + " haha")
|
||||||
a.Custom = func () {
|
a.Custom = func () {
|
||||||
log("WTF a=", a.widget.B, "id=", a.id)
|
log("WTF a=", a.B, "id=", a.id)
|
||||||
}
|
}
|
||||||
case "Combobox":
|
case "Combobox":
|
||||||
a := activeWidget.NewCombobox(name)
|
a := activeWidget.NewCombobox(name)
|
||||||
|
|
|
@ -36,8 +36,8 @@ func (n *Node) DebugTab(title string) *Node {
|
||||||
// generally useful debugging
|
// generally useful debugging
|
||||||
cb := gog.NewCheckbox("Seperate windows")
|
cb := gog.NewCheckbox("Seperate windows")
|
||||||
cb.Custom = func() {
|
cb.Custom = func() {
|
||||||
makeTabs = cb.widget.B
|
makeTabs = cb.B
|
||||||
log(debugGui, "Custom() n.widget =", cb.Name, cb.widget.B)
|
log(debugGui, "Custom() n.widget =", cb.Name, cb.B)
|
||||||
}
|
}
|
||||||
makeTabs = false
|
makeTabs = false
|
||||||
cb.Set(false)
|
cb.Set(false)
|
||||||
|
@ -134,7 +134,7 @@ func dropdownWindowWidgets(p *Node) {
|
||||||
|
|
||||||
dd := p.NewDropdown("Window Widgets Dropdown")
|
dd := p.NewDropdown("Window Widgets Dropdown")
|
||||||
dd.Custom = func() {
|
dd.Custom = func() {
|
||||||
name := dd.widget.S
|
name := dd.S
|
||||||
activeWidget = mapWindows[name]
|
activeWidget = mapWindows[name]
|
||||||
setActiveWidget(activeWidget)
|
setActiveWidget(activeWidget)
|
||||||
}
|
}
|
||||||
|
|
9
node.go
9
node.go
|
@ -10,15 +10,13 @@ func (n *Node) newNode(title string, t toolkit.WidgetType, custom func()) *Node
|
||||||
|
|
||||||
newN = addNode(title)
|
newN = addNode(title)
|
||||||
newN.WidgetType = t
|
newN.WidgetType = t
|
||||||
newN.widget.Type = t
|
|
||||||
// newN.widget.Action = "New"
|
|
||||||
newN.Custom = custom
|
newN.Custom = custom
|
||||||
|
|
||||||
// TODO: This should not be defined for each widget. This has to be stupid
|
// 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?
|
// or wait a second, is this where I send something to a channel?
|
||||||
newN.widget.Custom = func() {
|
newN.Custom = func() {
|
||||||
log(debugChange, "Trying to find Window Close. widget.Type =", newN.widget.Type)
|
log(debugChange, "Trying to find Window Close. widgetType =", newN.WidgetType)
|
||||||
if (newN.widget.Type == toolkit.Window) {
|
if (newN.WidgetType == toolkit.Window) {
|
||||||
log(debugChange, "Need to delete newN here")
|
log(debugChange, "Need to delete newN here")
|
||||||
n.Delete(newN)
|
n.Delete(newN)
|
||||||
}
|
}
|
||||||
|
@ -45,7 +43,6 @@ func addNode(title string) *Node {
|
||||||
n.Name = title
|
n.Name = title
|
||||||
n.Text = title
|
n.Text = title
|
||||||
n.id = Config.counter
|
n.id = Config.counter
|
||||||
n.widget.Id = n.id
|
|
||||||
log(debugNode, "addNode = widget setid =", n.id)
|
log(debugNode, "addNode = widget setid =", n.id)
|
||||||
|
|
||||||
Config.counter += 1
|
Config.counter += 1
|
||||||
|
|
|
@ -189,6 +189,7 @@ func sendCallback(p *aplug, funcName string) func(chan toolkit.Action) {
|
||||||
return newfunc
|
return newfunc
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
func loadFunc2(p *aplug, funcName string) func(*toolkit.Widget, *toolkit.Widget) {
|
func loadFunc2(p *aplug, funcName string) func(*toolkit.Widget, *toolkit.Widget) {
|
||||||
var newfunc func(*toolkit.Widget, *toolkit.Widget)
|
var newfunc func(*toolkit.Widget, *toolkit.Widget)
|
||||||
var ok bool
|
var ok bool
|
||||||
|
@ -207,6 +208,7 @@ func loadFunc2(p *aplug, funcName string) func(*toolkit.Widget, *toolkit.Widget)
|
||||||
}
|
}
|
||||||
return newfunc
|
return newfunc
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
// does this fix loadFuncE problems?
|
// does this fix loadFuncE problems?
|
||||||
// TODO: still need to move to channels here
|
// 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) {
|
func newaction(a *toolkit.Action, n *Node, where *Node) {
|
||||||
if (n != nil) {
|
if (n != nil) {
|
||||||
a.WidgetId = n.id
|
a.WidgetId = n.id
|
||||||
a.WidgetType = n.widget.Type
|
a.WidgetType = n.WidgetType
|
||||||
a.ActionType = a.ActionType
|
a.ActionType = a.ActionType
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -315,7 +317,7 @@ func newaction(a *toolkit.Action, n *Node, where *Node) {
|
||||||
if (where != nil) {
|
if (where != nil) {
|
||||||
log(logInfo, "Action() START on where X,Y, Next X,Y =", where.Name, where.X, where.Y, where.NextX, where.NextY)
|
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
|
a.ParentId = where.id
|
||||||
switch where.widget.Type {
|
switch where.WidgetType {
|
||||||
case toolkit.Grid:
|
case toolkit.Grid:
|
||||||
// where.Dump(true)
|
// 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)
|
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
|
// increment where to put the next widget in a grid or table
|
||||||
if (where != nil) {
|
if (where != nil) {
|
||||||
switch where.widget.Type {
|
switch where.WidgetType {
|
||||||
case toolkit.Grid:
|
case toolkit.Grid:
|
||||||
log(logInfo, "Action() START size (X,Y)", where.X, where.Y, "put next thing at (X,Y) =", where.NextX, where.NextY)
|
log(logInfo, "Action() START size (X,Y)", where.X, where.Y, "put next thing at (X,Y) =", where.NextX, where.NextY)
|
||||||
where.NextY += 1
|
where.NextY += 1
|
||||||
|
|
|
@ -62,7 +62,7 @@ type Node struct {
|
||||||
id int
|
id int
|
||||||
initOnce sync.Once
|
initOnce sync.Once
|
||||||
|
|
||||||
widget toolkit.Widget
|
// widget toolkit.Widget
|
||||||
WidgetType toolkit.WidgetType
|
WidgetType toolkit.WidgetType
|
||||||
|
|
||||||
// Title string // what is visable to the user
|
// Title string // what is visable to the user
|
||||||
|
|
|
@ -18,12 +18,13 @@ import "git.wit.org/wit/gui/toolkit"
|
||||||
//
|
//
|
||||||
// TODO: make sure you can't escape this goroutine
|
// TODO: make sure you can't escape this goroutine
|
||||||
//
|
//
|
||||||
|
/*
|
||||||
func Send(p *toolkit.Widget, c *toolkit.Widget) {
|
func Send(p *toolkit.Widget, c *toolkit.Widget) {
|
||||||
log(debugPlugin, "Send() goodbye. not used anymore")
|
log(debugPlugin, "Send() goodbye. not used anymore")
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
func oldAction2(a *toolkit.Action) {
|
||||||
func oldAction(a *toolkit.Action) {
|
|
||||||
log(logNow, "Action() START")
|
log(logNow, "Action() START")
|
||||||
if (a == nil) {
|
if (a == nil) {
|
||||||
log(debugPlugin, "Action = nil")
|
log(debugPlugin, "Action = nil")
|
||||||
|
|
|
@ -18,7 +18,7 @@ type ActionType int
|
||||||
// I'm using "Action". Maybe it should really be
|
// I'm using "Action". Maybe it should really be
|
||||||
// "Interaction" as per wikipedia [[User interface]]
|
// "Interaction" as per wikipedia [[User interface]]
|
||||||
// Could a protobuf be used here? (Can functions be passed?)
|
// Could a protobuf be used here? (Can functions be passed?)
|
||||||
type Widget struct {
|
type Widget2 struct {
|
||||||
// Name string
|
// Name string
|
||||||
Type WidgetType
|
Type WidgetType
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue