Scroll now has a constructor similar to Cell
This commit is contained in:
parent
5ca3b80e8e
commit
427b5e025d
@ -18,7 +18,7 @@ type Scroll struct {
|
||||
theme theme.Wrapped
|
||||
}
|
||||
|
||||
func NewScroll (horizontal, vertical bool) (element *Scroll) {
|
||||
func NewScroll (child tomo.Scrollable, horizontal, vertical bool) (element *Scroll) {
|
||||
element = &Scroll { }
|
||||
element.theme.Case = tomo.C("tomo", "scroll")
|
||||
element.entity = tomo.NewEntity(element).(tomo.ContainerEntity)
|
||||
@ -51,6 +51,8 @@ func NewScroll (horizontal, vertical bool) (element *Scroll) {
|
||||
})
|
||||
element.entity.Adopt(element.vertical)
|
||||
}
|
||||
|
||||
element.Adopt(child)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -13,10 +13,7 @@ func run () {
|
||||
window, _ := tomo.NewWindow(tomo.Bounds(0, 0, 256, 256))
|
||||
window.SetTitle("Text alignment")
|
||||
|
||||
container := containers.NewDocument()
|
||||
scrollContainer := elements.NewScroll(false, true)
|
||||
scrollContainer.Adopt(container)
|
||||
window.Adopt(scrollContainer)
|
||||
container := elements.NewDocument()
|
||||
|
||||
left := elements.NewLabel(text, true)
|
||||
center := elements.NewLabel(text, true)
|
||||
@ -32,6 +29,7 @@ func run () {
|
||||
container.Adopt(center, true)
|
||||
container.Adopt(right, true)
|
||||
container.Adopt(justify, true)
|
||||
window.Adopt(elements.NewScroll(container, false, true))
|
||||
|
||||
window.OnClose(tomo.Stop)
|
||||
window.Show()
|
||||
|
@ -21,7 +21,6 @@ func run () {
|
||||
file.Close()
|
||||
if err != nil { panic(err.Error()); return }
|
||||
|
||||
scrollContainer := elements.NewScroll(false, true)
|
||||
document := elements.NewDocument()
|
||||
|
||||
document.Adopt (elements.NewLabel (
|
||||
@ -60,8 +59,7 @@ func run () {
|
||||
document.Adopt(elements.NewSwitch("", false), false)
|
||||
}
|
||||
|
||||
scrollContainer.Adopt(document)
|
||||
window.Adopt(scrollContainer)
|
||||
window.Adopt(elements.NewScroll(document, false, true))
|
||||
window.OnClose(tomo.Stop)
|
||||
window.Show()
|
||||
}
|
||||
|
@ -16,9 +16,8 @@ func run () {
|
||||
window.Adopt(container)
|
||||
|
||||
textBox := elements.NewTextBox("", copypasta)
|
||||
scrollContainer := containers.NewScroll(true, false)
|
||||
|
||||
disconnectedContainer := containers.NewHBox(false, true)
|
||||
disconnectedContainer := elements.NewHBox(false, true)
|
||||
// list := elements.NewList (
|
||||
// elements.NewListEntry("This is list item 0", nil),
|
||||
// elements.NewListEntry("This is list item 1", nil),
|
||||
@ -52,9 +51,8 @@ func run () {
|
||||
// list.ScrollTo(viewport)
|
||||
// })
|
||||
|
||||
scrollContainer.Adopt(textBox)
|
||||
container.Adopt(elements.NewLabel("A ScrollContainer:", false), false)
|
||||
container.Adopt(scrollContainer, false)
|
||||
container.Adopt(elements.NewScroll(textBox, true, false), false)
|
||||
// disconnectedContainer.Adopt(list, false)
|
||||
disconnectedContainer.Adopt (elements.NewLabel (
|
||||
"Notice how the scroll bar to the right can be used to " +
|
||||
|
Reference in New Issue
Block a user