Example #1
0
File: list.go Project: nelsam/gxui
func (l *List) DesiredSize(min, max math.Size) math.Size {
	if l.adapter == nil {
		return min
	}
	count := math.Max(l.itemCount, 1)
	var s math.Size
	if l.orientation.Horizontal() {
		s = math.Size{W: l.itemSize.W * count, H: l.itemSize.H}
	} else {
		s = math.Size{W: l.itemSize.W, H: l.itemSize.H * count}
	}
	if l.scrollBarEnabled {
		if l.orientation.Horizontal() {
			s.H += l.scrollBar.DesiredSize(min, max).H
		} else {
			s.W += l.scrollBar.DesiredSize(min, max).W
		}
	}
	return s.Expand(l.outer.Padding()).Clamp(min, max)
}