Skip to content

Commit

Permalink
AUI layout now persists between sessions
Browse files Browse the repository at this point in the history
Layout is saved and restored with SavePerspective/LoadPerspective, which only
works if the panels have deterministic names (otherwise wxWidgets generates
random numbers as the panel names which do not match between sessions). These
names are generated by a simple numeric progression based on the number of
panes currently added.
  • Loading branch information
Matthew Mott committed Feb 19, 2021
1 parent 29d4cb0 commit c129e72
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion radiant/ui/mainframe/AuiLayout.cpp
Expand Up @@ -15,6 +15,7 @@
#include "camera/CameraWndManager.h"
#include "ui/texturebrowser/TextureBrowser.h"
#include "xyview/GlobalXYWnd.h"
#include "registry/registry.h"

namespace ui
{
Expand Down Expand Up @@ -43,7 +44,12 @@ AuiLayout::AuiLayout()

void AuiLayout::addPane(wxWindow* window, const wxAuiPaneInfo& info)
{
_auiMgr.AddPane(window, info);
// Give the pane a deterministic name so we can restore perspective
wxAuiPaneInfo nameInfo = info;
nameInfo.Name(std::to_string(_panes.size()));

// Add and store the pane
_auiMgr.AddPane(window, nameInfo);
_panes.push_back(window);
}

Expand Down Expand Up @@ -114,6 +120,13 @@ void AuiLayout::activate()
}
_auiMgr.Update();

// If we have a stored perspective, load it
std::string storedPersp = GlobalRegistry().get(RKEY_ROOT);
if (!storedPersp.empty())
{
_auiMgr.LoadPerspective(storedPersp);
}

// Hide the camera toggle option for non-floating views
GlobalMenuManager().setVisibility("main/view/cameraview", false);
// Hide the console/texture browser toggles for non-floating/non-split views
Expand All @@ -122,6 +135,9 @@ void AuiLayout::activate()

void AuiLayout::deactivate()
{
// Store perspective
GlobalRegistry().set(RKEY_ROOT, _auiMgr.SavePerspective().ToStdString());

// Show the camera toggle option again
GlobalMenuManager().setVisibility("main/view/cameraview", true);
GlobalMenuManager().setVisibility("main/view/textureBrowser", true);
Expand Down

0 comments on commit c129e72

Please sign in to comment.