Add examples
This commit is contained in:
@@ -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
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 { })
|
||||
}
|
||||
Reference in New Issue
Block a user