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() {
|
||||
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)
|
||||
}
|
||||
|
|
2
gui.go
2
gui.go
|
@ -24,6 +24,8 @@ func init() {
|
|||
|
||||
Config.counter = 0
|
||||
Config.prefix = "jwc"
|
||||
Config.DebugNode = false
|
||||
Config.DebugTabs = false
|
||||
}
|
||||
|
||||
func GuiInit() {
|
||||
|
|
|
@ -23,6 +23,8 @@ type GuiConfig struct {
|
|||
Width int
|
||||
Height int
|
||||
Debug bool
|
||||
DebugNode bool
|
||||
DebugTabs bool
|
||||
DebugTable bool
|
||||
Exit func(*GuiWindow)
|
||||
|
||||
|
|
|
@ -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())
|
||||
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) {
|
||||
if (Config.DebugTabs) {
|
||||
log.Println("tabSetMargined() IGNORE THIS")
|
||||
}
|
||||
c := tab.NumPages()
|
||||
for i := 0; i < c; i++ {
|
||||
if (Config.DebugTabs) {
|
||||
log.Println("tabSetMargined() i =", i)
|
||||
}
|
||||
tab.SetMargined(i, true)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue