Added an align method to label
This commit is contained in:
41
examples/align/main.go
Normal file
41
examples/align/main.go
Normal file
@@ -0,0 +1,41 @@
|
||||
package main
|
||||
|
||||
import "git.tebibyte.media/sashakoshka/tomo"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/textdraw"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements/basic"
|
||||
import _ "git.tebibyte.media/sashakoshka/tomo/backends/all"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements/containers"
|
||||
|
||||
func main () {
|
||||
tomo.Run(run)
|
||||
}
|
||||
|
||||
func run () {
|
||||
window, _ := tomo.NewWindow(360, 360)
|
||||
window.SetTitle("Text alignment")
|
||||
|
||||
container := containers.NewDocumentContainer()
|
||||
scrollContainer := containers.NewScrollContainer(false, true)
|
||||
scrollContainer.Adopt(container)
|
||||
window.Adopt(scrollContainer)
|
||||
|
||||
left := basicElements.NewLabel(text, true)
|
||||
center := basicElements.NewLabel(text, true)
|
||||
right := basicElements.NewLabel(text, true)
|
||||
justify := basicElements.NewLabel(text, true)
|
||||
|
||||
left.SetAlign(textdraw.AlignLeft)
|
||||
center.SetAlign(textdraw.AlignCenter)
|
||||
right.SetAlign(textdraw.AlignRight)
|
||||
justify.SetAlign(textdraw.AlignJustify)
|
||||
|
||||
container.Adopt(left)
|
||||
container.Adopt(center)
|
||||
container.Adopt(right)
|
||||
container.Adopt(justify)
|
||||
|
||||
window.OnClose(tomo.Stop)
|
||||
window.Show()
|
||||
}
|
||||
|
||||
const text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Fermentum et sollicitudin ac orci phasellus egestas tellus rutrum. Aliquam vestibulum morbi blandit cursus risus at ultrices mi."
|
||||
Reference in New Issue
Block a user