MCPcopy Create free account
hub / github.com/lxn/walk / sectionSizesForSpace

Method sectionSizesForSpace

gridlayout.go:671–849  ·  view source on GitHub ↗

sectionSizesForSpace returns section sizes. Input and outpus is measured in native pixels.

(orientation Orientation, space int, widths []int)

Source from the content-addressed store, hash-verified

669
670// sectionSizesForSpace returns section sizes. Input and outpus is measured in native pixels.
671func (li *gridLayoutItem) sectionSizesForSpace(orientation Orientation, space int, widths []int) []int {
672 var stretchFactors []int
673 if orientation == Horizontal {
674 stretchFactors = li.columnStretchFactors
675 } else {
676 stretchFactors = li.rowStretchFactors
677 }
678
679 var sectionCountWithGreedyNonSpacer int
680 var sectionCountWithGreedySpacer int
681 var stretchFactorsTotal [3]int
682 var minSizesRemaining int
683 minSizes := make([]int, len(stretchFactors))
684 maxSizes := make([]int, len(stretchFactors))
685 sizes := make([]int, len(stretchFactors))
686 sortedSections := gridLayoutSectionInfoList(make([]gridLayoutSectionInfo, len(stretchFactors)))
687
688 for i := 0; i < len(stretchFactors); i++ {
689 var otherAxisCount int
690 if orientation == Horizontal {
691 otherAxisCount = len(li.rowStretchFactors)
692 } else {
693 otherAxisCount = len(li.columnStretchFactors)
694 }
695
696 for j := 0; j < otherAxisCount; j++ {
697 var item LayoutItem
698 if orientation == Horizontal {
699 item = li.cells[j][i].item
700 } else {
701 item = li.cells[i][j].item
702 }
703
704 if item == nil {
705 continue
706 }
707
708 if !shouldLayoutItem(item) {
709 continue
710 }
711
712 info := li.item2Info[item]
713 flags := item.LayoutFlags()
714
715 max := item.Geometry().MaxSize
716
717 var pref Size
718 if hfw, ok := item.(HeightForWidther); !ok || !hfw.HasHeightForWidth() {
719 if is, ok := item.(IdealSizer); ok {
720 pref = is.IdealSize()
721 }
722 }
723
724 if orientation == Horizontal {
725 if info.spanHorz == 1 {
726 minSizes[i] = maxi(minSizes[i], li.MinSizeEffectiveForChild(item).Width)
727 }
728

Callers 2

MinSizeForSizeMethod · 0.95
PerformLayoutMethod · 0.95

Calls 12

LayoutFlagsMethod · 0.95
GeometryMethod · 0.95
spannedWidthMethod · 0.95
gridLayoutSectionInfoListTypeAlias · 0.85
shouldLayoutItemFunction · 0.85
maxiFunction · 0.85
MarginsFrom96DPIFunction · 0.85
IntFrom96DPIFunction · 0.85
HasHeightForWidthMethod · 0.65
IdealSizeMethod · 0.65
HeightForWidthMethod · 0.65

Tested by

no test coverage detected