MCPcopy Create free account
hub / github.com/MITK/MITK / MeasureTree

Method MeasureTree

Plugins/org.blueberry.ui.qt/src/internal/berryPartSashContainer.cpp:356–412  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

354}
355
356int 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

Callers 1

AddMethod · 0.95

Calls 10

GetDimensionFunction · 0.85
GetSashMethod · 0.80
IsLeftChildMethod · 0.80
GetLeftMethod · 0.80
GetRightMethod · 0.80
GetCompressionBiasMethod · 0.80
GetParentMethod · 0.45
IsHorizontalMethod · 0.45
GetChildMethod · 0.45
IsVisibleMethod · 0.45

Tested by

no test coverage detected