This repository has been archived on 2023-08-08. You can view files and clone it, but cannot push or open issues or pull requests.
tomo-old/examples/documentContainer/main.go

62 lines
2.1 KiB
Go
Raw Normal View History

package main
import "os"
import "image"
import _ "image/png"
import "git.tebibyte.media/sashakoshka/tomo"
2023-03-30 21:19:04 -06:00
import "git.tebibyte.media/sashakoshka/tomo/elements"
import _ "git.tebibyte.media/sashakoshka/tomo/backends/all"
func main () {
tomo.Run(run)
}
func run () {
window, _ := tomo.NewWindow(tomo.Bounds(0, 0, 383, 360))
window.SetTitle("Document Container")
file, err := os.Open("assets/banner.png")
if err != nil { panic(err.Error()); return }
logo, _, err := image.Decode(file)
file.Close()
if err != nil { panic(err.Error()); return }
document := elements.NewDocument()
2023-04-18 14:18:30 -06:00
document.Adopt (
elements.NewLabelWrapped (
"A document container is a vertically stacked container " +
"capable of properly laying out flexible elements such as " +
"text-wrapped labels. You can also include normal elements " +
"like:"),
elements.NewButton("Buttons,"),
elements.NewCheckbox("Checkboxes,", true),
elements.NewTextBox("", "And text boxes."),
elements.NewLine(),
elements.NewLabelWrapped (
"Document containers are meant to be placed inside of a " +
"ScrollContainer, like this one."),
elements.NewLabelWrapped (
"You could use document containers to do things like display various " +
"forms of hypertext (like HTML, gemtext, markdown, etc.), " +
"lay out a settings menu with descriptive label text between " +
"control groups like in iOS, or list comment or chat histories."),
elements.NewImage(logo),
elements.NewLabelWrapped (
"You can also choose whether each element is on its own line " +
"(sort of like an HTML/CSS block element) or on a line with " +
"other adjacent elements (like an HTML/CSS inline element)."))
document.AdoptInline (
elements.NewButton("Just"),
elements.NewButton("like"),
elements.NewButton("this."))
document.Adopt (elements.NewLabelWrapped (
"Oh, you're a switch? Then name all of these switches:"))
for i := 0; i < 30; i ++ {
2023-04-18 14:18:30 -06:00
document.AdoptInline(elements.NewSwitch("", false))
2023-03-13 15:10:27 -06:00
}
2023-04-18 14:18:30 -06:00
window.Adopt(elements.NewScroll(elements.ScrollVertical, document))
window.OnClose(tomo.Stop)
window.Show()
}