// Example license demonstrates the use of a TextView to display licensing // information. package main import "image" import _ "embed" import "git.tebibyte.media/tomo/tomo" import "git.tebibyte.media/tomo/nasin" import "git.tebibyte.media/tomo/objects" import "git.tebibyte.media/tomo/objects/layouts" //go:embed LICENSE var license []byte type Application struct { } func (this *Application) Describe () nasin.ApplicationDescription { return nasin.ApplicationDescription { Name: "Tomo License Example", ID: "xyz.holanet.TomoLicenseExample", } } func (this *Application) Init () error { window, err := nasin.NewApplicationWindow(this, image.Rect(0, 0, 600, 600)) if err != nil { return err } checkbox := objects.NewLabelCheckbox(false, "I accept these terms") checkbox.SetFocused(true) okButtok := objects.NewButton("OK") okButtok.SetIcon(tomo.IconDialogOkay) okButtok.OnClick(func () { if checkbox.Value() { window.Close() } else { dialog, _ := objects.NewDialogOk ( objects.DialogInformation, window, "", "You must read and agree to the license terms", nil) dialog.SetVisible(true) } }) scroller := objects.NewScrollContainer(objects.ScrollVertical) scroller.SetRoot(objects.NewTextView(string(license))) window.SetRoot(objects.NewOuterContainer ( layouts.NewGrid([]bool { true }, []bool { true, false }), scroller, objects.NewInnerContainer ( layouts.NewGrid([]bool { true, false }, []bool { true }), checkbox, okButtok))) window.OnClose(tomo.Stop) window.SetVisible(true) return nil } func main () { nasin.RunApplication(&Application { }) }