1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-17 08:30:06 +02:00

Bug 1465 - Labels Editor: Does not remember modified size and position after OK

This commit is contained in:
James Crook 2018-04-11 23:11:01 +01:00
parent 47bbedb20e
commit 09063d6b41
2 changed files with 28 additions and 6 deletions

View File

@ -237,14 +237,12 @@ void LabelDialog::Populate()
r = GetRect(); r = GetRect();
SetSizeHints(r.GetWidth(), r.GetHeight()); SetSizeHints(r.GetWidth(), r.GetHeight());
// Bug 1465
// There might be a saved size, in which case use that.
ReadSize();
// Center on display // Center on display
Center(); Center();
// Size and place window
// SetSize(wxSystemSettings::GetMetric(wxSYS_SCREEN_X) * 3 / 4,
// wxSystemSettings::GetMetric(wxSYS_SCREEN_Y) * 4 / 5);
// Center();
} }
void LabelDialog::PopulateOrExchange( ShuttleGui & S ) void LabelDialog::PopulateOrExchange( ShuttleGui & S )
@ -899,6 +897,25 @@ void LabelDialog::OnChangeHfreq(wxGridEvent & WXUNUSED(event), int row, RowData
return; return;
} }
void LabelDialog::ReadSize(){
wxSize sz = GetSize();
int prefWidth, prefHeight;
gPrefs->Read(wxT("/LabelEditor/Width"), &prefWidth, sz.x);
gPrefs->Read(wxT("/LabelEditor/Height"), &prefHeight, sz.y);
wxRect screenRect(wxGetClientDisplayRect());
wxSize prefSize = wxSize(prefWidth, prefHeight);
prefSize.DecTo(screenRect.GetSize());
SetSize(prefSize);
}
void LabelDialog::WriteSize(){
wxSize sz = GetSize();
gPrefs->Write(wxT("/LabelEditor/Width"), sz.x);
gPrefs->Write(wxT("/LabelEditor/Height"), sz.y);
gPrefs->Flush();
}
void LabelDialog::OnOK(wxCommandEvent & WXUNUSED(event)) void LabelDialog::OnOK(wxCommandEvent & WXUNUSED(event))
{ {
if (mGrid->IsCellEditControlShown()) { if (mGrid->IsCellEditControlShown()) {
@ -909,6 +926,7 @@ void LabelDialog::OnOK(wxCommandEvent & WXUNUSED(event))
// Standard handling // Standard handling
if (Validate() && TransferDataFromWindow()) { if (Validate() && TransferDataFromWindow()) {
WriteSize();
EndModal(wxID_OK); EndModal(wxID_OK);
} }
@ -927,6 +945,7 @@ void LabelDialog::OnCancel(wxCommandEvent & WXUNUSED(event))
return; return;
} }
WriteSize();
// Standard handling // Standard handling
EndModal(wxID_CANCEL); EndModal(wxID_CANCEL);

View File

@ -87,6 +87,9 @@ class LabelDialog final : public wxDialogWrapper
void OnOK(wxCommandEvent &event); void OnOK(wxCommandEvent &event);
void OnCancel(wxCommandEvent &event); void OnCancel(wxCommandEvent &event);
void ReadSize();
void WriteSize();
private: private:
Grid *mGrid; Grid *mGrid;