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

44 lines
1.4 KiB
Go
Raw Normal View History

2023-03-05 03:56:44 +00:00
package main
import "git.tebibyte.media/sashakoshka/tomo"
import "git.tebibyte.media/sashakoshka/tomo/theme"
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/backends/all"
import "git.tebibyte.media/sashakoshka/tomo/elements/containers"
2023-03-05 03:56:44 +00:00
func main () {
tomo.Run(run)
}
func run () {
window, _ := tomo.NewWindow(360, 2)
window.SetTitle("Icons")
2023-03-31 03:19:04 +00:00
container := containers.NewContainer(layouts.Vertical { true, true })
2023-03-05 03:56:44 +00:00
window.Adopt(container)
2023-03-31 03:19:04 +00:00
container.Adopt(elements.NewLabel("Just some of the wonderful icons we have:", false), false)
container.Adopt(elements.NewSpacer(true), false)
2023-03-05 03:56:44 +00:00
container.Adopt(icons(theme.IconHome, theme.IconRepositories), true)
container.Adopt(icons(theme.IconFile, theme.IconCD), true)
container.Adopt(icons(theme.IconOpen, theme.IconRemoveBookmark), true)
2023-03-05 05:31:41 +00:00
2023-03-31 03:19:04 +00:00
closeButton := elements.NewButton("Ok")
2023-03-05 05:31:41 +00:00
closeButton.SetIcon(theme.IconYes)
closeButton.ShowText(false)
closeButton.OnClick(tomo.Stop)
container.Adopt(closeButton, false)
2023-03-05 03:56:44 +00:00
window.OnClose(tomo.Stop)
window.Show()
}
func icons (min, max theme.Icon) (container *containers.Container) {
2023-03-31 03:19:04 +00:00
container = containers.NewContainer(layouts.Horizontal { true, false })
2023-03-05 03:56:44 +00:00
for index := min; index <= max; index ++ {
2023-03-31 03:19:04 +00:00
container.Adopt(elements.NewIcon(index, theme.IconSizeSmall), true)
2023-03-05 03:56:44 +00:00
}
return
}