diff options
Diffstat (limited to 'toolkit/andlabs')
| -rw-r--r-- | toolkit/andlabs/box.go | 13 | ||||
| -rw-r--r-- | toolkit/andlabs/button.go | 29 | ||||
| -rw-r--r-- | toolkit/andlabs/common.go | 11 | ||||
| -rw-r--r-- | toolkit/andlabs/group.go | 19 | ||||
| -rw-r--r-- | toolkit/andlabs/main.go | 1 | ||||
| -rw-r--r-- | toolkit/andlabs/structs.go | 3 |
6 files changed, 55 insertions, 21 deletions
diff --git a/toolkit/andlabs/box.go b/toolkit/andlabs/box.go index ac31f0d..8347bab 100644 --- a/toolkit/andlabs/box.go +++ b/toolkit/andlabs/box.go @@ -37,6 +37,19 @@ func (t *Toolkit) NewBox() *Toolkit { return &newTK } + if (t.uiWindow != nil) { + log.Println("\tgui.Toolbox.NewBox() is a Window") + var newT Toolkit + + vbox := ui.NewVerticalBox() + vbox.SetPadded(padded) + t.uiWindow.SetChild(vbox) + newT.uiBox = vbox + newT.Name = t.Name + + // panic("WTF") + return &newT + } log.Println("\tgui.Toolbox.NewBox() FAILED. Couldn't figure out where to make a box") t.Dump() return nil diff --git a/toolkit/andlabs/button.go b/toolkit/andlabs/button.go index 4e6ff52..e0b7d97 100644 --- a/toolkit/andlabs/button.go +++ b/toolkit/andlabs/button.go @@ -1,7 +1,7 @@ package toolkit import "log" -import "os" +// import "os" import "github.com/andlabs/ui" import _ "github.com/andlabs/ui/winmanifest" @@ -11,15 +11,12 @@ func (t Toolkit) NewButton(name string) *Toolkit { var newt Toolkit var b *ui.Button - if (t.uiBox == nil) { - log.Println("gui.ToolboxNode.NewButton() node.UiBox == nil. I can't add a range UI element without a place to put it") - log.Println("probably could just make a box here?") - os.Exit(0) + if t.broken() { return nil } if (DebugToolkit) { - log.Println("gui.Toolbox.NewGroup() create", name) + log.Println("gui.Toolbox.NewButton() create", name) } b = ui.NewButton(name) newt.uiButton = b @@ -40,6 +37,7 @@ func (t Toolkit) NewButton(name string) *Toolkit { log.Println("wit/gui/toolkit NewButton() toolkit.Custom() START") } newt.Custom() + return if (DebugToolkit) { log.Println("wit/gui/toolkit NewButton() toolkit.Custom() END") } @@ -53,14 +51,29 @@ func (t Toolkit) NewButton(name string) *Toolkit { log.Println("wit/gui/toolkit NewButton() running parent toolkit.Custom() START (IS THIS A BAD IDEA?)") } t.Custom() + return 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) + log.Println("TODO: LEFT TOOLKIT GOROUTINE WITH NOTHING TO DO button name =", name) }) - t.uiBox.Append(b, stretchy) + if (DebugToolkit) { + log.Println("gui.Toolbox.NewButton() about to append to Box parent t:", name) + t.Dump() + log.Println("gui.Toolbox.NewButton() about to append to Box new t:", name) + newt.Dump() + } + if (t.uiBox != nil) { + t.uiBox.Append(b, stretchy) + } else if (t.uiWindow != nil) { + t.uiWindow.SetChild(b) + } else { + log.Println("ERROR: wit/gui andlabs couldn't place this button in a box or a window") + log.Println("ERROR: wit/gui andlabs couldn't place this button in a box or a window") + return &t + } return &newt } diff --git a/toolkit/andlabs/common.go b/toolkit/andlabs/common.go index 569621d..e997aca 100644 --- a/toolkit/andlabs/common.go +++ b/toolkit/andlabs/common.go @@ -2,9 +2,6 @@ package toolkit import "log" -// import "github.com/andlabs/ui" -// import _ "github.com/andlabs/ui/winmanifest" - func init() { log.Println("gui/toolkit init() Setting defaultBehavior = true") setDefaultBehavior(true) @@ -37,8 +34,13 @@ func (t Toolkit) commonChange(widget string) { // 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 { +func (t *Toolkit) broken() bool { if (t.uiBox == nil) { + if (t.uiWindow != nil) { + 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? @@ -48,6 +50,7 @@ func (t Toolkit) broken() bool { } 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 diff --git a/toolkit/andlabs/group.go b/toolkit/andlabs/group.go index f48a78d..5b315a4 100644 --- a/toolkit/andlabs/group.go +++ b/toolkit/andlabs/group.go @@ -10,19 +10,21 @@ import _ "github.com/andlabs/ui/winmanifest" func (t Toolkit) NewGroup(title string) *Toolkit { var newt Toolkit - if (t.uiBox == nil) { - log.Println("gui.ToolboxNode.NewGroup() node.UiBox == nil. I can't add a range UI element without a place to put it") - log.Println("probably could just make a box here?") - os.Exit(0) - return nil - } - if (DebugToolkit) { log.Println("gui.Toolbox.NewGroup() create", title) } g := ui.NewGroup(title) g.SetMargined(margin) - t.uiBox.Append(g, stretchy) + + if (t.uiBox != nil) { + t.uiBox.Append(g, stretchy) + } else if (t.uiWindow != nil) { + t.uiWindow.SetChild(g) + } else { + log.Println("gui.ToolboxNode.NewGroup() node.UiBox == nil. I can't add a range UI element without a place to put it") + log.Println("probably could just make a box here?") + os.Exit(0) + } hbox := ui.NewVerticalBox() hbox.SetPadded(padded) @@ -30,6 +32,7 @@ func (t Toolkit) NewGroup(title string) *Toolkit { newt.uiGroup = g newt.uiBox = hbox + newt.uiWindow = t.uiWindow newt.Name = title t.Dump() diff --git a/toolkit/andlabs/main.go b/toolkit/andlabs/main.go index cea0486..d1dc7e6 100644 --- a/toolkit/andlabs/main.go +++ b/toolkit/andlabs/main.go @@ -4,6 +4,7 @@ import ( "log" "github.com/andlabs/ui" + // the _ means we only need this for the init() _ "github.com/andlabs/ui/winmanifest" ) diff --git a/toolkit/andlabs/structs.go b/toolkit/andlabs/structs.go index 90f9409..374627c 100644 --- a/toolkit/andlabs/structs.go +++ b/toolkit/andlabs/structs.go @@ -87,9 +87,10 @@ func (t *Toolkit) String() string { } func forceDump(t *Toolkit) { + tmp := DebugToolkit DebugToolkit = true t.Dump() - DebugToolkit = false + DebugToolkit = tmp } func (t *Toolkit) GetText() string { |
