This repository has been archived on 2023-08-08. You can view files and clone it, but cannot push or open issues or pull requests.
tomo-old/examples/vbox/main.go

38 lines
968 B
Go
Raw Normal View History

2023-01-09 19:22:08 -07:00
package main
import "git.tebibyte.media/sashakoshka/tomo"
2023-03-30 21:19:04 -06:00
import "git.tebibyte.media/sashakoshka/tomo/elements"
2023-04-15 16:24:16 -06:00
import "git.tebibyte.media/sashakoshka/tomo/elements/testing"
import _ "git.tebibyte.media/sashakoshka/tomo/backends/all"
2023-01-09 19:22:08 -07:00
func main () {
tomo.Run(run)
}
func run () {
window, _ := tomo.NewWindow(tomo.Bounds(0, 0, 128, 128))
2023-01-09 19:22:08 -07:00
window.SetTitle("vertical stack")
2023-04-18 14:18:30 -06:00
container := elements.NewVBox(elements.SpaceBoth)
2023-01-09 19:22:08 -07:00
2023-04-18 14:18:30 -06:00
label := elements.NewLabelWrapped("it is a label hehe")
2023-03-30 21:19:04 -06:00
button := elements.NewButton("drawing pad")
okButton := elements.NewButton("OK")
2023-01-10 14:39:37 -07:00
button.OnClick (func () {
2023-01-10 16:07:51 -07:00
container.DisownAll()
2023-04-18 14:18:30 -06:00
container.Adopt(elements.NewLabel("Draw here (not really):"))
container.AdoptExpand(testing.NewMouse())
container.Adopt(okButton)
okButton.Focus()
2023-01-10 14:39:37 -07:00
})
2023-01-10 15:34:40 -07:00
okButton.OnClick(tomo.Stop)
2023-04-18 14:18:30 -06:00
container.AdoptExpand(label)
container.Adopt(button, okButton)
window.Adopt(container)
2023-01-10 14:39:37 -07:00
okButton.Focus()
2023-01-09 19:22:08 -07:00
window.OnClose(tomo.Stop)
window.Show()
}