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.
This commit is contained in:
Niels Martin Hansen 2009-06-05 02:02:55 +00:00
parent c74a02e57d
commit 4b41b4ca4a
2 changed files with 28 additions and 3 deletions

View file

@ -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;

View file

@ -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);