Compare commits
2 Commits
9ce7f8b8f3
...
da346f2f12
Author | SHA1 | Date | |
---|---|---|---|
da346f2f12 | |||
71a41d390f |
@ -41,12 +41,12 @@ func (row Row) MinimumSize (hints tomo.LayoutHints, boxes []tomo.Box) image.Poin
|
|||||||
|
|
||||||
func (column Column) Arrange (hints tomo.LayoutHints, boxes []tomo.Box) {
|
func (column Column) Arrange (hints tomo.LayoutHints, boxes []tomo.Box) {
|
||||||
expands := func (index int) bool {
|
expands := func (index int) bool {
|
||||||
if index < len(boxes) { return false }
|
if index >= len(column) { return false }
|
||||||
return column[index]
|
return column[index]
|
||||||
}
|
}
|
||||||
|
|
||||||
// determine expanding box size
|
// determine expanding box size
|
||||||
expandingSize := 0
|
expandingSize := 0.0
|
||||||
if !hints.OverflowY {
|
if !hints.OverflowY {
|
||||||
gaps := len(boxes) - 1
|
gaps := len(boxes) - 1
|
||||||
freeSpace := float64(hints.Bounds.Dy() - hints.Gap.Y * gaps)
|
freeSpace := float64(hints.Bounds.Dy() - hints.Gap.Y * gaps)
|
||||||
@ -83,7 +83,7 @@ func (column Column) Arrange (hints tomo.LayoutHints, boxes []tomo.Box) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if expands(index) {
|
if expands(index) {
|
||||||
height = expandingSize
|
height = int(expandingSize)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,12 +111,12 @@ func (column Column) Arrange (hints tomo.LayoutHints, boxes []tomo.Box) {
|
|||||||
|
|
||||||
func (row Row) Arrange (hints tomo.LayoutHints, boxes []tomo.Box) {
|
func (row Row) Arrange (hints tomo.LayoutHints, boxes []tomo.Box) {
|
||||||
expands := func (index int) bool {
|
expands := func (index int) bool {
|
||||||
if index < len(boxes) { return false }
|
if index >= len(row) { return false }
|
||||||
return row[index]
|
return row[index]
|
||||||
}
|
}
|
||||||
|
|
||||||
// determine expanding box size
|
// determine expanding box size
|
||||||
expandingSize := 0
|
expandingSize := 0.0
|
||||||
if !hints.OverflowY {
|
if !hints.OverflowY {
|
||||||
gaps := len(boxes) - 1
|
gaps := len(boxes) - 1
|
||||||
freeSpace := float64(hints.Bounds.Dx() - hints.Gap.X * gaps)
|
freeSpace := float64(hints.Bounds.Dx() - hints.Gap.X * gaps)
|
||||||
@ -127,6 +127,7 @@ func (row Row) Arrange (hints tomo.LayoutHints, boxes []tomo.Box) {
|
|||||||
freeSpace -= float64(box.MinimumSize().Y)
|
freeSpace -= float64(box.MinimumSize().Y)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
expandingSize = freeSpace / float64(nExpanding)
|
||||||
}
|
}
|
||||||
|
|
||||||
// determine height
|
// determine height
|
||||||
@ -153,7 +154,7 @@ func (row Row) Arrange (hints tomo.LayoutHints, boxes []tomo.Box) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if expands(index) {
|
if expands(index) {
|
||||||
width = expandingSize
|
width = int(expandingSize)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,21 +181,57 @@ func (row Row) Arrange (hints tomo.LayoutHints, boxes []tomo.Box) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (column Column) RecommendedHeight (hints tomo.LayoutHints, boxes []tomo.Box, width int) int {
|
func (column Column) RecommendedHeight (hints tomo.LayoutHints, boxes []tomo.Box, width int) int {
|
||||||
// TODO
|
height := 0
|
||||||
return 0
|
for _, box := range boxes {
|
||||||
|
if box, ok := box.(tomo.ContentBox); ok {
|
||||||
|
height += box.RecommendedHeight(width)
|
||||||
|
} else {
|
||||||
|
height += box.MinimumSize().Y
|
||||||
|
}
|
||||||
|
}
|
||||||
|
height += hints.Gap.Y * (len(boxes) - 1)
|
||||||
|
return height
|
||||||
}
|
}
|
||||||
|
|
||||||
func (row Row) RecommendedHeight (hints tomo.LayoutHints, boxes []tomo.Box, width int) int {
|
func (row Row) RecommendedHeight (hints tomo.LayoutHints, boxes []tomo.Box, width int) int {
|
||||||
// TODO
|
height := 0
|
||||||
return 0
|
for _, box := range boxes {
|
||||||
|
minimum := box.MinimumSize()
|
||||||
|
boxHeight := 0
|
||||||
|
if box, ok := box.(tomo.ContentBox); ok {
|
||||||
|
boxHeight = box.RecommendedHeight(minimum.X)
|
||||||
|
} else {
|
||||||
|
boxHeight = minimum.Y
|
||||||
|
}
|
||||||
|
if boxHeight > height { height = boxHeight }
|
||||||
|
}
|
||||||
|
return height
|
||||||
}
|
}
|
||||||
|
|
||||||
func (column Column) RecommendedWidth (hints tomo.LayoutHints, boxes []tomo.Box, height int) int {
|
func (column Column) RecommendedWidth (hints tomo.LayoutHints, boxes []tomo.Box, height int) int {
|
||||||
// TODO
|
width := 0
|
||||||
return 0
|
for _, box := range boxes {
|
||||||
|
minimum := box.MinimumSize()
|
||||||
|
boxWidth := 0
|
||||||
|
if box, ok := box.(tomo.ContentBox); ok {
|
||||||
|
boxWidth = box.RecommendedHeight(minimum.Y)
|
||||||
|
} else {
|
||||||
|
boxWidth = minimum.X
|
||||||
|
}
|
||||||
|
if boxWidth > width { width = boxWidth }
|
||||||
|
}
|
||||||
|
return width
|
||||||
}
|
}
|
||||||
|
|
||||||
func (row Row) RecommendedWidth (hints tomo.LayoutHints, boxes []tomo.Box, height int) int {
|
func (row Row) RecommendedWidth (hints tomo.LayoutHints, boxes []tomo.Box, height int) int {
|
||||||
// TODO
|
width := 0
|
||||||
return 0
|
for _, box := range boxes {
|
||||||
|
if box, ok := box.(tomo.ContentBox); ok {
|
||||||
|
width += box.RecommendedWidth(height)
|
||||||
|
} else {
|
||||||
|
width += box.MinimumSize().X
|
||||||
|
}
|
||||||
|
}
|
||||||
|
width += hints.Gap.X * (len(boxes) - 1)
|
||||||
|
return width
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user