From 63d60b9b1e4681a79c8dae1144f8c0e192e794e0 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Wed, 2 May 2012 22:42:37 +0000 Subject: [PATCH] Save the size of the style editor in addition to the position Originally committed to SVN as r6743. --- aegisub/src/dialog_style_editor.cpp | 2 +- aegisub/src/libresrc/default_config.json | 2 ++ aegisub/src/persist_location.cpp | 19 +++++++++++++------ aegisub/src/persist_location.h | 5 ++++- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/aegisub/src/dialog_style_editor.cpp b/aegisub/src/dialog_style_editor.cpp index 024affad8..2b3a3912f 100644 --- a/aegisub/src/dialog_style_editor.cpp +++ b/aegisub/src/dialog_style_editor.cpp @@ -388,7 +388,7 @@ DialogStyleEditor::DialogStyleEditor(wxWindow *parent, AssStyle *style, agi::Con StyleName->SetInsertionPoint(0); StyleName->SetInsertionPoint(-1); - persist.reset(new PersistLocation(this, "Tool/Style Editor")); + persist.reset(new PersistLocation(this, "Tool/Style Editor", true)); Bind(wxEVT_CHILD_FOCUS, &DialogStyleEditor::OnChildFocus, this); diff --git a/aegisub/src/libresrc/default_config.json b/aegisub/src/libresrc/default_config.json index 57822d5f9..e9edd849b 100644 --- a/aegisub/src/libresrc/default_config.json +++ b/aegisub/src/libresrc/default_config.json @@ -482,6 +482,8 @@ }, "Style Editor" : { "Last" : { + "Height" : -1, + "Width" : -1, "X" : -1, "Y" : -1 }, diff --git a/aegisub/src/persist_location.cpp b/aegisub/src/persist_location.cpp index 13408712a..b8a7e8e89 100644 --- a/aegisub/src/persist_location.cpp +++ b/aegisub/src/persist_location.cpp @@ -31,9 +31,11 @@ #include #endif -PersistLocation::PersistLocation(wxDialog *dialog, std::string options_prefix) +PersistLocation::PersistLocation(wxDialog *dialog, std::string options_prefix, bool size_too) : x_opt(OPT_SET(options_prefix + "/Last/X")) , y_opt(OPT_SET(options_prefix + "/Last/Y")) +, w_opt(size_too ? OPT_SET(options_prefix + "/Last/Width") : 0) +, h_opt(size_too ? OPT_SET(options_prefix + "/Last/Height") : 0) , maximize_opt(OPT_SET(options_prefix + "/Maximized")) , dialog(dialog) { @@ -45,6 +47,9 @@ PersistLocation::PersistLocation(wxDialog *dialog, std::string options_prefix) // First move to the saved place so that it ends up on the right monitor dialog->Move(x, y); + if (size_too && w_opt->GetInt() > 0 && h_opt->GetInt() > 0) + dialog->SetSize(w_opt->GetInt(), h_opt->GetInt()); + int display_index = wxDisplay::GetFromWindow(dialog); // If it's moved offscreen center on the parent and try again @@ -75,11 +80,9 @@ PersistLocation::PersistLocation(wxDialog *dialog, std::string options_prefix) dialog->Bind(wxEVT_MOVE, &PersistLocation::OnMove, this); - if (dialog->GetWindowStyle() & wxMAXIMIZE_BOX) { - dialog->Bind(wxEVT_SIZE, &PersistLocation::OnSize, this); - if (maximize_opt->GetBool()) - dialog->Maximize(); - } + dialog->Bind(wxEVT_SIZE, &PersistLocation::OnSize, this); + if ((dialog->GetWindowStyle() & wxMAXIMIZE_BOX) && maximize_opt->GetBool()) + dialog->Maximize(); } void PersistLocation::OnMove(wxMoveEvent &e) { @@ -91,5 +94,9 @@ void PersistLocation::OnMove(wxMoveEvent &e) { void PersistLocation::OnSize(wxSizeEvent &e) { maximize_opt->SetBool(dialog->IsMaximized()); + if (w_opt) { + w_opt->SetInt(dialog->GetSize().GetWidth()); + h_opt->SetInt(dialog->GetSize().GetHeight()); + } e.Skip(); } diff --git a/aegisub/src/persist_location.h b/aegisub/src/persist_location.h index eef5f101b..e9f84d5a2 100644 --- a/aegisub/src/persist_location.h +++ b/aegisub/src/persist_location.h @@ -39,6 +39,8 @@ class wxSizeEvent; class PersistLocation { agi::OptionValue *x_opt; agi::OptionValue *y_opt; + agi::OptionValue *w_opt; + agi::OptionValue *h_opt; agi::OptionValue *maximize_opt; wxDialog *dialog; @@ -49,5 +51,6 @@ public: /// Persist the location of a dialog /// @param dialog The dialog to save and restore the position of /// @param options_prefix Prefix for the options names to store the location - PersistLocation(wxDialog *dialog, std::string options_prefix); + /// @param size_too Save and restore the size in addition to position + PersistLocation(wxDialog *dialog, std::string options_prefix, bool size_too = false); };