Got a bunch of examples working
This commit is contained in:
@@ -2,7 +2,6 @@ package main
|
||||
|
||||
import "git.tebibyte.media/sashakoshka/tomo"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/flow"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/layouts"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements"
|
||||
import _ "git.tebibyte.media/sashakoshka/tomo/backends/all"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements/containers"
|
||||
@@ -14,7 +13,7 @@ func main () {
|
||||
func run () {
|
||||
window, _ := tomo.NewWindow(tomo.Bounds(0, 0, 192, 192))
|
||||
window.SetTitle("adventure")
|
||||
container := containers.NewContainer(layouts.Vertical { true, true })
|
||||
container := containers.NewVBox(true, true)
|
||||
window.Adopt(container)
|
||||
|
||||
var world flow.Flow
|
||||
@@ -31,13 +30,11 @@ func run () {
|
||||
button2 := elements.NewButton("turn around")
|
||||
button2.OnClick(world.SwitchFunc("bear"))
|
||||
|
||||
container.Warp ( func () {
|
||||
container.Adopt(label, true)
|
||||
container.Adopt(button0, false)
|
||||
container.Adopt(button1, false)
|
||||
container.Adopt(button2, false)
|
||||
button0.Focus()
|
||||
})
|
||||
container.Adopt(label, true)
|
||||
container.Adopt(button0, false)
|
||||
container.Adopt(button1, false)
|
||||
container.Adopt(button2, false)
|
||||
button0.Focus()
|
||||
},
|
||||
"wet": func () {
|
||||
label := elements.NewLabel (
|
||||
@@ -49,12 +46,10 @@ func run () {
|
||||
button1 := elements.NewButton("exit")
|
||||
button1.OnClick(tomo.Stop)
|
||||
|
||||
container.Warp (func () {
|
||||
container.Adopt(label, true)
|
||||
container.Adopt(button0, false)
|
||||
container.Adopt(button1, false)
|
||||
button0.Focus()
|
||||
})
|
||||
container.Adopt(label, true)
|
||||
container.Adopt(button0, false)
|
||||
container.Adopt(button1, false)
|
||||
button0.Focus()
|
||||
},
|
||||
"house": func () {
|
||||
label := elements.NewLabel (
|
||||
@@ -66,12 +61,10 @@ func run () {
|
||||
button0 := elements.NewButton("turn back")
|
||||
button0.OnClick(world.SwitchFunc("start"))
|
||||
|
||||
container.Warp (func () {
|
||||
container.Adopt(label, true)
|
||||
container.Adopt(button1, false)
|
||||
container.Adopt(button0, false)
|
||||
button1.Focus()
|
||||
})
|
||||
container.Adopt(label, true)
|
||||
container.Adopt(button1, false)
|
||||
container.Adopt(button0, false)
|
||||
button1.Focus()
|
||||
},
|
||||
"inside": func () {
|
||||
label := elements.NewLabel (
|
||||
@@ -84,11 +77,9 @@ func run () {
|
||||
button0 := elements.NewButton("go back outside")
|
||||
button0.OnClick(world.SwitchFunc("house"))
|
||||
|
||||
container.Warp (func () {
|
||||
container.Adopt(label, true)
|
||||
container.Adopt(button0, false)
|
||||
button0.Focus()
|
||||
})
|
||||
container.Adopt(label, true)
|
||||
container.Adopt(button0, false)
|
||||
button0.Focus()
|
||||
},
|
||||
"bear": func () {
|
||||
label := elements.NewLabel (
|
||||
@@ -100,12 +91,10 @@ func run () {
|
||||
button1 := elements.NewButton("exit")
|
||||
button1.OnClick(tomo.Stop)
|
||||
|
||||
container.Warp (func () {
|
||||
container.Adopt(label, true)
|
||||
container.Adopt(button0, false)
|
||||
container.Adopt(button1, false)
|
||||
button0.Focus()
|
||||
})
|
||||
container.Adopt(label, true)
|
||||
container.Adopt(button0, false)
|
||||
container.Adopt(button1, false)
|
||||
button0.Focus()
|
||||
},
|
||||
}
|
||||
world.Switch("start")
|
||||
|
||||
Reference in New Issue
Block a user