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-04 20:56:44 -07:00
package main
import "git.tebibyte.media/sashakoshka/tomo"
2023-03-30 21:19:04 -06: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-04 20:56:44 -07:00
func main () {
tomo.Run(run)
}
func run () {
window, _ := tomo.NewWindow(tomo.Bounds(0, 0, 360, 0))
2023-03-04 20:56:44 -07:00
window.SetTitle("Icons")
2023-03-30 21:19:04 -06:00
container := containers.NewContainer(layouts.Vertical { true, true })
2023-03-04 20:56:44 -07:00
window.Adopt(container)
2023-03-30 21:19:04 -06:00
container.Adopt(elements.NewLabel("Just some of the wonderful icons we have:", false), false)
container.Adopt(elements.NewSpacer(true), false)
2023-04-02 15:55:24 -06:00
container.Adopt(icons(tomo.IconHome, tomo.IconHistory), true)
container.Adopt(icons(tomo.IconFile, tomo.IconNetwork), true)
container.Adopt(icons(tomo.IconOpen, tomo.IconRemoveFavorite), true)
container.Adopt(icons(tomo.IconCursor, tomo.IconDistort), true)
2023-03-04 22:31:41 -07:00
2023-03-30 21:19:04 -06:00
closeButton := elements.NewButton("Ok")
2023-04-02 15:55:24 -06:00
closeButton.SetIcon(tomo.IconYes)
2023-03-04 22:31:41 -07:00
closeButton.ShowText(false)
closeButton.OnClick(tomo.Stop)
container.Adopt(closeButton, false)
2023-03-04 20:56:44 -07:00
window.OnClose(tomo.Stop)
window.Show()
}
2023-04-02 15:55:24 -06:00
func icons (min, max tomo.Icon) (container *containers.Container) {
2023-03-30 21:19:04 -06:00
container = containers.NewContainer(layouts.Horizontal { true, false })
2023-03-04 20:56:44 -07:00
for index := min; index <= max; index ++ {
2023-04-02 15:55:24 -06:00
container.Adopt(elements.NewIcon(index, tomo.IconSizeSmall), true)
2023-03-04 20:56:44 -07:00
}
return
}