Got a bunch of examples working

This commit is contained in:
2023-04-15 22:23:08 -04:00
parent e16195d274
commit ed6de3a36f
20 changed files with 166 additions and 234 deletions

View File

@@ -7,7 +7,6 @@ import _ "image/png"
import "github.com/jezek/xgbutil/gopher"
import "git.tebibyte.media/sashakoshka/tomo"
import "git.tebibyte.media/sashakoshka/tomo/popups"
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"
@@ -17,7 +16,7 @@ func main () {
}
func run () {
window, _ := tomo.NewWindow(2, 2)
window, _ := tomo.NewWindow(tomo.Bounds(0, 0, 0, 0))
window.SetTitle("Tomo Logo")
file, err := os.Open("assets/banner.png")
@@ -26,16 +25,17 @@ func run () {
file.Close()
if err != nil { fatalError(window, err); return }
container := containers.NewContainer(layouts.Vertical { true, true })
container := containers.NewVBox(true, true)
logoImage := elements.NewImage(logo)
button := elements.NewButton("Show me a gopher instead")
button.OnClick (func () { container.Warp (func () {
container.DisownAll()
gopher, _, err :=
image.Decode(bytes.NewReader(gopher.GopherPng()))
if err != nil { fatalError(window, err); return }
container.Adopt(elements.NewImage(gopher),true)
}) })
button.OnClick (func () {
window.SetTitle("Not the Tomo Logo")
container.DisownAll()
gopher, _, err :=
image.Decode(bytes.NewReader(gopher.GopherPng()))
if err != nil { fatalError(window, err); return }
container.Adopt(elements.NewImage(gopher),true)
})
container.Adopt(logoImage, true)
container.Adopt(button, false)