DocumentContainer has a proper minimum width
This commit is contained in:
parent
15fa3b2497
commit
b7a7800370
@ -222,9 +222,6 @@ func (element *DocumentContainer) SetTheme (new theme.Theme) {
|
|||||||
if new == element.theme.Theme { return }
|
if new == element.theme.Theme { return }
|
||||||
element.theme.Theme = new
|
element.theme.Theme = new
|
||||||
element.Propagator.SetTheme(new)
|
element.Propagator.SetTheme(new)
|
||||||
element.core.SetMinimumSize (
|
|
||||||
element.theme.Padding(theme.PatternBackground).Horizontal(),
|
|
||||||
element.theme.Padding(theme.PatternBackground).Vertical(),)
|
|
||||||
element.redoAll()
|
element.redoAll()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -331,6 +328,7 @@ func (element *DocumentContainer) doLayout () {
|
|||||||
bounds := padding.Apply(element.Bounds())
|
bounds := padding.Apply(element.Bounds())
|
||||||
element.contentBounds = image.Rectangle { }
|
element.contentBounds = image.Rectangle { }
|
||||||
|
|
||||||
|
minimumWidth := 0
|
||||||
dot := bounds.Min.Sub(element.scroll)
|
dot := bounds.Min.Sub(element.scroll)
|
||||||
for index, entry := range element.children {
|
for index, entry := range element.children {
|
||||||
if index > 0 {
|
if index > 0 {
|
||||||
@ -338,6 +336,9 @@ func (element *DocumentContainer) doLayout () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
width, height := entry.MinimumSize()
|
width, height := entry.MinimumSize()
|
||||||
|
if width > minimumWidth {
|
||||||
|
minimumWidth = width
|
||||||
|
}
|
||||||
if width < bounds.Dx() {
|
if width < bounds.Dx() {
|
||||||
width = bounds.Dx()
|
width = bounds.Dx()
|
||||||
}
|
}
|
||||||
@ -351,6 +352,10 @@ func (element *DocumentContainer) doLayout () {
|
|||||||
element.contentBounds = element.contentBounds.Union(entry.Bounds)
|
element.contentBounds = element.contentBounds.Union(entry.Bounds)
|
||||||
dot.Y += height
|
dot.Y += height
|
||||||
}
|
}
|
||||||
|
|
||||||
element.contentBounds =
|
element.contentBounds =
|
||||||
element.contentBounds.Sub(element.contentBounds.Min)
|
element.contentBounds.Sub(element.contentBounds.Min)
|
||||||
|
element.core.SetMinimumSize (
|
||||||
|
minimumWidth + padding.Horizontal(),
|
||||||
|
padding.Vertical())
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
|
import "os"
|
||||||
|
import "image"
|
||||||
|
import _ "image/png"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo"
|
import "git.tebibyte.media/sashakoshka/tomo"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/elements/basic"
|
import "git.tebibyte.media/sashakoshka/tomo/elements/basic"
|
||||||
import _ "git.tebibyte.media/sashakoshka/tomo/backends/x"
|
import _ "git.tebibyte.media/sashakoshka/tomo/backends/x"
|
||||||
@ -9,30 +12,27 @@ func main () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func run () {
|
func run () {
|
||||||
window, _ := tomo.NewWindow(480, 360)
|
window, _ := tomo.NewWindow(383, 360)
|
||||||
window.SetTitle("Scroll")
|
window.SetTitle("Scroll")
|
||||||
|
|
||||||
|
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 }
|
||||||
|
|
||||||
scrollContainer := basicElements.NewScrollContainer(false, true)
|
scrollContainer := basicElements.NewScrollContainer(false, true)
|
||||||
document := basicElements.NewDocumentContainer()
|
document := basicElements.NewDocumentContainer()
|
||||||
|
|
||||||
document.Adopt (basicElements.NewLabel (
|
document.Adopt (basicElements.NewLabel (
|
||||||
"A document container is a vertically stacked container " +
|
"A document container is a vertically stacked container " +
|
||||||
"capable of properly laying out flexible elements such as " +
|
"capable of properly laying out flexible elements such as " +
|
||||||
"text-wrapped labels.", true))
|
"text-wrapped labels. You can also include normal elements " +
|
||||||
|
"like:", true))
|
||||||
document.Adopt (basicElements.NewButton (
|
document.Adopt (basicElements.NewButton (
|
||||||
"You can also include normal elements like buttons,"))
|
"Buttons,"))
|
||||||
document.Adopt (basicElements.NewButton (
|
|
||||||
"You can also include normal elements like buttons,"))
|
|
||||||
document.Adopt (basicElements.NewButton (
|
|
||||||
"You can also include normal elements like buttons,"))
|
|
||||||
document.Adopt (basicElements.NewButton (
|
|
||||||
"You can also include normal elements like buttons,"))
|
|
||||||
document.Adopt (basicElements.NewButton (
|
|
||||||
"You can also include normal elements like buttons,"))
|
|
||||||
document.Adopt (basicElements.NewButton (
|
|
||||||
"You can also include normal elements like buttons,"))
|
|
||||||
document.Adopt (basicElements.NewCheckbox (
|
document.Adopt (basicElements.NewCheckbox (
|
||||||
"checkboxes,", true))
|
"Checkboxes,", true))
|
||||||
document.Adopt(basicElements.NewTextBox("", "And text boxes."))
|
document.Adopt(basicElements.NewTextBox("", "And text boxes."))
|
||||||
document.Adopt (basicElements.NewSpacer(true))
|
document.Adopt (basicElements.NewSpacer(true))
|
||||||
document.Adopt (basicElements.NewLabel (
|
document.Adopt (basicElements.NewLabel (
|
||||||
@ -43,6 +43,7 @@ func run () {
|
|||||||
"forms of hypertext (like HTML, gemtext, markdown, etc.), " +
|
"forms of hypertext (like HTML, gemtext, markdown, etc.), " +
|
||||||
"lay out a settings menu with descriptive label text between " +
|
"lay out a settings menu with descriptive label text between " +
|
||||||
"control groups like in iOS, or list comment or chat histories.", true))
|
"control groups like in iOS, or list comment or chat histories.", true))
|
||||||
|
document.Adopt(basicElements.NewImage(logo))
|
||||||
|
|
||||||
scrollContainer.Adopt(document)
|
scrollContainer.Adopt(document)
|
||||||
window.Adopt(scrollContainer)
|
window.Adopt(scrollContainer)
|
||||||
|
Reference in New Issue
Block a user