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

49 lines
1.2 KiB
Go
Raw Normal View History

package main
import "time"
import "git.tebibyte.media/sashakoshka/tomo"
2023-01-18 01:30:58 +00:00
import "git.tebibyte.media/sashakoshka/tomo/popups"
2023-03-31 03:19:04 +00:00
import "git.tebibyte.media/sashakoshka/tomo/layouts"
import "git.tebibyte.media/sashakoshka/tomo/elements"
import "git.tebibyte.media/sashakoshka/tomo/elements/containers"
import _ "git.tebibyte.media/sashakoshka/tomo/backends/all"
func main () {
tomo.Run(run)
}
func run () {
window, _ := tomo.NewWindow(tomo.Bounds(0, 0, 0, 0))
window.SetTitle("Approaching")
2023-03-31 03:19:04 +00:00
container := containers.NewContainer(layouts.Vertical { true, true })
window.Adopt(container)
2023-03-31 03:19:04 +00:00
container.Adopt (elements.NewLabel (
"Rapidly approaching your location...", false), false)
2023-03-31 03:19:04 +00:00
bar := elements.NewProgressBar(0)
container.Adopt(bar, false)
2023-03-31 03:19:04 +00:00
button := elements.NewButton("Stop")
button.SetEnabled(false)
container.Adopt(button, false)
window.OnClose(tomo.Stop)
window.Show()
2023-03-31 03:19:04 +00:00
go fill(window, bar)
}
2023-03-31 03:19:04 +00:00
func fill (window tomo.Window, bar *elements.ProgressBar) {
for progress := 0.0; progress < 1.0; progress += 0.01 {
time.Sleep(time.Second / 24)
2023-01-18 01:30:58 +00:00
tomo.Do (func () {
bar.SetProgress(progress)
})
}
2023-01-18 01:30:58 +00:00
tomo.Do (func () {
popups.NewDialog (
popups.DialogKindInfo,
2023-03-31 03:19:04 +00:00
window,
2023-01-18 01:30:58 +00:00
"I am here",
"Don't look outside your window.")
})
}