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/layouts"
|
|
|
|
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 " +
|
|
|
|
"like:", true))
|
2023-03-30 21:19:04 -06:00
|
|
|
document.Adopt (elements.NewButton (
|
2023-03-11 17:25:35 -07:00
|
|
|
"Buttons,"))
|
2023-03-30 21:19:04 -06:00
|
|
|
document.Adopt (elements.NewCheckbox (
|
2023-03-11 17:25:35 -07:00
|
|
|
"Checkboxes,", true))
|
2023-03-30 21:19:04 -06:00
|
|
|
document.Adopt(elements.NewTextBox("", "And text boxes."))
|
|
|
|
document.Adopt (elements.NewSpacer(true))
|
|
|
|
document.Adopt (elements.NewLabel (
|
2023-03-11 16:00:29 -07:00
|
|
|
"Document containers are meant to be placed inside of a " +
|
|
|
|
"ScrollContainer, like this one.", 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 " +
|
|
|
|
"control groups like in iOS, or list comment or chat histories.", true))
|
2023-03-30 21:19:04 -06:00
|
|
|
document.Adopt(elements.NewImage(logo))
|
|
|
|
document.Adopt (elements.NewLabel (
|
2023-03-13 15:10:27 -06:00
|
|
|
"Oh, you're a switch? Then name all of these switches:", true))
|
|
|
|
for i := 0; i < 3; i ++ {
|
2023-03-30 21:19:04 -06:00
|
|
|
switchContainer := containers.NewContainer (layouts.Horizontal {
|
2023-03-13 15:10:27 -06:00
|
|
|
Gap: true,
|
|
|
|
})
|
|
|
|
for i := 0; i < 10; i ++ {
|
2023-03-30 21:19:04 -06:00
|
|
|
switchContainer.Adopt(elements.NewSwitch("", false), true)
|
2023-03-13 15:10:27 -06:00
|
|
|
}
|
|
|
|
document.Adopt(switchContainer)
|
|
|
|
}
|
2023-03-11 16:00:29 -07:00
|
|
|
|
|
|
|
scrollContainer.Adopt(document)
|
|
|
|
window.Adopt(scrollContainer)
|
|
|
|
window.OnClose(tomo.Stop)
|
|
|
|
window.Show()
|
|
|
|
}
|