MCPcopy Create free account
hub / github.com/audacity/audacity / VisitLayout

Method VisitLayout

src/toolbars/ToolDock.cpp:505–682  ·  view source on GitHub ↗

Skeleton routine common to insertion of a toolbar, and figuring out width-constrained layout of toolbars

Source from the content-addressed store, hash-verified

503// Skeleton routine common to insertion of a toolbar, and figuring out
504// width-constrained layout of toolbars
505void ToolDock::VisitLayout(LayoutVisitor &visitor,
506 ToolBarConfiguration *pWrappedConfiguration)
507{
508 if (pWrappedConfiguration)
509 pWrappedConfiguration->Clear();
510
511 // Get size of our parent since we haven't been sized yet
512 int width, height;
513 GetParent()->GetClientSize( &width, &height );
514 width -= toolbarGap;
515 height -= toolbarGap;
516
517 // Rectangle of space to allocate
518 wxRect main{ toolbarGap, toolbarGap,
519 // Allow limited width, but arbitrary height, for the root rectangle
520 width, std::numeric_limits<int>::max() };
521
522 // For recording the nested subdivisions of the rectangle
523 struct Item {
524 Identifier section;
525 Item *parent{};
526 ToolBar *lastSib {};
527 ToolBar *lastWrappedChild {};
528 wxRect rect;
529 };
530 std::vector<Item> items(mBars.size());
531 Item *layout = items.data();
532 Item *next = layout;
533
534 ToolBar *lastRoot {};
535 ToolBar *lastWrappedRoot {};
536
537 // Process all docked and visible toolbars
538 for ( const auto &place : this->GetConfiguration() )
539 {
540 // Cache toolbar pointer
541 const auto ct = place.pTree->pBar;
542
543 // set up the chain of ancestors.
544 const auto parent = place.position.rightOf;
545 const auto section = ct->GetSection();
546 auto &newItem = *next++;
547 if (parent)
548 newItem.parent = std::find_if(layout, next - 1, [&](Item &item){
549 return parent->GetSection() == item.section;
550 });
551 // Mark the slots that really were visited, for final pass through
552 // the spaces.
553 newItem.section = section;
554
555 ToolBar *prevSib;
556 if (!parent) {
557 prevSib = lastRoot;
558 lastRoot = ct;
559 }
560 else {
561 auto &sib = newItem.parent->lastSib;
562 prevSib = sib;

Callers 1

PositionBarMethod · 0.95

Calls 15

GetParentFunction · 0.85
maxFunction · 0.85
GetSectionMethod · 0.80
SetPositionMethod · 0.80
GetHeightMethod · 0.80
ClearMethod · 0.45
sizeMethod · 0.45
dataMethod · 0.45
GetSizeMethod · 0.45
GetParentMethod · 0.45
SetSizeMethod · 0.45
ModifySizeMethod · 0.45

Tested by

no test coverage detected