Skip to content

Commit

Permalink
#5642: EntityClassChooser remembers its size and position now
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Jun 11, 2021
1 parent 0a2cdfc commit 24ed753
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 7 additions & 3 deletions libs/wxutil/EntityClassChooser.cpp
Expand Up @@ -27,7 +27,8 @@ namespace wxutil
namespace
{
const char* const ECLASS_CHOOSER_TITLE = N_("Create entity");
const std::string RKEY_SPLIT_POS = "user/ui/entityClassChooser/splitPos";
const char* const RKEY_SPLIT_POS = "user/ui/entityClassChooser/splitPos";
const char* const RKEY_WINDOW_STATE = "user/ui/entityClassChooser/window";

const char* const FOLDER_ICON = "folder16.png";
const char* const ENTITY_ICON = "cmenu_add_entity.png";
Expand Down Expand Up @@ -180,15 +181,15 @@ EntityClassChooser::EntityClassChooser() :
makeLabelBold(this, "EntityClassChooserDefFileNameLabel");
makeLabelBold(this, "EntityClassChooserUsageLabel");

FitToScreen(0.7f, 0.8f);

wxSplitterWindow* splitter = findNamedObject<wxSplitterWindow>(this, "EntityClassChooserSplitter");

// Disallow unsplitting
splitter->SetMinimumPaneSize(200);
splitter->SetSashPosition(static_cast<int>(GetSize().GetWidth() * 0.2f));

// Persist layout to registry
_windowPosition.initialise(this, RKEY_WINDOW_STATE, 0.7f, 0.8f);

_panedPosition.connect(splitter);
_panedPosition.loadFromPath(RKEY_SPLIT_POS);

Expand Down Expand Up @@ -247,6 +248,8 @@ void EntityClassChooser::onDeleteEvent(wxCloseEvent& ev)

int EntityClassChooser::ShowModal()
{
_windowPosition.applyPosition();

_treeViewToolbar->ClearFilter();

// Update the member variables
Expand All @@ -258,6 +261,7 @@ int EntityClassChooser::ShowModal()
int returnCode = DialogBase::ShowModal();

_panedPosition.saveToPath(RKEY_SPLIT_POS);
_windowPosition.saveToPath(RKEY_WINDOW_STATE);

return returnCode;
}
Expand Down
2 changes: 2 additions & 0 deletions libs/wxutil/EntityClassChooser.h
Expand Up @@ -9,6 +9,7 @@
#include "dataview/ResourceTreeViewToolbar.h"
#include "XmlResourceBasedWidget.h"
#include "PanedPosition.h"
#include "WindowPosition.h"

#include <memory>
#include <sigc++/connection.h>
Expand Down Expand Up @@ -38,6 +39,7 @@ class EntityClassChooser :
// Model preview widget
ModelPreviewPtr _modelPreview;

WindowPosition _windowPosition;
PanedPosition _panedPosition;

sigc::connection _defsReloaded;
Expand Down

0 comments on commit 24ed753

Please sign in to comment.