v0.4.2 more code cleanups and improvements
Add command line argv handling using go-arg make hello world dumb stupid simple again more swtiching to common code move debugging options to support go-args more debugging output cleanup more debugging cleanups fix null pointer crash
This commit is contained in:
parent
f48d3fbcfe
commit
5417c8f477
|
@ -1,4 +1,5 @@
|
|||
*.swp
|
||||
cmds/gui-demo/gui-demo
|
||||
cmds/helloworld/helloworld
|
||||
cmds/textbox/textbox
|
||||
cmds/gui-demo/gui-demo
|
||||
cmds/consolemouse/consolemouse
|
||||
|
|
25
README.md
25
README.md
|
@ -21,7 +21,7 @@ Principles:
|
|||
* It's ok to guess. We will return something close.
|
||||
* Hide complexity internally here
|
||||
* Isolate the GUI toolkit
|
||||
* Function names should follow [[Graphical widget]]
|
||||
* Function names should follow [Wikipedia Graphical widget]
|
||||
```
|
||||
|
||||
## Quick Start
|
||||
|
@ -107,12 +107,19 @@ information this uses spew.Dump()
|
|||
|
||||
-- manpage quote from the excellent minimalistic window manager 'evilwm'
|
||||
|
||||
## External References
|
||||
## References
|
||||
|
||||
Useful links and other external things which might be useful
|
||||
Useful links and other
|
||||
external things
|
||||
which might be useful
|
||||
|
||||
* [Wikipedia Graphical widget](https://en.wikipedia.org/wiki/Graphical_widget)
|
||||
* [Github mirror](https://github.com/witorg/gui)
|
||||
[Wikipedia Graphical widget]: [https://en.wikipedia.org/wiki/Graphical_widget](https://en.wikipedia.org/wiki/Graphical_widget)
|
||||
[Github mirror]: [https://github.com/witorg/gui](https://github.com/witorg/gui)
|
||||
|
||||
```go
|
||||
* [Wikipedia Graphical widget]
|
||||
* [Github mirror]
|
||||
```
|
||||
|
||||
## Functions
|
||||
|
||||
|
@ -154,7 +161,7 @@ This creates a window that shows how this package works
|
|||
|
||||
`func GolangDebugWindow()`
|
||||
|
||||
### func [IndentPrintln](/structs.go#L191)
|
||||
### func [IndentPrintln](/structs.go#L190)
|
||||
|
||||
`func IndentPrintln(a ...interface{})`
|
||||
|
||||
|
@ -187,7 +194,7 @@ For example: gui.Queue(NewWindow())
|
|||
|
||||
## Types
|
||||
|
||||
### type [GuiConfig](/structs.go#L43)
|
||||
### type [GuiConfig](/structs.go#L42)
|
||||
|
||||
`type GuiConfig struct { ... }`
|
||||
|
||||
|
@ -197,7 +204,7 @@ For example: gui.Queue(NewWindow())
|
|||
var Config GuiConfig
|
||||
```
|
||||
|
||||
### type [Node](/structs.go#L98)
|
||||
### type [Node](/structs.go#L97)
|
||||
|
||||
`type Node struct { ... }`
|
||||
|
||||
|
@ -255,7 +262,7 @@ func main() {
|
|||
You get a window
|
||||
```
|
||||
|
||||
### type [Widget](/structs.go#L68)
|
||||
### type [Widget](/structs.go#L67)
|
||||
|
||||
`type Widget int`
|
||||
|
||||
|
|
|
@ -13,9 +13,13 @@ func (n *Node) NewButton(name string, custom func()) *Node {
|
|||
|
||||
// TODO: this is still confusing and probably wrong. This needs to communicate through a channel
|
||||
newNode.toolkit.Custom = func() {
|
||||
log.Println("gui.AppendButton() Button Clicked. Running custom() from outside toolkit START")
|
||||
if (Config.Options.Debug) {
|
||||
log.Println("gui.AppendButton() Button Clicked. Running custom() from outside toolkit START")
|
||||
}
|
||||
custom()
|
||||
log.Println("gui.AppendButton() Button Clicked. Running custom() from outside toolkit END")
|
||||
if (Config.Options.Debug) {
|
||||
log.Println("gui.AppendButton() Button Clicked. Running custom() from outside toolkit END")
|
||||
}
|
||||
}
|
||||
newNode.custom = custom
|
||||
|
||||
|
|
|
@ -8,57 +8,37 @@ import (
|
|||
)
|
||||
|
||||
func main() {
|
||||
f, err := os.OpenFile("/tmp/guilogfile", os.O_RDWR | os.O_CREATE | os.O_APPEND, 0666)
|
||||
if err != nil {
|
||||
log.Fatalf("error opening file: %v", err)
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
log.SetOutput(f)
|
||||
log.Println("This is a test log entry")
|
||||
|
||||
gui.Main(initGUI)
|
||||
gui.Main(myGUI)
|
||||
}
|
||||
|
||||
// This initializes the first window
|
||||
func initGUI() {
|
||||
func myGUI() {
|
||||
var w *gui.Node
|
||||
gui.Config.Title = "Hello World golang wit/gui Window"
|
||||
gui.Config.Width = 640
|
||||
gui.Config.Height = 480
|
||||
gui.Config.Exit = myDefaultExit
|
||||
gui.Config.Exit = myExit
|
||||
|
||||
w = gui.NewWindow()
|
||||
w.Dump()
|
||||
addDemoTab(w, "A Simple Tab Demo")
|
||||
addDemoTab(w, "A Second Tab")
|
||||
addHelloWorld(w, "A Simple Tab")
|
||||
}
|
||||
|
||||
func addDemoTab(window *gui.Node, title string) {
|
||||
var newNode, g *gui.Node
|
||||
func addHelloWorld(window *gui.Node, title string) {
|
||||
var newNode, g, tb *gui.Node
|
||||
|
||||
newNode = window.NewTab(title)
|
||||
log.Println("addDemoTab() newNode.Dump")
|
||||
log.Println("addDemoTab() newNode.Dump")
|
||||
log.Println("addDemoTab() newNode.Dump")
|
||||
log.Println("addDemoTab() newNode.Dump")
|
||||
newNode.Dump()
|
||||
|
||||
g = newNode.NewGroup("group 1")
|
||||
log.Println("addDemoTab() g.Dump")
|
||||
log.Println("addDemoTab() g.Dump")
|
||||
log.Println("addDemoTab() g.Dump")
|
||||
log.Println("addDemoTab() g.Dump")
|
||||
g.Dump()
|
||||
// os.Exit(0)
|
||||
dd := g.NewDropdown("demoCombo2")
|
||||
dd.AddDropdown("more 1")
|
||||
dd.AddDropdown("more 2")
|
||||
dd.AddDropdown("more 3")
|
||||
g = newNode.NewGroup("hello")
|
||||
tb = g.NewTextbox("hello world box") // when debugging, this string will be used
|
||||
tb.OnChanged = func(*gui.Node) {
|
||||
s := tb.GetText()
|
||||
log.Println("text box =", s)
|
||||
}
|
||||
tb.SetText("world")
|
||||
}
|
||||
|
||||
func myDefaultExit(n *gui.Node) {
|
||||
log.Println("You can Do exit() things here")
|
||||
func myExit(n *gui.Node) {
|
||||
log.Println("exit() here")
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
run: build
|
||||
./textbox --guidebug
|
||||
|
||||
build-release:
|
||||
go get -v -u -x .
|
||||
go build
|
||||
|
||||
build:
|
||||
GO111MODULE="off" go get -v -x .
|
||||
GO111MODULE="off" go build
|
||||
|
||||
update:
|
||||
GO111MODULE="off" go get -v -u -x .
|
|
@ -0,0 +1,104 @@
|
|||
// This creates a simple hello world window
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"log"
|
||||
"fmt"
|
||||
"git.wit.org/wit/gui"
|
||||
arg "github.com/alexflint/go-arg"
|
||||
)
|
||||
|
||||
type LogOptions struct {
|
||||
LogFile string
|
||||
Verbose bool
|
||||
GuiDebug bool `help:"open up the wit/gui Debugging Window"`
|
||||
GuiDemo bool `help:"open the wit/gui Demo Window"`
|
||||
User string `arg:"env:USER"`
|
||||
}
|
||||
|
||||
var args struct {
|
||||
Foo string
|
||||
Bar bool
|
||||
LogOptions
|
||||
gui.GuiOptions
|
||||
}
|
||||
|
||||
|
||||
func main() {
|
||||
arg.MustParse(&args)
|
||||
fmt.Println(args.Foo, args.Bar, args.User)
|
||||
|
||||
gui.Config.Options.Debug = args.Debug
|
||||
gui.Config.Options.DebugChange = args.DebugChange
|
||||
gui.Config.Options.DebugDump = args.DebugDump
|
||||
gui.Config.Options.DebugNode = args.DebugNode
|
||||
gui.Config.Options.DebugTabs = args.DebugTabs
|
||||
|
||||
/*
|
||||
f, err := os.OpenFile("/tmp/guilogfile", os.O_RDWR | os.O_CREATE | os.O_APPEND, 0666)
|
||||
if err != nil {
|
||||
log.Fatalf("error opening file: %v", err)
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
log.SetOutput(f)
|
||||
log.Println("This is a test log entry")
|
||||
*/
|
||||
|
||||
gui.Main(initGUI)
|
||||
}
|
||||
|
||||
// This initializes the first window
|
||||
func initGUI() {
|
||||
var w *gui.Node
|
||||
gui.Config.Title = "Hello World golang wit/gui Window"
|
||||
gui.Config.Width = 640
|
||||
gui.Config.Height = 480
|
||||
gui.Config.Exit = myDefaultExit
|
||||
|
||||
w = gui.NewWindow()
|
||||
w.Dump()
|
||||
addDemoTab(w, "A Simple Tab Demo")
|
||||
addDemoTab(w, "A Second Tab")
|
||||
|
||||
if (args.GuiDemo) {
|
||||
gui.DemoToolkitWindow()
|
||||
}
|
||||
|
||||
if (args.GuiDebug) {
|
||||
gui.DebugWindow()
|
||||
}
|
||||
}
|
||||
|
||||
func addDemoTab(window *gui.Node, title string) {
|
||||
var newNode, g, g2, tb *gui.Node
|
||||
|
||||
newNode = window.NewTab(title)
|
||||
log.Println("addDemoTab() newNode.Dump")
|
||||
newNode.Dump()
|
||||
|
||||
g = newNode.NewGroup("group 1")
|
||||
dd := g.NewDropdown("demoCombo2")
|
||||
dd.AddDropdown("more 1")
|
||||
dd.AddDropdown("more 2")
|
||||
dd.AddDropdown("more 3")
|
||||
dd.OnChanged = func(*gui.Node) {
|
||||
s := dd.GetText()
|
||||
tb.SetText("hello world " + args.User + "\n" + s)
|
||||
}
|
||||
|
||||
g2 = newNode.NewGroup("group 2")
|
||||
tb = g2.NewTextbox("tb")
|
||||
log.Println("tb =", tb.GetText())
|
||||
tb.OnChanged = func(*gui.Node) {
|
||||
s := tb.GetText()
|
||||
log.Println("text =", s)
|
||||
}
|
||||
}
|
||||
|
||||
func myDefaultExit(n *gui.Node) {
|
||||
log.Println("You can Do exit() things here")
|
||||
os.Exit(0)
|
||||
}
|
||||
|
20
dropdown.go
20
dropdown.go
|
@ -7,16 +7,24 @@ import toolkit "git.wit.org/wit/gui/toolkit/andlabs"
|
|||
func commonCallback(n *Node) {
|
||||
// TODO: make all of this common code to all the widgets
|
||||
if (n.OnChanged == nil) {
|
||||
log.Println("Not Running n.OnChanged(n) == nil")
|
||||
if (Config.Options.DebugChange) {
|
||||
log.Println("Not Running n.OnChanged(n) == nil")
|
||||
}
|
||||
} else {
|
||||
log.Println("Running n.OnChanged(n)")
|
||||
if (Config.Options.DebugChange) {
|
||||
log.Println("Running n.OnChanged(n)")
|
||||
}
|
||||
n.OnChanged(n)
|
||||
}
|
||||
|
||||
if (n.custom == nil) {
|
||||
log.Println("Not Running n.custom(n) == nil")
|
||||
if (Config.Options.DebugChange) {
|
||||
log.Println("Not Running n.custom(n) == nil")
|
||||
}
|
||||
} else {
|
||||
log.Println("Running n.custom()")
|
||||
if (Config.Options.DebugChange) {
|
||||
log.Println("Running n.custom()")
|
||||
}
|
||||
n.custom()
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +33,9 @@ func (n *Node) NewDropdown(name string) *Node {
|
|||
var newT *toolkit.Toolkit
|
||||
var sNode *Node
|
||||
|
||||
log.Println("toolkit.NewDropdown() START", name)
|
||||
if (Config.Options.Debug) {
|
||||
log.Println("toolkit.NewDropdown() START", name)
|
||||
}
|
||||
|
||||
n.verify()
|
||||
|
||||
|
|
4
main.go
4
main.go
|
@ -17,8 +17,8 @@ func init() {
|
|||
|
||||
Config.counter = 0
|
||||
Config.prefix = "wit"
|
||||
Config.DebugNode = false
|
||||
Config.DebugTabs = false
|
||||
Config.Options.DebugNode = false
|
||||
Config.Options.DebugTabs = false
|
||||
|
||||
title := "master"
|
||||
w := 640
|
||||
|
|
52
structs.go
52
structs.go
|
@ -30,16 +30,29 @@ func GetDebugToolkit () bool {
|
|||
}
|
||||
|
||||
func ShowDebugValues() {
|
||||
log.Println("\t wit/gui Debug =", Config.Debug)
|
||||
log.Println("\t wit/gui DebugDump =", Config.DebugDump)
|
||||
log.Println("\t wit/gui DebugNode =", Config.DebugNode)
|
||||
log.Println("\t wit/gui DebugTabs =", Config.DebugTabs)
|
||||
log.Println("\t wit/gui DebugTable =", Config.DebugTable)
|
||||
log.Println("\t wit/gui DebugWindow =", Config.DebugWindow)
|
||||
log.Println("\t wit/gui DebugWindow =", Config.DebugWindow)
|
||||
log.Println("\t wit/gui Debug =", Config.Options.Debug)
|
||||
log.Println("\t wit/gui DebugDump =", Config.Options.DebugDump)
|
||||
log.Println("\t wit/gui DebugNode =", Config.Options.DebugNode)
|
||||
log.Println("\t wit/gui DebugTabs =", Config.Options.DebugTabs)
|
||||
// log.Println("\t wit/gui DebugTable =", Config.Options.DebugTable)
|
||||
// log.Println("\t wit/gui DebugWindow =", Config.Options.DebugWindow)
|
||||
log.Println("\t wit/gui DebugChange =", Config.Options.DebugChange)
|
||||
|
||||
log.Println("\t wit/gui DebugToolkit =", toolkit.DebugToolkit)
|
||||
}
|
||||
|
||||
type GuiOptions struct {
|
||||
// These are global debugging settings
|
||||
// TODO: move to a standard logging system
|
||||
Debug bool
|
||||
DebugDump bool
|
||||
DebugNode bool
|
||||
DebugTabs bool
|
||||
// DebugTable bool
|
||||
// DebugWindow bool
|
||||
DebugChange bool `help:"debug mouse clicks and keyboard input"`
|
||||
}
|
||||
|
||||
type GuiConfig struct {
|
||||
// This is the master node. The Binary Tree starts here
|
||||
master *Node
|
||||
|
@ -50,14 +63,7 @@ type GuiConfig struct {
|
|||
Height int
|
||||
Exit func(*Node)
|
||||
|
||||
// These are global debugging settings
|
||||
// TODO: move to a standard logging system
|
||||
Debug bool
|
||||
DebugDump bool
|
||||
DebugNode bool
|
||||
DebugTabs bool
|
||||
DebugTable bool
|
||||
DebugWindow bool
|
||||
Options GuiOptions
|
||||
|
||||
// hacks
|
||||
depth int
|
||||
|
@ -124,7 +130,7 @@ func (n *Node) Window() *Node {
|
|||
}
|
||||
|
||||
func (n *Node) Dump() {
|
||||
if ! Config.DebugDump {
|
||||
if ! Config.Options.DebugDump {
|
||||
return
|
||||
}
|
||||
IndentPrintln("NODE DUMP START")
|
||||
|
@ -162,14 +168,16 @@ func (n *Node) Dump() {
|
|||
IndentPrintln("NODE DUMP END")
|
||||
}
|
||||
|
||||
/*
|
||||
func (n *Node) SetName(name string) {
|
||||
n.toolkit.SetWindowTitle(name)
|
||||
return
|
||||
}
|
||||
*/
|
||||
|
||||
func (n *Node) Append(child *Node) {
|
||||
n.children = append(n.children, child)
|
||||
if (Config.Debug) {
|
||||
if (Config.Options.Debug) {
|
||||
log.Println("child node:")
|
||||
child.Dump()
|
||||
log.Println("parent node:")
|
||||
|
@ -212,11 +220,11 @@ func (n *Node) ListChildren(dump bool) {
|
|||
if len(n.children) == 0 {
|
||||
if (n.parent == nil) {
|
||||
} else {
|
||||
if (Config.DebugNode) {
|
||||
if (Config.Options.DebugNode) {
|
||||
log.Println("\t\t\tparent =",n.parent.id)
|
||||
}
|
||||
if (listChildrenParent != nil) {
|
||||
if (Config.DebugNode) {
|
||||
if (Config.Options.DebugNode) {
|
||||
log.Println("\t\t\tlistChildrenParent =",listChildrenParent.id)
|
||||
}
|
||||
if (listChildrenParent.id != n.parent.id) {
|
||||
|
@ -225,7 +233,7 @@ func (n *Node) ListChildren(dump bool) {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (Config.DebugNode) {
|
||||
if (Config.Options.DebugNode) {
|
||||
log.Println("\t\t", n.id, "has no children")
|
||||
}
|
||||
return
|
||||
|
@ -233,7 +241,7 @@ func (n *Node) ListChildren(dump bool) {
|
|||
for _, child := range n.children {
|
||||
// log.Println("\t\t", child.id, child.Width, child.Height, child.Name)
|
||||
if (child.parent != nil) {
|
||||
if (Config.DebugNode) {
|
||||
if (Config.Options.DebugNode) {
|
||||
log.Println("\t\t\tparent =",child.parent.id)
|
||||
}
|
||||
} else {
|
||||
|
@ -243,7 +251,7 @@ func (n *Node) ListChildren(dump bool) {
|
|||
if (dump == true) {
|
||||
child.Dump()
|
||||
}
|
||||
if (Config.DebugNode) {
|
||||
if (Config.Options.DebugNode) {
|
||||
if (child.children == nil) {
|
||||
log.Println("\t\t", child.id, "has no children")
|
||||
} else {
|
||||
|
|
4
text.go
4
text.go
|
@ -18,7 +18,9 @@ func (n *Node) NewLabel(text string) *Node {
|
|||
}
|
||||
|
||||
func (n *Node) SetText(str string) bool {
|
||||
log.Println("gui.SetText() value =", str)
|
||||
if (Config.Options.DebugChange) {
|
||||
log.Println("gui.SetText() value =", str)
|
||||
}
|
||||
if (n.toolkit == nil) {
|
||||
return false
|
||||
}
|
||||
|
|
25
textbox.go
25
textbox.go
|
@ -22,13 +22,26 @@ func (n *Node) NewTextbox(name string) *Node {
|
|||
newt.Name = name
|
||||
// newt.Custom = func () {
|
||||
newt.OnChanged = func (*toolkit.Toolkit) {
|
||||
println("AM IN CALLBACK. SETTING NODE.checked START")
|
||||
if (Config.Options.DebugChange) {
|
||||
log.Println("AM IN CALLBACK. SETTING NODE.checked START")
|
||||
c.Dump()
|
||||
c.toolkit.Dump()
|
||||
}
|
||||
c.text = c.toolkit.GetText()
|
||||
c.Dump()
|
||||
c.toolkit.Dump()
|
||||
c.OnChanged(n)
|
||||
println("n.toolkit.GetText() =", c.text)
|
||||
println("AM IN CALLBACK. SETTING NODE.checked END")
|
||||
if (c.OnChanged == nil) {
|
||||
if (Config.Options.DebugChange) {
|
||||
log.Println("this is println?")
|
||||
}
|
||||
} else {
|
||||
if (Config.Options.DebugChange) {
|
||||
log.Println("this is println? running c.OnChanged() here")
|
||||
}
|
||||
c.OnChanged(n)
|
||||
}
|
||||
if (Config.Options.DebugChange) {
|
||||
log.Println("n.toolkit.GetText() =", c.text)
|
||||
log.Println("AM IN CALLBACK. SETTING NODE.checked END")
|
||||
}
|
||||
}
|
||||
|
||||
return c
|
||||
|
|
|
@ -18,7 +18,9 @@ func (t Toolkit) NewButton(name string) *Toolkit {
|
|||
return nil
|
||||
}
|
||||
|
||||
log.Println("gui.Toolbox.NewGroup() create", name)
|
||||
if (DebugToolkit) {
|
||||
log.Println("gui.Toolbox.NewGroup() create", name)
|
||||
}
|
||||
b = ui.NewButton(name)
|
||||
newt.uiButton = b
|
||||
|
||||
|
@ -26,20 +28,34 @@ func (t Toolkit) NewButton(name string) *Toolkit {
|
|||
log.Println("TODO: IN TOOLKIT GOROUTINE. SHOULD LEAVE HERE VIA channels. button name =", name)
|
||||
t.Dump()
|
||||
newt.Dump()
|
||||
log.Println("wit/gui/toolkit NewButton() Should do something here")
|
||||
if (DebugToolkit) {
|
||||
log.Println("wit/gui/toolkit NewButton() Should do something here")
|
||||
}
|
||||
if (newt.Custom == nil) {
|
||||
log.Println("wit/gui/toolkit NewButton() toolkit.Custom == nil")
|
||||
if (DebugToolkit) {
|
||||
log.Println("wit/gui/toolkit NewButton() toolkit.Custom == nil")
|
||||
}
|
||||
} else {
|
||||
log.Println("wit/gui/toolkit NewButton() toolkit.Custom() START")
|
||||
if (DebugToolkit) {
|
||||
log.Println("wit/gui/toolkit NewButton() toolkit.Custom() START")
|
||||
}
|
||||
newt.Custom()
|
||||
log.Println("wit/gui/toolkit NewButton() toolkit.Custom() END")
|
||||
if (DebugToolkit) {
|
||||
log.Println("wit/gui/toolkit NewButton() toolkit.Custom() END")
|
||||
}
|
||||
}
|
||||
if (t.Custom == nil) {
|
||||
log.Println("wit/gui/toolkit NewButton() parent toolkit.Custom == nil")
|
||||
if (DebugToolkit) {
|
||||
log.Println("wit/gui/toolkit NewButton() parent toolkit.Custom == nil")
|
||||
}
|
||||
} else {
|
||||
log.Println("wit/gui/toolkit NewButton() running parent toolkit.Custom() START (IS THIS A BAD IDEA?)")
|
||||
if (DebugToolkit) {
|
||||
log.Println("wit/gui/toolkit NewButton() running parent toolkit.Custom() START (IS THIS A BAD IDEA?)")
|
||||
}
|
||||
t.Custom()
|
||||
log.Println("wit/gui/toolkit NewButton() running parent toolkit.Custom() END (IS THIS A BAD IDEA?)")
|
||||
if (DebugToolkit) {
|
||||
log.Println("wit/gui/toolkit NewButton() running parent toolkit.Custom() END (IS THIS A BAD IDEA?)")
|
||||
}
|
||||
}
|
||||
log.Println("TODO: LEFT TOOLKIT GOROUTINE button name =", name)
|
||||
})
|
||||
|
|
|
@ -12,30 +12,38 @@ func init() {
|
|||
|
||||
func (t Toolkit) commonChange(widget string) {
|
||||
s := t.String()
|
||||
log.Println("gui.Toolkit.ui.OnChanged() =", s)
|
||||
if (DebugToolkit) {
|
||||
log.Println("gui.Toolkit.ui.OnChanged() =", s)
|
||||
}
|
||||
if (t.OnChanged != nil) {
|
||||
log.Println("gui.Toolkit.OnChanged() trying to run toolkit.OnChanged() entered val =", s)
|
||||
if (DebugToolkit) {
|
||||
log.Println("gui.Toolkit.OnChanged() trying to run toolkit.OnChanged() entered val =", s)
|
||||
}
|
||||
t.OnChanged(&t)
|
||||
return
|
||||
}
|
||||
if (t.Custom != nil) {
|
||||
log.Println("gui.Toolkit.OnChanged() Running toolkit.Custom()")
|
||||
t.Dump()
|
||||
if (DebugToolkit) {
|
||||
log.Println("gui.Toolkit.OnChanged() Running toolkit.Custom()")
|
||||
t.Dump()
|
||||
}
|
||||
t.Custom()
|
||||
return
|
||||
}
|
||||
log.Println("gui.Toolkit.OnChanged() ENDED without finding any callback")
|
||||
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 Toolkit) broken() bool {
|
||||
if (t.uiBox == nil) {
|
||||
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) {
|
||||
|
|
|
@ -9,7 +9,9 @@ import _ "github.com/andlabs/ui/winmanifest"
|
|||
|
||||
func (t *Toolkit) NewDropdown(title string) *Toolkit {
|
||||
// make new node here
|
||||
log.Println("gui.Toolbox.NewDropdownCombobox()")
|
||||
if (DebugToolkit) {
|
||||
log.Println("gui.Toolbox.NewDropdownCombobox()", title)
|
||||
}
|
||||
var newt Toolkit
|
||||
|
||||
if t.broken() {
|
||||
|
|
|
@ -17,7 +17,9 @@ func (t Toolkit) NewGroup(title string) *Toolkit {
|
|||
return nil
|
||||
}
|
||||
|
||||
log.Println("gui.Toolbox.NewGroup() create", title)
|
||||
if (DebugToolkit) {
|
||||
log.Println("gui.Toolbox.NewGroup() create", title)
|
||||
}
|
||||
g := ui.NewGroup(title)
|
||||
g.SetMargined(margin)
|
||||
t.uiBox.Append(g, stretchy)
|
||||
|
|
|
@ -6,9 +6,6 @@ import "os"
|
|||
import "github.com/andlabs/ui"
|
||||
import _ "github.com/andlabs/ui/winmanifest"
|
||||
|
||||
import "github.com/davecgh/go-spew/spew"
|
||||
|
||||
// func NewSlider(b *ui.Box, name string *Toolkit {
|
||||
func (t Toolkit) NewSlider(title string, x int, y int) *Toolkit {
|
||||
// make new node here
|
||||
log.Println("gui.Toolkit.NewSpinbox()", x, y)
|
||||
|
@ -27,24 +24,7 @@ func (t Toolkit) NewSlider(title string, x int, y int) *Toolkit {
|
|||
t.uiBox.Append(s, stretchy)
|
||||
|
||||
s.OnChanged(func(spin *ui.Slider) {
|
||||
i := spin.Value()
|
||||
log.Println("gui.Toolkit.ui.Slider.OnChanged() val =", i)
|
||||
if (DebugToolkit) {
|
||||
log.Println("gui.Toolkit.ui.OnChanged() val =", i)
|
||||
scs := spew.ConfigState{MaxDepth: 1}
|
||||
scs.Dump(newt)
|
||||
}
|
||||
if (newt.OnChanged != nil) {
|
||||
log.Println("gui.Toolkit.OnChanged() trying to run toolkit.OnChanged() entered val =", i)
|
||||
newt.OnChanged(&newt)
|
||||
return
|
||||
}
|
||||
if (newt.Custom != nil) {
|
||||
log.Println("gui.Toolkit.OnChanged() Running toolkit.Custom()")
|
||||
newt.Custom()
|
||||
return
|
||||
}
|
||||
log.Println("gui.Toolkit.OnChanged() ENDED without finding any callback")
|
||||
newt.commonChange("Slider")
|
||||
})
|
||||
|
||||
return &newt
|
||||
|
|
|
@ -6,9 +6,6 @@ import "os"
|
|||
import "github.com/andlabs/ui"
|
||||
import _ "github.com/andlabs/ui/winmanifest"
|
||||
|
||||
import "github.com/davecgh/go-spew/spew"
|
||||
|
||||
// func NewSlider(b *ui.Box, name string *Toolkit {
|
||||
func (t Toolkit) NewSpinner(title string, x int, y int) *Toolkit {
|
||||
// make new node here
|
||||
log.Println("gui.Toolkit.NewSpinner()", x, y)
|
||||
|
@ -26,16 +23,7 @@ func (t Toolkit) NewSpinner(title string, x int, y int) *Toolkit {
|
|||
t.uiBox.Append(s, stretchy)
|
||||
|
||||
s.OnChanged(func(s *ui.Spinbox) {
|
||||
i := s.Value()
|
||||
if (DebugToolkit) {
|
||||
log.Println("gui.Toolkit.ui.OnChanged() val =", i)
|
||||
scs := spew.ConfigState{MaxDepth: 1}
|
||||
scs.Dump(newt)
|
||||
}
|
||||
if (t.OnChanged != nil) {
|
||||
log.Println("gui.Toolkit.OnChanged() entered val =", i)
|
||||
newt.OnChanged(&newt)
|
||||
}
|
||||
newt.commonChange("Spinner")
|
||||
})
|
||||
|
||||
return &newt
|
||||
|
|
|
@ -93,7 +93,7 @@ func forceDump(t *Toolkit) {
|
|||
}
|
||||
|
||||
func (t *Toolkit) GetText() string {
|
||||
forceDump(t)
|
||||
t.Dump()
|
||||
if (DebugToolkit) {
|
||||
log.Println("gui.Toolkit.Text() Enter")
|
||||
scs := spew.ConfigState{MaxDepth: 1}
|
||||
|
@ -110,7 +110,9 @@ func (t *Toolkit) GetText() string {
|
|||
log.Println("gui.Toolkit.Value() =", t.uiMultilineEntry.Text())
|
||||
}
|
||||
text := t.uiMultilineEntry.Text()
|
||||
log.Println("gui.Toolkit.Value() text =", text)
|
||||
if (DebugToolkit) {
|
||||
log.Println("gui.Toolkit.Value() text =", text)
|
||||
}
|
||||
t.text = text
|
||||
return text
|
||||
}
|
||||
|
|
|
@ -61,14 +61,18 @@ func (t *Toolkit) AddTab(name string) *Toolkit {
|
|||
func tabSetMargined(tab *ui.Tab) {
|
||||
c := tab.NumPages()
|
||||
for i := 0; i < c; i++ {
|
||||
log.Println("SetMargined", i, margin)
|
||||
if (DebugToolkit) {
|
||||
log.Println("SetMargined", i, margin)
|
||||
}
|
||||
tab.SetMargined(i, margin)
|
||||
}
|
||||
}
|
||||
|
||||
func newTab(w *ui.Window, name string) *Toolkit {
|
||||
log.Println("gui.toolkit.NewTab() ADD", name)
|
||||
var t Toolkit
|
||||
if (DebugToolkit) {
|
||||
log.Println("gui.toolkit.NewTab() ADD", name)
|
||||
}
|
||||
|
||||
if (w == nil) {
|
||||
log.Println("gui.toolkit.NewTab() node.UiWindow == nil. I can't add a tab without a window")
|
||||
|
@ -77,7 +81,9 @@ func newTab(w *ui.Window, name string) *Toolkit {
|
|||
time.Sleep(1 * time.Second)
|
||||
return nil
|
||||
}
|
||||
log.Println("gui.toolkit.AddTab() START name =", name)
|
||||
if (DebugToolkit) {
|
||||
log.Println("gui.toolkit.AddTab() START name =", name)
|
||||
}
|
||||
tab := ui.NewTab()
|
||||
w.SetMargined(margin)
|
||||
|
||||
|
@ -94,14 +100,18 @@ func newTab(w *ui.Window, name string) *Toolkit {
|
|||
}
|
||||
|
||||
func (t *Toolkit) appendTab(name string) *Toolkit {
|
||||
log.Println("gui.toolkit.NewTab() ADD", name)
|
||||
var newT Toolkit
|
||||
if (DebugToolkit) {
|
||||
log.Println("gui.toolkit.NewTab() ADD", name)
|
||||
}
|
||||
|
||||
if (t.uiTab == nil) {
|
||||
log.Println("gui.Toolkit.UiWindow == nil. I can't add a widget without a place to put it")
|
||||
panic("should never have happened. wit/gui/toolkit has ui.Tab == nil")
|
||||
}
|
||||
log.Println("gui.toolkit.AddTab() START name =", name)
|
||||
if (DebugToolkit) {
|
||||
log.Println("gui.toolkit.AddTab() START name =", name)
|
||||
}
|
||||
|
||||
var hbox *ui.Box
|
||||
if (defaultBehavior) {
|
||||
|
|
|
@ -6,7 +6,9 @@ import "github.com/andlabs/ui"
|
|||
import _ "github.com/andlabs/ui/winmanifest"
|
||||
|
||||
func (t Toolkit) NewTextbox(name string) *Toolkit {
|
||||
log.Println("gui.Toolkit.NewTextbox()", name)
|
||||
if (DebugToolkit) {
|
||||
log.Println("gui.Toolkit.NewTextbox()", name)
|
||||
}
|
||||
var newt Toolkit
|
||||
|
||||
if t.broken() {
|
||||
|
|
|
@ -22,17 +22,25 @@ func NewWindow(title string, x int, y int) *Toolkit {
|
|||
w.SetBorderless(canvas)
|
||||
w.SetMargined(margin)
|
||||
w.OnClosing(func(*ui.Window) bool {
|
||||
log.Println("ui.Window().OnExit() SHOULD ATTEMPT CALLBACK here")
|
||||
t.Dump()
|
||||
if (DebugToolkit) {
|
||||
log.Println("ui.Window().OnExit() SHOULD ATTEMPT CALLBACK here")
|
||||
t.Dump()
|
||||
}
|
||||
if (t.OnExit != nil) {
|
||||
log.Println("ui.Window().OnExit() ATTEMPTING toolkit.OnExit CALLBACK")
|
||||
if (DebugToolkit) {
|
||||
log.Println("ui.Window().OnExit() ATTEMPTING toolkit.OnExit CALLBACK")
|
||||
}
|
||||
t.OnExit(&t)
|
||||
}
|
||||
if (t.Custom != nil) {
|
||||
log.Println("ui.Window().Custom() ATTEMPTING toolkit.Custom CALLBACK")
|
||||
if (DebugToolkit) {
|
||||
log.Println("ui.Window().Custom() ATTEMPTING toolkit.Custom CALLBACK")
|
||||
}
|
||||
t.Custom()
|
||||
}
|
||||
log.Println("ui.Window().OnExit() Toolkit.OnExit is nil")
|
||||
if (DebugToolkit) {
|
||||
log.Println("ui.Window().OnExit() Toolkit.OnExit is nil")
|
||||
}
|
||||
return true
|
||||
})
|
||||
w.Show()
|
||||
|
|
|
@ -33,52 +33,59 @@ func DebugTab() {
|
|||
|
||||
var checkd, checkdn, checkdt, checkdtk *Node
|
||||
|
||||
//////////////////////// debug flags //////////////////////////////////
|
||||
func debugFlags(n *Node) {
|
||||
var df, checkd, checkdn, checkdd, changeCheckbox *Node
|
||||
df = n.NewGroup("Debug Flags")
|
||||
df.NewLabel("flags to control debugging output")
|
||||
|
||||
checkd = df.NewCheckbox("Debug")
|
||||
checkd.OnChanged = func(*Node) {
|
||||
checkd.checked = checkd.toolkit.Checked()
|
||||
Config.Options.Debug = checkd.checked
|
||||
if (Config.Options.Debug) {
|
||||
log.Println("Debug turned on")
|
||||
} else {
|
||||
log.Println("Debug turned off")
|
||||
}
|
||||
}
|
||||
|
||||
checkdn = df.NewCheckbox("Debug Node")
|
||||
checkdn.OnChanged = func(*Node) {
|
||||
checkdn.checked = checkdn.toolkit.Checked()
|
||||
Config.Options.DebugNode = checkdn.checked
|
||||
}
|
||||
|
||||
checkdd = df.NewCheckbox("Debug node.Dump()")
|
||||
checkdd.OnChanged = func(*Node) {
|
||||
Config.Options.DebugDump = checkdd.toolkit.Checked()
|
||||
}
|
||||
|
||||
changeCheckbox = df.NewCheckbox("Debug Change")
|
||||
changeCheckbox.OnChanged = func(*Node) {
|
||||
Config.Options.DebugChange = changeCheckbox.toolkit.Checked()
|
||||
}
|
||||
|
||||
df.NewButton("Dump Debug Flags", func () {
|
||||
ShowDebugValues()
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
func (n *Node) DebugTab(title string) *Node {
|
||||
var newN, gog, g1, g2, g3, dd, gf *Node
|
||||
var newN, gog, g1, g2, g3, dd *Node
|
||||
|
||||
// time.Sleep(1 * time.Second)
|
||||
newN = n.NewTab(title)
|
||||
newN.Dump()
|
||||
|
||||
//////////////////////// main debug things //////////////////////////////////
|
||||
gog = newN.NewGroup("GOLANG")
|
||||
gog.NewLabel("go language")
|
||||
gog.NewButton("GO Language Debug", func () {
|
||||
GolangDebugWindow()
|
||||
})
|
||||
|
||||
gf = newN.NewGroup("Debug Flags")
|
||||
gf.NewLabel("flags to control debugging output")
|
||||
|
||||
checkd = gf.NewCheckbox("Debug")
|
||||
checkd.OnChanged = func(*Node) {
|
||||
checkd.checked = checkd.toolkit.Checked()
|
||||
Config.Debug = checkd.checked
|
||||
if (Config.Debug) {
|
||||
} else {
|
||||
}
|
||||
}
|
||||
|
||||
checkdn = gf.NewCheckbox("Debug Node")
|
||||
checkdn.OnChanged = func(*Node) {
|
||||
checkdn.checked = checkdn.toolkit.Checked()
|
||||
Config.DebugNode = checkdn.checked
|
||||
}
|
||||
|
||||
checkdd := gf.NewCheckbox("Debug node.Dump()")
|
||||
checkdd.OnChanged = func(*Node) {
|
||||
Config.DebugDump = checkdd.toolkit.Checked()
|
||||
}
|
||||
|
||||
checkdt = gf.NewCheckbox("Debug Tabs")
|
||||
checkdtk = gf.NewCheckbox("Debug Toolkit")
|
||||
|
||||
// Debug bool
|
||||
// DebugNode bool
|
||||
// DebugTabs bool
|
||||
// DebugTable bool
|
||||
// DebugWindow bool
|
||||
// DebugToolkit bool
|
||||
|
||||
gog.NewLabel("wit/gui package")
|
||||
gog.NewButton("WIT/GUI Package Debug", func () {
|
||||
Config.Width = 640
|
||||
|
@ -92,6 +99,9 @@ func (n *Node) DebugTab(title string) *Node {
|
|||
DemoToolkitWindow()
|
||||
})
|
||||
|
||||
debugFlags(newN)
|
||||
|
||||
//////////////////////// window debugging things //////////////////////////////////
|
||||
g1 = newN.NewGroup("Current Windows")
|
||||
dd = g1.NewDropdown("Window Dropdown")
|
||||
log.Println("dd =", dd)
|
||||
|
|
Loading…
Reference in New Issue