1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-05-01 16:19:43 +02:00

Bug 275 - Snap-To status/quantisation are global, leading to incorrect indications in multiple projects

This adds (I believe) project specific selection format.
This commit is contained in:
lllucius 2013-10-27 01:58:35 +00:00
parent ded45eb85e
commit 3d95126e0e
7 changed files with 42 additions and 14 deletions

View File

@ -2257,7 +2257,7 @@ void AudacityProject::OnSetLeftSelection()
}
else
{
wxString fmt = gPrefs->Read(wxT("/SelectionFormat"), wxT(""));
wxString fmt = GetSelectionFormat();
TimeDialog dlg(this, _("Set Left Selection Boundary"),
fmt, mRate, mViewInfo.sel0, _("Position"));
@ -2299,7 +2299,7 @@ void AudacityProject::OnSetRightSelection()
}
else
{
wxString fmt = gPrefs->Read(wxT("/SelectionFormat"), wxT(""));
wxString fmt = GetSelectionFormat();
TimeDialog dlg(this, _("Set Right Selection Boundary"),
fmt, mRate, mViewInfo.sel1, _("Position"));
@ -5608,8 +5608,7 @@ void AudacityProject::OnAddLabelPlaying()
void AudacityProject::OnEditLabels()
{
wxString format;
gPrefs->Read(wxT("/SelectionFormat"), &format);
wxString format = GetSelectionFormat();
LabelDialog dlg(this, mDirManager, mTracks, mViewInfo, mRate, format);

View File

@ -730,6 +730,7 @@ AudacityProject::AudacityProject(wxWindow * parent, wxWindowID id,
mDefaultFormat((sampleFormat) gPrefs->
Read(wxT("/SamplingRate/DefaultProjectSampleFormat"), floatSample)),
mSnapTo((bool) gPrefs->Read(wxT("/SnapTo"), (long) false)),
mSelectionFormat(gPrefs->Read(wxT("/SelectionFormat"), wxT(""))),
mDirty(false),
mTrackPanel(NULL),
mTrackFactory(NULL),
@ -1199,6 +1200,19 @@ void AudacityProject::AS_SetSnapTo(bool state)
RedrawProject();
}
const wxString & AudacityProject::AS_GetSelectionFormat()
{
return GetSelectionFormat();
}
void AudacityProject::AS_SetSelectionFormat(const wxString & format)
{
mSelectionFormat = format;
gPrefs->Write(wxT("/SelectionFormat"), mSelectionFormat);
gPrefs->Flush();
}
void AudacityProject::AS_ModifySelection(double &start, double &end, bool done)
{
mViewInfo.sel0 = start;

View File

@ -306,6 +306,11 @@ class AUDACITY_DLL_API AudacityProject: public wxFrame,
void SetSnapTo(bool state);
bool GetSnapTo();
// Selection Format
void SetSelectionFormat(const wxString & format);
const wxString & GetSelectionFormat();
// Scrollbars
void OnScrollLeft();
@ -364,6 +369,8 @@ class AUDACITY_DLL_API AudacityProject: public wxFrame,
virtual void AS_SetRate(double rate);
virtual bool AS_GetSnapTo();
virtual void AS_SetSnapTo(bool state);
virtual const wxString & AS_GetSelectionFormat();
virtual void AS_SetSelectionFormat(const wxString & format);
virtual void AS_ModifySelection(double &start, double &end, bool done);
void SetStateTo(unsigned int n);
@ -439,6 +446,7 @@ class AUDACITY_DLL_API AudacityProject: public wxFrame,
TrackList *mTracks;
bool mSnapTo;
wxString mSelectionFormat;
TrackList *mLastSavedTracks;

View File

@ -44,9 +44,7 @@ SnapManager::SnapManager(TrackList *tracks, TrackClipArray *exclusions,
if (p) {
mConverter.SetSampleRate(p->GetRate());
mSnapToTime = true;
wxString formatName;
gPrefs->Read(wxT("/SelectionFormat"), &formatName);
mConverter.SetFormatString(mConverter.GetBuiltinFormat(formatName));
mConverter.SetFormatName(GetActiveProject()->GetSelectionFormat());
}
}

View File

@ -6731,9 +6731,7 @@ void TrackPanel::OnCursorRight( bool shift, bool ctrl, bool keyup )
double TrackPanel::GridMove(double t, int minPix)
{
TimeTextCtrl ttc(this, wxID_ANY, wxT(""), 0.0, GetProject()->GetRate());
wxString formatName;
gPrefs->Read(wxT("/SelectionFormat"), &formatName);
ttc.SetFormatString(ttc.GetBuiltinFormat(formatName));
ttc.SetFormatName(GetProject()->GetSelectionFormat());
ttc.SetTimeValue(t);
// Try incrementing/decrementing the value; if we've moved far enough we're

View File

@ -114,8 +114,7 @@ void SelectionBar::Populate()
* to do some look-ups, so we'll have to create one. We can't make the
* look-ups static because they depend on translations which are done at
* runtime */
wxString formatName;
gPrefs->Read(wxT("/SelectionFormat"), &formatName);
wxString formatName = mListener ? mListener->AS_GetSelectionFormat() : wxEmptyString;
mainSizer = new wxFlexGridSizer(7, 1, 1);
Add(mainSizer, 0, wxALIGN_CENTER_VERTICAL);
@ -301,6 +300,7 @@ void SelectionBar::SetListener(SelectionBarListener *l)
mListener = l;
SetRate(mListener->AS_GetRate());
SetSnapTo(mListener->AS_GetSnapTo());
SetSelectionFormat(mListener->AS_GetSelectionFormat());
};
void SelectionBar::OnSize(wxSizeEvent &evt)
@ -368,8 +368,7 @@ void SelectionBar::OnUpdate(wxCommandEvent &evt)
// Save format name before recreating the controls so they resize properly
format = mLeftTime->GetBuiltinName(index);
gPrefs->Write(wxT("/SelectionFormat"), format);
gPrefs->Flush();
mListener->AS_SetSelectionFormat(format);
#if wxUSE_TOOLTIPS
mSnapTo->SetToolTip(wxString::Format(_("Snap Clicks/Selections to %s"), format.c_str()));
@ -472,6 +471,15 @@ void SelectionBar::SetSnapTo(bool state)
mSnapTo->SetValue(state);
}
void SelectionBar::SetSelectionFormat(const wxString & format)
{
mLeftTime->SetFormatString(mLeftTime->GetBuiltinFormat(format));
wxCommandEvent e;
e.SetInt(mLeftTime->GetFormatIndex());
OnUpdate(e);
}
void SelectionBar::SetRate(double rate)
{
if (rate != mRate) {

View File

@ -36,6 +36,8 @@ class AUDACITY_DLL_API SelectionBarListener {
virtual void AS_SetRate(double rate) = 0;
virtual bool AS_GetSnapTo() = 0;
virtual void AS_SetSnapTo(bool state) = 0;
virtual const wxString & AS_GetSelectionFormat() = 0;
virtual void AS_SetSelectionFormat(const wxString & format) = 0;
virtual void AS_ModifySelection(double &start, double &end, bool done) = 0;
};
@ -58,6 +60,7 @@ class SelectionBar:public ToolBar {
double GetRightTime();
void SetField(const wxChar *msg, int fieldNum);
void SetSnapTo(bool state);
void SetSelectionFormat(const wxString & format);
void SetRate(double rate);
void SetListener(SelectionBarListener *l);