EXAMPLE: correctly add a tab to the example app
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
585e7f00f0
commit
9a07e2b2af
|
@ -26,7 +26,8 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func initGUI() {
|
func initGUI() {
|
||||||
gui.NewWindow("jcarr start", 640, 480)
|
n := gui.NewWindow("jcarr start", 640, 480)
|
||||||
|
n.AddDemoTab("up the rabbit hole")
|
||||||
}
|
}
|
||||||
|
|
||||||
func watchGUI() {
|
func watchGUI() {
|
||||||
|
@ -35,7 +36,7 @@ func watchGUI() {
|
||||||
log.Println("Waiting for customExit()", i)
|
log.Println("Waiting for customExit()", i)
|
||||||
i += 1
|
i += 1
|
||||||
time.Sleep(1 * time.Second)
|
time.Sleep(1 * time.Second)
|
||||||
if i == 2 {
|
if i == 4 {
|
||||||
log.Println("Sending ExampleWindow to gui.Queue()")
|
log.Println("Sending ExampleWindow to gui.Queue()")
|
||||||
gui.Queue(gui.DebugWindow)
|
gui.Queue(gui.DebugWindow)
|
||||||
}
|
}
|
||||||
|
|
2
gui.go
2
gui.go
|
@ -24,6 +24,8 @@ func init() {
|
||||||
|
|
||||||
Config.counter = 0
|
Config.counter = 0
|
||||||
Config.prefix = "jwc"
|
Config.prefix = "jwc"
|
||||||
|
Config.DebugNode = false
|
||||||
|
Config.DebugTabs = false
|
||||||
}
|
}
|
||||||
|
|
||||||
func GuiInit() {
|
func GuiInit() {
|
||||||
|
|
|
@ -23,6 +23,8 @@ type GuiConfig struct {
|
||||||
Width int
|
Width int
|
||||||
Height int
|
Height int
|
||||||
Debug bool
|
Debug bool
|
||||||
|
DebugNode bool
|
||||||
|
DebugTabs bool
|
||||||
DebugTable bool
|
DebugTable bool
|
||||||
Exit func(*GuiWindow)
|
Exit func(*GuiWindow)
|
||||||
|
|
||||||
|
|
|
@ -356,15 +356,11 @@ func addButton(box *ui.Box, name string) *ui.Button {
|
||||||
return 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) {
|
func (n *Node) AddDebugTab(title string) {
|
||||||
newNode := n.AddTab(title, makeWindowDebug())
|
newNode := n.AddTab(title, makeWindowDebug())
|
||||||
|
if (Config.DebugNode) {
|
||||||
newNode.Dump()
|
newNode.Dump()
|
||||||
|
}
|
||||||
tabSetMargined(newNode.uiTab)
|
tabSetMargined(newNode.uiTab)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -372,10 +368,14 @@ func (n *Node) AddDebugTab(title string) {
|
||||||
//
|
//
|
||||||
// TODO: do proper tab tracking (will be complicated). low priority
|
// TODO: do proper tab tracking (will be complicated). low priority
|
||||||
func tabSetMargined(tab *ui.Tab) {
|
func tabSetMargined(tab *ui.Tab) {
|
||||||
|
if (Config.DebugTabs) {
|
||||||
log.Println("tabSetMargined() IGNORE THIS")
|
log.Println("tabSetMargined() IGNORE THIS")
|
||||||
|
}
|
||||||
c := tab.NumPages()
|
c := tab.NumPages()
|
||||||
for i := 0; i < c; i++ {
|
for i := 0; i < c; i++ {
|
||||||
|
if (Config.DebugTabs) {
|
||||||
log.Println("tabSetMargined() i =", i)
|
log.Println("tabSetMargined() i =", i)
|
||||||
|
}
|
||||||
tab.SetMargined(i, true)
|
tab.SetMargined(i, true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,14 @@ import "log"
|
||||||
import "github.com/andlabs/ui"
|
import "github.com/andlabs/ui"
|
||||||
import _ "github.com/andlabs/ui/winmanifest"
|
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 {
|
func makeWindowTemplate() ui.Control {
|
||||||
hbox := ui.NewHorizontalBox()
|
hbox := ui.NewHorizontalBox()
|
||||||
hbox.SetPadded(true)
|
hbox.SetPadded(true)
|
||||||
|
|
Loading…
Reference in New Issue