updateParentRelSizes updates any parent-relative Min, Max size values based on current actual parent sizes.
()
| 708 | // updateParentRelSizes updates any parent-relative Min, Max size values |
| 709 | // based on current actual parent sizes. |
| 710 | func (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 |
| 747 | func (wb *WidgetBase) sizeUpParts() { |
no test coverage detected