MCPcopy Create free account
hub / github.com/cogentcore/core / updateParentRelSizes

Method updateParentRelSizes

core/layout.go:710–744  ·  view source on GitHub ↗

updateParentRelSizes updates any parent-relative Min, Max size values based on current actual parent sizes.

()

Source from the content-addressed store, hash-verified

708// updateParentRelSizes updates any parent-relative Min, Max size values
709// based on current actual parent sizes.
710func (wb *WidgetBase) updateParentRelSizes() bool {
711 pwb := wb.parentWidget()
712 if pwb == nil {
713 return false
714 }
715 sz := &wb.Geom.Size
716 s := &wb.Styles
717 psz := pwb.Geom.Size.Alloc.Content.Sub(pwb.Geom.Size.InnerSpace)
718 got := false
719 for d := math32.X; d <= math32.Y; d++ {
720 if s.Min.Dim(d).Unit == units.UnitPw {
721 got = true
722 sz.Min.SetDim(d, psz.X*0.01*s.Min.Dim(d).Value)
723 }
724 if s.Min.Dim(d).Unit == units.UnitPh {
725 got = true
726 sz.Min.SetDim(d, psz.Y*0.01*s.Min.Dim(d).Value)
727 }
728 if s.Max.Dim(d).Unit == units.UnitPw {
729 got = true
730 sz.Max.SetDim(d, psz.X*0.01*s.Max.Dim(d).Value)
731 }
732 if s.Max.Dim(d).Unit == units.UnitPh {
733 got = true
734 sz.Max.SetDim(d, psz.Y*0.01*s.Max.Dim(d).Value)
735 }
736 }
737 if got {
738 sz.fitSizeMax(&sz.Actual.Total, sz.Min)
739 sz.fitSizeMax(&sz.Alloc.Total, sz.Min)
740 sz.setContentFromTotal(&sz.Actual)
741 sz.setContentFromTotal(&sz.Alloc)
742 }
743 return got
744}
745
746// sizeUpParts adjusts the Content size to hold the Parts layout if present
747func (wb *WidgetBase) sizeUpParts() {

Callers 3

SizeDownMethod · 0.95
styleSizeUpdateMethod · 0.95
sizeDownFrameMethod · 0.80

Calls 6

parentWidgetMethod · 0.95
fitSizeMaxMethod · 0.80
setContentFromTotalMethod · 0.80
SubMethod · 0.45
DimMethod · 0.45
SetDimMethod · 0.45

Tested by

no test coverage detected