From da4af8d240eacc232c956d0f1bd727e983aec08e Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Tue, 7 May 2024 20:22:07 -0400 Subject: [PATCH] Add examples --- examples/icons/main.go | 15 ++++++++++++--- examples/inputs/main.go | 37 +++++++++++++++++++++++++++++++++++++ go.mod | 2 +- go.sum | 4 ++-- 4 files changed, 52 insertions(+), 6 deletions(-) create mode 100644 examples/inputs/main.go diff --git a/examples/icons/main.go b/examples/icons/main.go index b6113bf..4c8da84 100644 --- a/examples/icons/main.go +++ b/examples/icons/main.go @@ -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) diff --git a/examples/inputs/main.go b/examples/inputs/main.go new file mode 100644 index 0000000..423f1b7 --- /dev/null +++ b/examples/inputs/main.go @@ -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 { }) +} diff --git a/go.mod b/go.mod index 40f8d15..9b67802 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index 6da86bc..6c25e2e 100644 --- a/go.sum +++ b/go.sum @@ -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=