From 8b9e3844a62d8ee40a54f6c7d2f0d72b23745d40 Mon Sep 17 00:00:00 2001 From: Niels Martin Hansen Date: Fri, 5 Jun 2009 02:02:55 +0000 Subject: [PATCH] Fix #607: Have style editor save its position and size during the session, similar to how several other dialogues already do. The stored position is not persistent, it is lost when Aegisub is closed. Originally committed to SVN as r3019. --- aegisub/src/dialog_style_editor.cpp | 26 +++++++++++++++++++++++--- aegisub/src/dialog_style_editor.h | 5 +++++ 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/aegisub/src/dialog_style_editor.cpp b/aegisub/src/dialog_style_editor.cpp index dc9e4c18d..5a3db7954 100644 --- a/aegisub/src/dialog_style_editor.cpp +++ b/aegisub/src/dialog_style_editor.cpp @@ -356,7 +356,7 @@ DialogStyleEditor::DialogStyleEditor (wxWindow *parent, AssStyle *_style, Subtit // Set sizer MainSizer->SetSizeHints(this); SetSizer(MainSizer); - CenterOnParent(); + LoadPosition(); } @@ -399,8 +399,8 @@ END_EVENT_TABLE() ///////////////////// // Event redirectors void DialogStyleEditor::OnApply (wxCommandEvent &event) { Apply(true,false); } -void DialogStyleEditor::OnOK (wxCommandEvent &event) { Apply(true,true); } -void DialogStyleEditor::OnCancel (wxCommandEvent &event) { Apply(false,true); } +void DialogStyleEditor::OnOK (wxCommandEvent &event) { SavePosition(); Apply(true,true); } +void DialogStyleEditor::OnCancel (wxCommandEvent &event) { SavePosition(); Apply(false,true); } void DialogStyleEditor::OnSetColor1 (wxCommandEvent &event) { OnSetColor(1); } void DialogStyleEditor::OnSetColor2 (wxCommandEvent &event) { OnSetColor(2); } void DialogStyleEditor::OnSetColor3 (wxCommandEvent &event) { OnSetColor(3); } @@ -687,3 +687,23 @@ int DialogStyleEditor::AlignToControl (int n) { default: return 7; } } + + +///////////////////////////////////////////////// +// Load and save window position for the session +void DialogStyleEditor::SavePosition() { + use_saved_position = true; + saved_position = GetRect(); +} +void DialogStyleEditor::LoadPosition() { + if (use_saved_position) + SetSize(saved_position); + else + CentreOnParent(); +} + + +///////////////////////////////////// +// Static class data saving position +wxRect DialogStyleEditor::saved_position; +bool DialogStyleEditor::use_saved_position = false; diff --git a/aegisub/src/dialog_style_editor.h b/aegisub/src/dialog_style_editor.h index 220c449ce..e9ca54947 100644 --- a/aegisub/src/dialog_style_editor.h +++ b/aegisub/src/dialog_style_editor.h @@ -100,6 +100,11 @@ private: ColourButton *previewButton; wxSizer *MainSizer; + static wxRect saved_position; + static bool use_saved_position; + void SavePosition(); + void LoadPosition(); + void SetBitmapColor (int n,wxColour color); int AlignToControl (int n); int ControlToAlign (int n);