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/verticalLayout/main.go

39 lines
996 B
Go
Raw Normal View History

2023-01-10 02:22:08 +00:00
package main
import "git.tebibyte.media/sashakoshka/tomo"
import "git.tebibyte.media/sashakoshka/tomo/elements/basic"
import "git.tebibyte.media/sashakoshka/tomo/elements/layouts"
import _ "git.tebibyte.media/sashakoshka/tomo/backends/x"
func main () {
tomo.Run(run)
}
func run () {
window, _ := tomo.NewWindow(2, 2)
window.SetTitle("vertical stack")
2023-01-10 21:39:37 +00:00
container := basic.NewContainer(layouts.Vertical { true, true })
window.Adopt(container)
2023-01-10 02:22:08 +00:00
2023-01-10 22:34:40 +00:00
label := basic.NewLabel("it is a label hehe")
button := basic.NewButton("drawing pad")
okButton := basic.NewButton("OK")
2023-01-10 21:39:37 +00:00
button.OnClick (func () {
2023-01-10 22:34:40 +00:00
container.Disown(label)
container.Disown(button)
container.Disown(okButton)
container.Adopt(basic.NewLabel("Draw here:"), false)
container.Adopt(basic.NewTest(), true)
container.Adopt(okButton, false)
2023-01-10 21:39:37 +00:00
})
2023-01-10 22:34:40 +00:00
okButton.OnClick(tomo.Stop)
2023-01-10 21:39:37 +00:00
container.Adopt(label, true)
container.Adopt(button, false)
2023-01-10 22:34:40 +00:00
container.Adopt(okButton, false)
2023-01-10 02:22:08 +00:00
window.OnClose(tomo.Stop)
window.Show()
}