summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gui-example/main.go5
-rw-r--r--gui.go2
-rw-r--r--structs.go2
-rw-r--r--window-debug.go18
-rw-r--r--window-template.go8
5 files changed, 24 insertions, 11 deletions
diff --git a/gui-example/main.go b/gui-example/main.go
index cba4545..69f3172 100644
--- a/gui-example/main.go
+++ b/gui-example/main.go
@@ -26,7 +26,8 @@ func main() {
}
func initGUI() {
- gui.NewWindow("jcarr start", 640, 480)
+ n := gui.NewWindow("jcarr start", 640, 480)
+ n.AddDemoTab("up the rabbit hole")
}
func watchGUI() {
@@ -35,7 +36,7 @@ func watchGUI() {
log.Println("Waiting for customExit()", i)
i += 1
time.Sleep(1 * time.Second)
- if i == 2 {
+ if i == 4 {
log.Println("Sending ExampleWindow to gui.Queue()")
gui.Queue(gui.DebugWindow)
}
diff --git a/gui.go b/gui.go
index 0c903b4..b9a8d06 100644
--- a/gui.go
+++ b/gui.go
@@ -24,6 +24,8 @@ func init() {
Config.counter = 0
Config.prefix = "jwc"
+ Config.DebugNode = false
+ Config.DebugTabs = false
}
func GuiInit() {
diff --git a/structs.go b/structs.go
index 8833dd5..80c763d 100644
--- a/structs.go
+++ b/structs.go
@@ -23,6 +23,8 @@ type GuiConfig struct {
Width int
Height int
Debug bool
+ DebugNode bool
+ DebugTabs bool
DebugTable bool
Exit func(*GuiWindow)
diff --git a/window-debug.go b/window-debug.go
index ef457aa..3afe8e3 100644
--- a/window-debug.go
+++ b/window-debug.go
@@ -356,15 +356,11 @@ func addButton(box *ui.Box, name string) *ui.Button {
return button
}
-func (n *Node) AddDemoTab(title string) {
- newNode := n.AddTab(title, makeWindowTemplate())
- newNode.Dump()
- tabSetMargined(newNode.uiTab)
-}
-
func (n *Node) AddDebugTab(title string) {
newNode := n.AddTab(title, makeWindowDebug())
- newNode.Dump()
+ if (Config.DebugNode) {
+ newNode.Dump()
+ }
tabSetMargined(newNode.uiTab)
}
@@ -372,10 +368,14 @@ func (n *Node) AddDebugTab(title string) {
//
// TODO: do proper tab tracking (will be complicated). low priority
func tabSetMargined(tab *ui.Tab) {
- log.Println("tabSetMargined() IGNORE THIS")
+ if (Config.DebugTabs) {
+ log.Println("tabSetMargined() IGNORE THIS")
+ }
c := tab.NumPages()
for i := 0; i < c; i++ {
- log.Println("tabSetMargined() i =", i)
+ if (Config.DebugTabs) {
+ log.Println("tabSetMargined() i =", i)
+ }
tab.SetMargined(i, true)
}
}
diff --git a/window-template.go b/window-template.go
index c3e30ef..82162dd 100644
--- a/window-template.go
+++ b/window-template.go
@@ -4,6 +4,14 @@ import "log"
import "github.com/andlabs/ui"
import _ "github.com/andlabs/ui/winmanifest"
+func (n *Node) AddDemoTab(title string) {
+ newNode := n.AddTab(title, makeWindowTemplate())
+ if (Config.DebugNode) {
+ newNode.Dump()
+ }
+ tabSetMargined(newNode.uiTab)
+}
+
func makeWindowTemplate() ui.Control {
hbox := ui.NewHorizontalBox()
hbox.SetPadded(true)