Add examples
This commit is contained in:
parent
d90fb327db
commit
da4af8d240
|
@ -8,6 +8,8 @@ import "git.tebibyte.media/tomo/objects"
|
||||||
import "git.tebibyte.media/tomo/tomo/theme"
|
import "git.tebibyte.media/tomo/tomo/theme"
|
||||||
import "git.tebibyte.media/tomo/objects/layouts"
|
import "git.tebibyte.media/tomo/objects/layouts"
|
||||||
|
|
||||||
|
const scrollIcons = false
|
||||||
|
|
||||||
type Application struct {
|
type Application struct {
|
||||||
size theme.IconSize
|
size theme.IconSize
|
||||||
grid tomo.ContainerBox
|
grid tomo.ContainerBox
|
||||||
|
@ -50,9 +52,16 @@ func (this *Application) Init () error {
|
||||||
|
|
||||||
container := objects.NewOuterContainer (
|
container := objects.NewOuterContainer (
|
||||||
layouts.NewGrid([]bool { true }, []bool { false, true, false }),
|
layouts.NewGrid([]bool { true }, []bool { false, true, false }),
|
||||||
objects.NewLabel("A smorgasbord of icons:"),
|
objects.NewLabel("A smorgasbord of icons:"))
|
||||||
this.grid,
|
if scrollIcons {
|
||||||
iconButtons)
|
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.SetRoot(container)
|
||||||
|
|
||||||
window.OnClose(tomo.Stop)
|
window.OnClose(tomo.Stop)
|
||||||
|
|
37
examples/inputs/main.go
Normal file
37
examples/inputs/main.go
Normal 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
2
go.mod
|
@ -3,7 +3,7 @@ module git.tebibyte.media/tomo/nasin
|
||||||
go 1.20
|
go 1.20
|
||||||
|
|
||||||
require (
|
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/tomo v0.31.0
|
||||||
git.tebibyte.media/tomo/x v0.7.1
|
git.tebibyte.media/tomo/x v0.7.1
|
||||||
git.tebibyte.media/tomo/xdg v0.1.0
|
git.tebibyte.media/tomo/xdg v0.1.0
|
||||||
|
|
4
go.sum
4
go.sum
|
@ -1,6 +1,6 @@
|
||||||
git.tebibyte.media/sashakoshka/xgbkb v1.0.0/go.mod h1:pNcE6TRO93vHd6q42SdwLSTTj25L0Yzggz7yLe0JV6Q=
|
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.10.0 h1:wrqWCW9z4thqPqGWlTsNAMGgrcrJPsvXYCjoLlymMMk=
|
||||||
git.tebibyte.media/tomo/objects v0.9.0/go.mod h1:34UDkPEHxBgIsAYWyqqE4u1KvVtwzwdpCO6AdkgsrKo=
|
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 h1:LHPpj3AWycochnC8F441aaRNS6Tq6w6WnBrp/LGjyhM=
|
||||||
git.tebibyte.media/tomo/tomo v0.31.0/go.mod h1:C9EzepS9wjkTJjnZaPBh22YvVPyA4hbBAJVU20Rdmps=
|
git.tebibyte.media/tomo/tomo v0.31.0/go.mod h1:C9EzepS9wjkTJjnZaPBh22YvVPyA4hbBAJVU20Rdmps=
|
||||||
git.tebibyte.media/tomo/typeset v0.7.1 h1:aZrsHwCG5ZB4f5CruRFsxLv5ezJUCFUFsQJJso2sXQ8=
|
git.tebibyte.media/tomo/typeset v0.7.1 h1:aZrsHwCG5ZB4f5CruRFsxLv5ezJUCFUFsQJJso2sXQ8=
|
||||||
|
|
Loading…
Reference in New Issue
Block a user