2023-03-11 16:00:29 -07:00
|
|
|
package main
|
|
|
|
|
2023-03-11 17:25:35 -07:00
|
|
|
import "os"
|
|
|
|
import "image"
|
|
|
|
import _ "image/png"
|
2023-03-11 16:00:29 -07:00
|
|
|
import "git.tebibyte.media/sashakoshka/tomo"
|
2023-03-30 21:19:04 -06:00
|
|
|
import "git.tebibyte.media/sashakoshka/tomo/elements"
|
2023-03-15 23:14:39 -06:00
|
|
|
import _ "git.tebibyte.media/sashakoshka/tomo/backends/all"
|
2023-03-16 12:22:56 -06:00
|
|
|
import "git.tebibyte.media/sashakoshka/tomo/elements/containers"
|
2023-03-11 16:00:29 -07:00
|
|
|
|
|
|
|
func main () {
|
|
|
|
tomo.Run(run)
|
|
|
|
}
|
|
|
|
|
|
|
|
func run () {
|
2023-03-11 17:25:35 -07:00
|
|
|
window, _ := tomo.NewWindow(383, 360)
|
2023-03-11 16:00:29 -07:00
|
|
|
window.SetTitle("Scroll")
|
2023-03-11 17:25:35 -07:00
|
|
|
|
|
|
|
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 }
|
2023-03-11 16:00:29 -07:00
|
|
|
|
2023-03-16 12:22:56 -06:00
|
|
|
scrollContainer := containers.NewScrollContainer(false, true)
|
|
|
|
document := containers.NewDocumentContainer()
|
2023-03-11 16:00:29 -07:00
|
|
|
|
2023-03-30 21:19:04 -06:00
|
|
|
document.Adopt (elements.NewLabel (
|
2023-03-11 16:00:29 -07:00
|
|
|
"A document container is a vertically stacked container " +
|
|
|
|
"capable of properly laying out flexible elements such as " +
|
2023-03-11 17:25:35 -07:00
|
|
|
"text-wrapped labels. You can also include normal elements " +
|
2023-04-04 14:39:12 -06:00
|
|
|
"like:", true), true)
|
2023-03-30 21:19:04 -06:00
|
|
|
document.Adopt (elements.NewButton (
|
2023-04-04 14:39:12 -06:00
|
|
|
"Buttons,"), true)
|
2023-03-30 21:19:04 -06:00
|
|
|
document.Adopt (elements.NewCheckbox (
|
2023-04-04 14:39:12 -06:00
|
|
|
"Checkboxes,", true), true)
|
|
|
|
document.Adopt(elements.NewTextBox("", "And text boxes."), true)
|
|
|
|
document.Adopt (elements.NewSpacer(true), true)
|
2023-03-30 21:19:04 -06:00
|
|
|
document.Adopt (elements.NewLabel (
|
2023-03-11 16:00:29 -07:00
|
|
|
"Document containers are meant to be placed inside of a " +
|
2023-04-04 14:39:12 -06:00
|
|
|
"ScrollContainer, like this one.", true), true)
|
2023-03-30 21:19:04 -06:00
|
|
|
document.Adopt (elements.NewLabel (
|
2023-03-11 16:00:29 -07:00
|
|
|
"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 " +
|
2023-04-04 14:39:12 -06:00
|
|
|
"control groups like in iOS, or list comment or chat histories.",
|
|
|
|
true), true)
|
|
|
|
document.Adopt(elements.NewImage(logo), true)
|
2023-03-30 21:19:04 -06:00
|
|
|
document.Adopt (elements.NewLabel (
|
2023-04-04 14:39:12 -06:00
|
|
|
"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).",
|
|
|
|
true), true)
|
|
|
|
document.Adopt(elements.NewButton("Just"), false)
|
|
|
|
document.Adopt(elements.NewButton("like"), false)
|
|
|
|
document.Adopt(elements.NewButton("this."), false)
|
|
|
|
document.Adopt (elements.NewLabel (
|
|
|
|
"Oh, you're a switch? Then name all of these switches:",
|
|
|
|
true), true)
|
|
|
|
for i := 0; i < 30; i ++ {
|
|
|
|
document.Adopt(elements.NewSwitch("", false), false)
|
2023-03-13 15:10:27 -06:00
|
|
|
}
|
2023-03-11 16:00:29 -07:00
|
|
|
|
|
|
|
scrollContainer.Adopt(document)
|
|
|
|
window.Adopt(scrollContainer)
|
|
|
|
window.OnClose(tomo.Stop)
|
|
|
|
window.Show()
|
|
|
|
}
|