MCPcopy Create free account
hub / github.com/codereader/DarkRadiant / toggleMainControl

Method toggleMainControl

radiant/ui/mainframe/AuiLayout.cpp:594–646  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

592}
593
594void 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
648void AuiLayout::savePaneLocation(wxAuiPaneInfo& pane)
649{

Callers

nothing calls this directly

Calls 10

isCenterPaneFunction · 0.85
rMessageFunction · 0.85
DEFAULT_PANE_INFOFunction · 0.85
findControlMethod · 0.80
starts_withFunction · 0.50
beginMethod · 0.45
endMethod · 0.45
ShowMethod · 0.45
createWidgetMethod · 0.45
getDisplayNameMethod · 0.45

Tested by

no test coverage detected