| 592 | } |
| 593 | |
| 594 | void AuiLayout::toggleMainControl(const std::string& controlName) |
| 595 | { |
| 596 | // Check the center pane to see what's currently in there |
| 597 | for (auto p = _panes.begin(); p != _panes.end(); ++p) |
| 598 | { |
| 599 | auto& paneInfo = _auiMgr.GetPane(p->paneName); |
| 600 | |
| 601 | if (!isCenterPane(paneInfo) || !paneInfo.IsShown()) continue; |
| 602 | |
| 603 | // If the existing pane has already the requested control, switch back to ortho |
| 604 | auto newControlName = string::starts_with(paneInfo.name.ToStdString(), controlName) ? UserControl::OrthoView : controlName; |
| 605 | |
| 606 | if (newControlName == paneInfo.name) return; // nothing to do |
| 607 | |
| 608 | auto control = GlobalUserInterface().findControl(newControlName); |
| 609 | |
| 610 | if (!control) |
| 611 | { |
| 612 | throw std::invalid_argument("Cannot make " + newControlName + " to a main control"); |
| 613 | } |
| 614 | |
| 615 | rMessage() << "Swapping " << newControlName << " with the existing main control " << |
| 616 | paneInfo.name.ToStdString() << std::endl; |
| 617 | |
| 618 | // Find the hidden OrthoView pane |
| 619 | auto& existingOrthoView = _auiMgr.GetPane(UserControl::OrthoView); |
| 620 | |
| 621 | if (newControlName == UserControl::OrthoView) |
| 622 | { |
| 623 | existingOrthoView.Show(); |
| 624 | ensureControlIsActive(existingOrthoView.window); |
| 625 | |
| 626 | removeNonOrthoCenterPanes(); |
| 627 | } |
| 628 | else |
| 629 | { |
| 630 | // Hide the existing OrthoView pane |
| 631 | existingOrthoView.Hide(); |
| 632 | ensureControlIsInactive(existingOrthoView.window); |
| 633 | |
| 634 | // Close all other center panes, we don't need two main panels |
| 635 | removeNonOrthoCenterPanes(); |
| 636 | |
| 637 | // Add the new control as center pane |
| 638 | auto newWidget = control->createWidget(_auiMgr.GetManagedWindow()); |
| 639 | addPane(newControlName, newWidget, DEFAULT_PANE_INFO(control->getDisplayName(), MIN_SIZE).CenterPane()); |
| 640 | ensureControlIsActive(newWidget); |
| 641 | } |
| 642 | |
| 643 | _auiMgr.Update(); |
| 644 | break; |
| 645 | } |
| 646 | } |
| 647 | |
| 648 | void AuiLayout::savePaneLocation(wxAuiPaneInfo& pane) |
| 649 | { |
nothing calls this directly
no test coverage detected