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"
|
||||
|
||||
func (n *Node) Checked() bool {
|
||||
return n.widget.B
|
||||
return n.B
|
||||
}
|
||||
|
||||
func (n *Node) NewCheckbox(name string) *Node {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
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.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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue