Row, Column have recommended size support
This commit is contained in:
parent
71a41d390f
commit
da346f2f12
@ -181,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