Add examples

This commit is contained in:
Sasha Koshka 2024-05-07 20:22:07 -04:00
parent d90fb327db
commit da4af8d240
4 changed files with 52 additions and 6 deletions

View File

@ -8,6 +8,8 @@ import "git.tebibyte.media/tomo/objects"
import "git.tebibyte.media/tomo/tomo/theme"
import "git.tebibyte.media/tomo/objects/layouts"
const scrollIcons = false
type Application struct {
size theme.IconSize
grid tomo.ContainerBox
@ -50,9 +52,16 @@ func (this *Application) Init () error {
container := objects.NewOuterContainer (
layouts.NewGrid([]bool { true }, []bool { false, true, false }),
objects.NewLabel("A smorgasbord of icons:"),
this.grid,
iconButtons)
objects.NewLabel("A smorgasbord of icons:"))
if scrollIcons {
iconScroller := objects.NewScrollContainer(objects.ScrollVertical)
this.grid.SetOverflow(false, true)
iconScroller.SetRoot(this.grid)
container.Add(iconScroller)
} else {
container.Add(this.grid)
}
container.Add(iconButtons)
window.SetRoot(container)
window.OnClose(tomo.Stop)

37
examples/inputs/main.go Normal file
View File

@ -0,0 +1,37 @@
// Example inputs demonstrates the use of various user input methods.
package main
import "image"
import "git.tebibyte.media/tomo/tomo"
import "git.tebibyte.media/tomo/nasin"
import "git.tebibyte.media/tomo/objects"
// import "git.tebibyte.media/tomo/tomo/theme"
import "git.tebibyte.media/tomo/objects/layouts"
type Application struct { }
func (this *Application) Describe () nasin.ApplicationDescription {
return nasin.ApplicationDescription {
Name: "Tomo Input Example",
ID: "xyz.holanet.TomoInputExample",
}
}
func (this *Application) Init () error {
window, err := nasin.NewApplicationWindow(this, image.Rect(0, 0, 128, 128))
if err != nil { return err }
window.SetRoot(objects.NewOuterContainer(layouts.Column { },
objects.NewTextInput(""),
objects.NewHorizontalSlider(0.5),
objects.NewLabelCheckbox(false, "checkbox"),
))
window.OnClose(tomo.Stop)
window.Show()
return nil
}
func main () {
nasin.RunApplication(&Application { })
}

2
go.mod
View File

@ -3,7 +3,7 @@ module git.tebibyte.media/tomo/nasin
go 1.20
require (
git.tebibyte.media/tomo/objects v0.9.0
git.tebibyte.media/tomo/objects v0.10.0
git.tebibyte.media/tomo/tomo v0.31.0
git.tebibyte.media/tomo/x v0.7.1
git.tebibyte.media/tomo/xdg v0.1.0

4
go.sum
View File

@ -1,6 +1,6 @@
git.tebibyte.media/sashakoshka/xgbkb v1.0.0/go.mod h1:pNcE6TRO93vHd6q42SdwLSTTj25L0Yzggz7yLe0JV6Q=
git.tebibyte.media/tomo/objects v0.9.0 h1:ElyltNRAHRliSZX80BL7vTWzip/d0P46gaCtGZeJhB4=
git.tebibyte.media/tomo/objects v0.9.0/go.mod h1:34UDkPEHxBgIsAYWyqqE4u1KvVtwzwdpCO6AdkgsrKo=
git.tebibyte.media/tomo/objects v0.10.0 h1:wrqWCW9z4thqPqGWlTsNAMGgrcrJPsvXYCjoLlymMMk=
git.tebibyte.media/tomo/objects v0.10.0/go.mod h1:34UDkPEHxBgIsAYWyqqE4u1KvVtwzwdpCO6AdkgsrKo=
git.tebibyte.media/tomo/tomo v0.31.0 h1:LHPpj3AWycochnC8F441aaRNS6Tq6w6WnBrp/LGjyhM=
git.tebibyte.media/tomo/tomo v0.31.0/go.mod h1:C9EzepS9wjkTJjnZaPBh22YvVPyA4hbBAJVU20Rdmps=
git.tebibyte.media/tomo/typeset v0.7.1 h1:aZrsHwCG5ZB4f5CruRFsxLv5ezJUCFUFsQJJso2sXQ8=