Skip to content

Commit

Permalink
Remove persistence of EmbeddedLayout pane positions
Browse files Browse the repository at this point in the history
A bug in the persistence code is causing a progressive shift of the pane
positions with each successive session, moving the splitters to the right and
downwards until the 2D view and group widgets are hardly visible. With this
code disabled, the splitters are left at their default position, which (on
Linux at least) seems to be 50% of the widget size. This is not optimal but at
least is consistent between sessions.
  • Loading branch information
Matthew Mott committed Apr 25, 2018
1 parent 47e96c5 commit cc22ed6
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 63 deletions.
56 changes: 0 additions & 56 deletions radiant/ui/mainframe/EmbeddedLayout.cpp
Expand Up @@ -18,7 +18,6 @@

namespace ui
{

namespace
{
const std::string RKEY_EMBEDDED_ROOT = "user/ui/mainFrame/embedded";
Expand Down Expand Up @@ -87,13 +86,6 @@ void EmbeddedLayout::activate()
// Add the camGroup pane to the left and the GL widget to the right
_horizPane->SplitVertically(_groupCamPane, xywnd->getGLWidget());

// Connect the pane position trackers
_posHPane.connect(_horizPane);
_posGroupCamPane.connect(_groupCamPane);

// Attempt to restore this layout's state
restoreStateFromPath(RKEY_EMBEDDED_ROOT);

topLevelParent->Layout();

// Hide the camera toggle option for non-floating views
Expand All @@ -111,9 +103,6 @@ void EmbeddedLayout::deactivate()
// Remove all previously stored pane information
GlobalRegistry().deleteXPath(RKEY_EMBEDDED_ROOT + "//pane");

// Save pane info
saveStateToPath(RKEY_EMBEDDED_ROOT);

// Delete all active views
GlobalXYWndManager().destroyViews();

Expand All @@ -128,10 +117,6 @@ void EmbeddedLayout::deactivate()

GlobalGroupDialog().removePage("textures"); // do this after destroyWindow()

// Disconnect before destroying stuff
_posHPane.disconnect();
_posGroupCamPane.disconnect();

delete _horizPane;

// Those two have been deleted by the above, so NULL the references
Expand All @@ -141,60 +126,19 @@ void EmbeddedLayout::deactivate()

void EmbeddedLayout::maximiseCameraSize()
{
// Save the current state to the registry
saveStateToPath(RKEY_EMBEDDED_TEMP_ROOT);

// Maximise the camera, wxWidgets will clip the coordinates
_horizPane->SetSashPosition(2000000);
_groupCamPane->SetSashPosition(2000000);
}

void EmbeddedLayout::restorePanePositions()
{
// Restore state
restoreStateFromPath(RKEY_EMBEDDED_TEMP_ROOT);

// Remove all previously stored pane information
GlobalRegistry().deleteXPath(RKEY_EMBEDDED_TEMP_ROOT);
}

void EmbeddedLayout::restoreStateFromPath(const std::string& path)
{
// Trigger a proper resize event before setting the sash position
GlobalMainFrame().getWxTopLevelWindow()->SendSizeEvent();
wxTheApp->Yield();

// Now load the paned positions from the registry
if (GlobalRegistry().keyExists(path + "/pane[@name='texcam']"))
{
_posGroupCamPane.loadFromPath(path + "/pane[@name='texcam']");
}

if (GlobalRegistry().keyExists(path + "/pane[@name='horizontal']"))
{
_posHPane.loadFromPath(path + "/pane[@name='horizontal']");
}
}

void EmbeddedLayout::restoreStateFromRegistry()
{
restoreStateFromPath(RKEY_EMBEDDED_ROOT);
}

void EmbeddedLayout::saveStateToPath(const std::string& path)
{
GlobalRegistry().createKeyWithName(path, "pane", "horizontal");
_posHPane.saveToPath(path + "/pane[@name='horizontal']");

GlobalRegistry().createKeyWithName(path, "pane", "texcam");
_posGroupCamPane.saveToPath(path + "/pane[@name='texcam']");
}

void EmbeddedLayout::toggleFullscreenCameraView()
{
if (GlobalRegistry().keyExists(RKEY_EMBEDDED_TEMP_ROOT))
{
restorePanePositions();
}
else
{
Expand Down
7 changes: 0 additions & 7 deletions radiant/ui/mainframe/EmbeddedLayout.h
Expand Up @@ -23,9 +23,6 @@ class EmbeddedLayout :
wxSplitterWindow* _horizPane;
wxSplitterWindow* _groupCamPane;

wxutil::PanedPosition _posHPane;
wxutil::PanedPosition _posGroupCamPane;

public:
// IMainFrameLayout implementation
std::string getName() override;
Expand All @@ -40,10 +37,6 @@ class EmbeddedLayout :
private:
void maximiseCameraSize();
void restorePanePositions();

// Saves the state of this window layout to the given XMLRegistry path (without trailing slash)
void restoreStateFromPath(const std::string& path);
void saveStateToPath(const std::string& path);
};

} // namespace ui

0 comments on commit cc22ed6

Please sign in to comment.