| 354 | } |
| 355 | |
| 356 | int PartSashContainer::MeasureTree(const QRect& outerBounds, |
| 357 | LayoutTree::ConstPointer toMeasure, bool horizontal) |
| 358 | { |
| 359 | if (toMeasure == 0) |
| 360 | { |
| 361 | return Geometry::GetDimension(outerBounds, horizontal); |
| 362 | } |
| 363 | |
| 364 | LayoutTreeNode* parent = toMeasure->GetParent(); |
| 365 | if (parent == nullptr) |
| 366 | { |
| 367 | return Geometry::GetDimension(outerBounds, horizontal); |
| 368 | } |
| 369 | |
| 370 | if (parent->GetSash()->IsHorizontal() == horizontal) |
| 371 | { |
| 372 | return MeasureTree(outerBounds, LayoutTree::ConstPointer(parent), horizontal); |
| 373 | } |
| 374 | |
| 375 | bool isLeft = parent->IsLeftChild(toMeasure); |
| 376 | |
| 377 | LayoutTree::Pointer otherChild = parent->GetChild(!isLeft); |
| 378 | if (otherChild->IsVisible()) |
| 379 | { |
| 380 | int left = parent->GetSash()->GetLeft(); |
| 381 | int right = parent->GetSash()->GetRight(); |
| 382 | int childSize = isLeft ? left : right; |
| 383 | |
| 384 | int bias = parent->GetCompressionBias(); |
| 385 | |
| 386 | // Normalize bias: 1 = we're fixed, -1 = other child is fixed |
| 387 | if (isLeft) |
| 388 | { |
| 389 | bias = -bias; |
| 390 | } |
| 391 | |
| 392 | if (bias == 1) |
| 393 | { |
| 394 | // If we're fixed, return the fixed size |
| 395 | return childSize; |
| 396 | } |
| 397 | else if (bias == -1) |
| 398 | { |
| 399 | |
| 400 | // If the other child is fixed, return the size of the parent minus the fixed size of the |
| 401 | // other child |
| 402 | return MeasureTree(outerBounds, LayoutTree::ConstPointer(parent), horizontal) - (left + right |
| 403 | - childSize); |
| 404 | } |
| 405 | |
| 406 | // Else return the size of the parent, scaled appropriately |
| 407 | return MeasureTree(outerBounds, LayoutTree::ConstPointer(parent), horizontal) * childSize / (left |
| 408 | + right); |
| 409 | } |
| 410 | |
| 411 | return MeasureTree(outerBounds, LayoutTree::ConstPointer(parent), horizontal); |
| 412 | } |
| 413 |
no test coverage detected