| 79 | } |
| 80 | |
| 81 | void ConstrainedBox::CalculateConstrainedSize(wf::Size &availableSize) |
| 82 | { |
| 83 | // We check for Infinity, in the case we have no constraint from parent |
| 84 | // we'll request the child's measurements first, so we can use that as |
| 85 | // a starting point to constrain it's dimensions based on the criteria |
| 86 | // set in our properties. |
| 87 | bool hasWidth = IsPositiveRealNumber(availableSize.Width); |
| 88 | bool hasHeight = IsPositiveRealNumber(availableSize.Height); |
| 89 | |
| 90 | if (!hasWidth && !hasHeight) |
| 91 | { |
| 92 | // We have infinite space, like a ScrollViewer with both scrolling directions |
| 93 | // Ask child how big they want to be first. |
| 94 | availableSize = base_type::MeasureOverride(availableSize); |
| 95 | |
| 96 | hasWidth = IsPositiveRealNumber(availableSize.Width); |
| 97 | hasHeight = IsPositiveRealNumber(availableSize.Height); |
| 98 | |
| 99 | if (!hasWidth && !hasHeight) |
| 100 | { |
| 101 | // At this point we have no way to determine a constraint, the Panel won't do anything |
| 102 | // This should be rare? We don't really have a way to provide a warning here. |
| 103 | return; |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | // Apply Multiples |
| 108 | // --------------- |
| 109 | // These floor the Width/Height values to the nearest multiple of the property (if set). |
| 110 | // For instance you may have a responsive 4x4 repeated checkerboard pattern for transparency and |
| 111 | // want to snap to the nearest interval of 4 so the checkerboard is consistency across the layout. |
| 112 | if (hasWidth) |
| 113 | { |
| 114 | ApplyMultiple(MultipleX(), availableSize.Width); |
| 115 | } |
| 116 | |
| 117 | if (hasHeight) |
| 118 | { |
| 119 | ApplyMultiple(MultipleY(), availableSize.Height); |
| 120 | } |
| 121 | } |
| 122 | } |
nothing calls this directly
no outgoing calls
no test coverage detected