diff --git a/radiant/ui/mainframe/AuiLayout.cpp b/radiant/ui/mainframe/AuiLayout.cpp index 47e7cd0525..95a8040aae 100644 --- a/radiant/ui/mainframe/AuiLayout.cpp +++ b/radiant/ui/mainframe/AuiLayout.cpp @@ -421,6 +421,14 @@ void AuiLayout::focusControl(const std::string& controlName) // Focus matching controls in the property notebook _propertyNotebook->focusControl(controlName); + // Ensure the property panel is visible when focusing a tab + auto& propertyPane = _auiMgr.GetPane(PROPERTIES_PANEL); + if (!propertyPane.IsShown()) + { + propertyPane.Show(true); + _auiMgr.Update(); + } + // Unset the focus of any wxPanels in floating windows for (auto p = _panes.begin(); p != _panes.end(); ++p) { @@ -444,6 +452,46 @@ void AuiLayout::focusControl(const std::string& controlName) } } +void AuiLayout::toggleControlInPropertyPanel(const std::string& controlName) +{ + // If the control is a property tab, make it visible + // If the notbeook is floating, toggling a visible tab also toggles the whole notebook + auto& propertyPane = _auiMgr.GetPane(PROPERTIES_PANEL); + + if (propertyPane.IsFloating()) + { + // Toggling a visible tab in the floating panel hides the whole notebook + if (propertyPane.IsShown() && _propertyNotebook->controlIsVisible(controlName)) + { + propertyPane.Hide(); + _auiMgr.Update(); + return; + } + + // Tab is not visible yet, focus it + _propertyNotebook->focusControl(controlName); + + // Ensure the floating pane is visible + if (!propertyPane.IsShown()) + { + propertyPane.Show(true); + _auiMgr.Update(); + } + } + else // Property panel is docked + { + // Focus matching controls in the property notebook + _propertyNotebook->focusControl(controlName); + + // Ensure the non-floating property panel is visible + if (!propertyPane.IsShown()) + { + propertyPane.Show(true); + _auiMgr.Update(); + } + } +} + void AuiLayout::toggleControl(const std::string& controlName) { // Check the default settings if there's a control @@ -461,11 +509,11 @@ void AuiLayout::toggleControl(const std::string& controlName) } // Control exists, we can toggle - // If the control is a property tab, then just focus it + + // Controls in the property panel receive special treatment on toggling if (_propertyNotebook->controlExists(controlName)) { - // Focus matching controls in the property notebook - _propertyNotebook->focusControl(controlName); + toggleControlInPropertyPanel(controlName); return; } diff --git a/radiant/ui/mainframe/AuiLayout.h b/radiant/ui/mainframe/AuiLayout.h index f92a565a78..46fcfb80ef 100644 --- a/radiant/ui/mainframe/AuiLayout.h +++ b/radiant/ui/mainframe/AuiLayout.h @@ -70,6 +70,8 @@ class AuiLayout void createPane(const std::string& controlName, const std::string& paneName, const std::function& setupPane); + void toggleControlInPropertyPanel(const std::string& controlName); + void onPaneClose(wxAuiManagerEvent& ev); void handlePaneClosed(wxAuiPaneInfo& paneInfo); void removeNonOrthoCenterPanes(); diff --git a/radiant/ui/mainframe/PropertyNotebook.cpp b/radiant/ui/mainframe/PropertyNotebook.cpp index 20c6ca8734..8c67aa2716 100644 --- a/radiant/ui/mainframe/PropertyNotebook.cpp +++ b/radiant/ui/mainframe/PropertyNotebook.cpp @@ -299,6 +299,11 @@ bool PropertyNotebook::controlExists(const std::string& controlName) return findControlIndexByName(controlName) != -1; } +bool PropertyNotebook::controlIsVisible(const std::string& controlName) +{ + return getSelectedControlName() == controlName; +} + void PropertyNotebook::focusControl(const std::string& controlName) { if (auto index = findControlIndexByName(controlName); index != -1) diff --git a/radiant/ui/mainframe/PropertyNotebook.h b/radiant/ui/mainframe/PropertyNotebook.h index a600a5dea8..90cc6bba89 100644 --- a/radiant/ui/mainframe/PropertyNotebook.h +++ b/radiant/ui/mainframe/PropertyNotebook.h @@ -50,6 +50,9 @@ class PropertyNotebook : // Returns true if the given control is loaded in a tab bool controlExists(const std::string& controlName); + // Returns true if the tab of this control is shown + bool controlIsVisible(const std::string& controlName); + void saveState(); void restoreState(); void restoreDefaultState();