mirror of
https://github.com/cookiengineer/audacity
synced 2025-04-30 23:59:41 +02:00
Enh809 - Add persistency of spectral selections, including those in labels
This commit is contained in:
parent
5d19887da6
commit
7d6de21e3a
@ -2130,8 +2130,6 @@ bool LabelTrack::HandleXMLTag(const wxChar *tag, const wxChar **attrs)
|
||||
|
||||
// loop through attrs, which is a null-terminated list of
|
||||
// attribute-value pairs
|
||||
bool has_t1 = false;
|
||||
double dblValue;
|
||||
while(*attrs) {
|
||||
const wxChar *attr = *attrs++;
|
||||
const wxChar *value = *attrs++;
|
||||
@ -2145,14 +2143,8 @@ bool LabelTrack::HandleXMLTag(const wxChar *tag, const wxChar **attrs)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!wxStrcmp(attr, wxT("t")) && Internat::CompatibleToDouble(strValue, &dblValue))
|
||||
selectedRegion.setT0(dblValue, false);
|
||||
else if (!wxStrcmp(attr, wxT("t1")) && Internat::CompatibleToDouble(strValue, &dblValue))
|
||||
{
|
||||
has_t1 = true;
|
||||
selectedRegion.setT1(dblValue, false);
|
||||
}
|
||||
// PRL: to do: read other selection fields
|
||||
if (selectedRegion.HandleXMLAttribute(attr, value, wxT("t"), wxT("t1")))
|
||||
;
|
||||
else if (!wxStrcmp(attr, wxT("title")))
|
||||
title = strValue;
|
||||
|
||||
@ -2160,8 +2152,10 @@ bool LabelTrack::HandleXMLTag(const wxChar *tag, const wxChar **attrs)
|
||||
|
||||
// Handle files created by Audacity 1.1. Labels in Audacity 1.1
|
||||
// did not have separate start- and end-times.
|
||||
if (!has_t1)
|
||||
selectedRegion.collapseToT0();
|
||||
// PRL: this superfluous now, given class SelectedRegion's internal
|
||||
// consistency guarantees
|
||||
//if (selectedRegion.t1() < 0)
|
||||
// selectedRegion.collapseToT0();
|
||||
|
||||
LabelStruct *l = new LabelStruct(selectedRegion, title);
|
||||
mLabels.Add(l);
|
||||
@ -2230,9 +2224,8 @@ void LabelTrack::WriteXML(XMLWriter &xmlFile)
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
xmlFile.StartTag(wxT("label"));
|
||||
// PRL: mismatch of attribute name and structure field name, historical
|
||||
xmlFile.WriteAttr(wxT("t"), mLabels[i]->getT0(), 8);
|
||||
xmlFile.WriteAttr(wxT("t1"), mLabels[i]->getT1(), 8);
|
||||
mLabels[i]->getSelectedRegion()
|
||||
.WriteXMLAttributes(xmlFile, wxT("t"), wxT("t1"));
|
||||
// PRL: to do: write other selection fields
|
||||
xmlFile.WriteAttr(wxT("title"), mLabels[i]->title);
|
||||
xmlFile.EndTag(wxT("label"));
|
||||
|
@ -56,6 +56,7 @@ public:
|
||||
void DrawTextBox( wxDC & dc, const wxRect & r);
|
||||
void DrawHighlight( wxDC & dc, int xPos1, int xPos2, int charHeight);
|
||||
void getXPos( wxDC & dc, int * xPos1, int cursorPos);
|
||||
const SelectedRegion &getSelectedRegion() const { return selectedRegion; }
|
||||
double getDuration() const { return selectedRegion.duration(); }
|
||||
double getT0() const { return selectedRegion.t0(); }
|
||||
double getT1() const { return selectedRegion.t1(); }
|
||||
@ -169,11 +170,11 @@ class AUDACITY_DLL_API LabelTrack : public Track
|
||||
static bool IsTextClipSupported();
|
||||
|
||||
// methods to set flags
|
||||
void SetDragXPos(const int d) { mDragXPos = d; };
|
||||
void SetInBox(bool inTextBox) { mInBox = inTextBox; };
|
||||
void SetResetCursorPos(bool resetFlag) { mResetCursorPos = resetFlag; };
|
||||
void SetWrongDragging(bool rightFlag) { mRightDragging = rightFlag; };
|
||||
void SetDrawCursor(bool drawCursorFlag) { mDrawCursor = drawCursorFlag; };
|
||||
void SetDragXPos(const int d) { mDragXPos = d; }
|
||||
void SetInBox(bool inTextBox) { mInBox = inTextBox; }
|
||||
void SetResetCursorPos(bool resetFlag) { mResetCursorPos = resetFlag; }
|
||||
void SetWrongDragging(bool rightFlag) { mRightDragging = rightFlag; }
|
||||
void SetDrawCursor(bool drawCursorFlag) { mDrawCursor = drawCursorFlag; }
|
||||
|
||||
bool HandleMouse(const wxMouseEvent & evt, wxRect & r, double h, double pps,
|
||||
SelectedRegion *newSel);
|
||||
@ -202,7 +203,7 @@ class AUDACITY_DLL_API LabelTrack : public Track
|
||||
|
||||
//get current cursor position
|
||||
bool CalcCursorX(wxWindow * parent, int * x);
|
||||
int getCurrentCursorPosition() const { return mCurrentCursorPos; };
|
||||
int getCurrentCursorPosition() const { return mCurrentCursorPos; }
|
||||
|
||||
void MayAdjustLabel( int iLabel, int iEdge, bool bAllowSwapping, double fNewTime);
|
||||
void MayMoveLabel( int iLabel, int iEdge, double fNewTime);
|
||||
|
@ -741,6 +741,8 @@ AudacityProject::AudacityProject(wxWindow * parent, wxWindowID id,
|
||||
Read(wxT("/SamplingRate/DefaultProjectSampleFormat"), floatSample)),
|
||||
mSnapTo(gPrefs->Read(wxT("/SnapTo"), SNAP_OFF)),
|
||||
mSelectionFormat(gPrefs->Read(wxT("/SelectionFormat"), wxT(""))),
|
||||
mFrequencySelectionFormatName(gPrefs->Read(wxT("/FrequencySelectionFormatName"), wxT(""))),
|
||||
mBandwidthSelectionFormatName(gPrefs->Read(wxT("/BandwidthSelectionFormatName"), wxT(""))),
|
||||
mDirty(false),
|
||||
mRuler(NULL),
|
||||
mTrackPanel(NULL),
|
||||
@ -1254,16 +1256,16 @@ void AudacityProject::SSBL_SetFrequencySelectionFormatName(const wxString & form
|
||||
gPrefs->Flush();
|
||||
}
|
||||
|
||||
const wxString & AudacityProject::SSBL_GetLogFrequencySelectionFormatName()
|
||||
const wxString & AudacityProject::SSBL_GetBandwidthSelectionFormatName()
|
||||
{
|
||||
return GetLogFrequencySelectionFormatName();
|
||||
return GetBandwidthSelectionFormatName();
|
||||
}
|
||||
|
||||
void AudacityProject::SSBL_SetLogFrequencySelectionFormatName(const wxString & formatName)
|
||||
void AudacityProject::SSBL_SetBandwidthSelectionFormatName(const wxString & formatName)
|
||||
{
|
||||
mLogFrequencySelectionFormatName = formatName;
|
||||
mBandwidthSelectionFormatName = formatName;
|
||||
|
||||
gPrefs->Write(wxT("/LogFrequencySelectionFormatName"), mLogFrequencySelectionFormatName);
|
||||
gPrefs->Write(wxT("/BandwidthSelectionFormatName"), mBandwidthSelectionFormatName);
|
||||
gPrefs->Flush();
|
||||
}
|
||||
|
||||
@ -1300,17 +1302,17 @@ void AudacityProject::SetFrequencySelectionFormatName(const wxString & formatNam
|
||||
#endif
|
||||
}
|
||||
|
||||
const wxString & AudacityProject::GetLogFrequencySelectionFormatName() const
|
||||
const wxString & AudacityProject::GetBandwidthSelectionFormatName() const
|
||||
{
|
||||
return mLogFrequencySelectionFormatName;
|
||||
return mBandwidthSelectionFormatName;
|
||||
}
|
||||
|
||||
void AudacityProject::SetLogFrequencySelectionFormatName(const wxString & formatName)
|
||||
void AudacityProject::SetBandwidthSelectionFormatName(const wxString & formatName)
|
||||
{
|
||||
SSBL_SetLogFrequencySelectionFormatName(formatName);
|
||||
SSBL_SetBandwidthSelectionFormatName(formatName);
|
||||
#ifdef EXPERIMENTAL_SPECTRAL_EDITING
|
||||
if (GetSpectralSelectionBar()) {
|
||||
GetSpectralSelectionBar()->SetLogFrequencySelectionFormatName(formatName);
|
||||
GetSpectralSelectionBar()->SetBandwidthSelectionFormatName(formatName);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -2922,20 +2924,10 @@ bool AudacityProject::HandleXMLTag(const wxChar *tag, const wxChar **attrs)
|
||||
requiredTags++;
|
||||
}
|
||||
|
||||
else if (!wxStrcmp(attr, wxT("sel0"))) {
|
||||
double t0;
|
||||
Internat::CompatibleToDouble(value, &t0);
|
||||
mViewInfo.selectedRegion.setT0(t0, false);
|
||||
else if (mViewInfo.selectedRegion
|
||||
.HandleXMLAttribute(attr, value, wxT("sel0"), wxT("sel1"))) {
|
||||
}
|
||||
|
||||
else if (!wxStrcmp(attr, wxT("sel1"))) {
|
||||
double t1;
|
||||
Internat::CompatibleToDouble(value, &t1);
|
||||
mViewInfo.selectedRegion.setT1(t1, false);
|
||||
}
|
||||
|
||||
// PRL: to do: persistence of other fields of the selection
|
||||
|
||||
else if (!wxStrcmp(attr, wxT("vpos")))
|
||||
// Just assign a variable, put the value in its place later
|
||||
wxString(value).ToLong(&longVpos);
|
||||
@ -2955,9 +2947,14 @@ bool AudacityProject::HandleXMLTag(const wxChar *tag, const wxChar **attrs)
|
||||
SetSnapTo(wxString(value) == wxT("on") ? true : false);
|
||||
}
|
||||
|
||||
else if (!wxStrcmp(attr, wxT("selectionformat"))) {
|
||||
else if (!wxStrcmp(attr, wxT("selectionformat")))
|
||||
SetSelectionFormat(value);
|
||||
}
|
||||
|
||||
else if (!wxStrcmp(attr, wxT("frequencyformat")))
|
||||
SetFrequencySelectionFormatName(value);
|
||||
|
||||
else if (!wxStrcmp(attr, wxT("bandwidthformat")))
|
||||
SetBandwidthSelectionFormatName(value);
|
||||
} // while
|
||||
|
||||
if (longVpos != 0) {
|
||||
@ -3133,8 +3130,8 @@ void AudacityProject::WriteXML(XMLWriter &xmlFile)
|
||||
xmlFile.WriteAttr(wxT("projname"), projName);
|
||||
xmlFile.WriteAttr(wxT("version"), wxT(AUDACITY_FILE_FORMAT_VERSION));
|
||||
xmlFile.WriteAttr(wxT("audacityversion"), AUDACITY_VERSION_STRING);
|
||||
xmlFile.WriteAttr(wxT("sel0"), mViewInfo.selectedRegion.t0(), 10);
|
||||
xmlFile.WriteAttr(wxT("sel1"), mViewInfo.selectedRegion.t1(), 10);
|
||||
mViewInfo.selectedRegion
|
||||
.WriteXMLAttributes(xmlFile, wxT("sel0"), wxT("sel1"));
|
||||
// PRL: to do: persistence of other fields of the selection
|
||||
xmlFile.WriteAttr(wxT("vpos"), mViewInfo.vpos);
|
||||
xmlFile.WriteAttr(wxT("h"), mViewInfo.h, 10);
|
||||
@ -3142,6 +3139,8 @@ void AudacityProject::WriteXML(XMLWriter &xmlFile)
|
||||
xmlFile.WriteAttr(wxT("rate"), mRate);
|
||||
xmlFile.WriteAttr(wxT("snapto"), GetSnapTo() ? wxT("on") : wxT("off"));
|
||||
xmlFile.WriteAttr(wxT("selectionformat"), GetSelectionFormat());
|
||||
xmlFile.WriteAttr(wxT("frequencyformat"), GetFrequencySelectionFormatName());
|
||||
xmlFile.WriteAttr(wxT("bandwidthformat"), GetBandwidthSelectionFormatName());
|
||||
|
||||
mTags->WriteXML(xmlFile);
|
||||
|
||||
|
@ -110,10 +110,10 @@ enum PlayMode {
|
||||
class ImportXMLTagHandler : public XMLTagHandler
|
||||
{
|
||||
public:
|
||||
ImportXMLTagHandler(AudacityProject* pProject) { mProject = pProject; };
|
||||
ImportXMLTagHandler(AudacityProject* pProject) { mProject = pProject; }
|
||||
|
||||
virtual bool HandleXMLTag(const wxChar *tag, const wxChar **attrs);
|
||||
virtual XMLTagHandler *HandleXMLChild(const wxChar * WXUNUSED(tag)) { return NULL; };
|
||||
virtual XMLTagHandler *HandleXMLChild(const wxChar * WXUNUSED(tag)) { return NULL; }
|
||||
|
||||
// Don't want a WriteXML method because ImportXMLTagHandler is not a WaveTrack.
|
||||
// <import> tags are instead written by AudacityProject::WriteXML.
|
||||
@ -135,7 +135,7 @@ class AUDACITY_DLL_API AudacityProject: public wxFrame,
|
||||
const wxPoint & pos, const wxSize & size);
|
||||
virtual ~AudacityProject();
|
||||
|
||||
TrackList *GetTracks() { return mTracks; };
|
||||
TrackList *GetTracks() { return mTracks; }
|
||||
UndoManager *GetUndoManager() { return &mUndoManager; }
|
||||
|
||||
sampleFormat GetDefaultFormat() { return mDefaultFormat; }
|
||||
@ -221,7 +221,7 @@ class AUDACITY_DLL_API AudacityProject: public wxFrame,
|
||||
bool GetDirty() { return mDirty; }
|
||||
void SetProjectTitle();
|
||||
|
||||
TrackPanel * GetTrackPanel(){return mTrackPanel;};
|
||||
TrackPanel * GetTrackPanel(){return mTrackPanel;}
|
||||
|
||||
bool GetIsEmpty() { return mTracks->IsEmpty(); }
|
||||
|
||||
@ -327,8 +327,8 @@ class AUDACITY_DLL_API AudacityProject: public wxFrame,
|
||||
void SetFrequencySelectionFormatName(const wxString & format);
|
||||
const wxString & GetFrequencySelectionFormatName() const;
|
||||
|
||||
void SetLogFrequencySelectionFormatName(const wxString & format);
|
||||
const wxString & GetLogFrequencySelectionFormatName() const;
|
||||
void SetBandwidthSelectionFormatName(const wxString & format);
|
||||
const wxString & GetBandwidthSelectionFormatName() const;
|
||||
|
||||
// Scrollbars
|
||||
|
||||
@ -387,8 +387,8 @@ class AUDACITY_DLL_API AudacityProject: public wxFrame,
|
||||
Meter *GetCaptureMeter();
|
||||
void SetCaptureMeter(Meter *capture);
|
||||
|
||||
LyricsWindow* GetLyricsWindow() { return mLyricsWindow; };
|
||||
MixerBoard* GetMixerBoard() { return mMixerBoard; };
|
||||
LyricsWindow* GetLyricsWindow() { return mLyricsWindow; }
|
||||
MixerBoard* GetMixerBoard() { return mMixerBoard; }
|
||||
|
||||
// SelectionBarListener callback methods
|
||||
|
||||
@ -407,8 +407,8 @@ class AUDACITY_DLL_API AudacityProject: public wxFrame,
|
||||
virtual const wxString & SSBL_GetFrequencySelectionFormatName();
|
||||
virtual void SSBL_SetFrequencySelectionFormatName(const wxString & formatName);
|
||||
|
||||
virtual const wxString & SSBL_GetLogFrequencySelectionFormatName();
|
||||
virtual void SSBL_SetLogFrequencySelectionFormatName(const wxString & formatName);
|
||||
virtual const wxString & SSBL_GetBandwidthSelectionFormatName();
|
||||
virtual void SSBL_SetBandwidthSelectionFormatName(const wxString & formatName);
|
||||
|
||||
virtual void SSBL_ModifySpectralSelection(double &bottom, double &top, bool done);
|
||||
|
||||
@ -464,8 +464,8 @@ class AUDACITY_DLL_API AudacityProject: public wxFrame,
|
||||
static bool GetCacheBlockFiles();
|
||||
|
||||
public:
|
||||
bool IsSoloSimple() { return mSoloPref == wxT("Simple"); };
|
||||
bool IsSoloNone() { return mSoloPref == wxT("None"); };
|
||||
bool IsSoloSimple() { return mSoloPref == wxT("Simple"); }
|
||||
bool IsSoloNone() { return mSoloPref == wxT("None"); }
|
||||
|
||||
private:
|
||||
|
||||
@ -488,7 +488,7 @@ class AUDACITY_DLL_API AudacityProject: public wxFrame,
|
||||
int mSnapTo;
|
||||
wxString mSelectionFormat;
|
||||
wxString mFrequencySelectionFormatName;
|
||||
wxString mLogFrequencySelectionFormatName;
|
||||
wxString mBandwidthSelectionFormatName;
|
||||
|
||||
TrackList *mLastSavedTracks;
|
||||
|
||||
|
63
src/SelectedRegion.cpp
Normal file
63
src/SelectedRegion.cpp
Normal file
@ -0,0 +1,63 @@
|
||||
/**********************************************************************
|
||||
|
||||
Audacity: A Digital Audio Editor
|
||||
|
||||
SelectedRegion.cpp
|
||||
|
||||
Paul Licameli
|
||||
|
||||
*******************************************************************/
|
||||
|
||||
#include "Internat.h"
|
||||
#include "SelectedRegion.h"
|
||||
#include "xml/XMLWriter.h"
|
||||
|
||||
const wxChar *SelectedRegion::sDefaultT0Name = wxT("selStart");
|
||||
const wxChar *SelectedRegion::sDefaultT1Name = wxT("selEnd");
|
||||
|
||||
namespace {
|
||||
const wxChar *sDefaultF0Name = wxT("selLow");
|
||||
const wxChar *sDefaultF1Name = wxT("selHigh");
|
||||
}
|
||||
|
||||
void SelectedRegion::WriteXMLAttributes
|
||||
(XMLWriter &xmlFile,
|
||||
const wxChar *legacyT0Name, const wxChar *legacyT1Name) const
|
||||
{
|
||||
xmlFile.WriteAttr(legacyT0Name, t0(), 10);
|
||||
xmlFile.WriteAttr(legacyT1Name, t1(), 10);
|
||||
#ifdef EXPERIMENTAL_SPECTRAL_EDITING
|
||||
if (f0() >= 0)
|
||||
xmlFile.WriteAttr(sDefaultF0Name, f0(), 10);
|
||||
if (f1() >= 0)
|
||||
xmlFile.WriteAttr(sDefaultF1Name, f1(), 10);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool SelectedRegion::HandleXMLAttribute
|
||||
(const wxChar *attr, const wxChar *value,
|
||||
const wxChar *legacyT0Name, const wxChar *legacyT1Name)
|
||||
{
|
||||
typedef bool (SelectedRegion::*Setter)(double, bool);
|
||||
Setter setter = 0;
|
||||
if (!wxStrcmp(attr, legacyT0Name))
|
||||
setter = &SelectedRegion::setT0;
|
||||
else if (!wxStrcmp(attr, legacyT1Name))
|
||||
setter = &SelectedRegion::setT1;
|
||||
#ifdef EXPERIMENTAL_SPECTRAL_EDITING
|
||||
else if (!wxStrcmp(attr, sDefaultF0Name))
|
||||
setter = &SelectedRegion::setF0;
|
||||
else if (!wxStrcmp(attr, sDefaultF1Name))
|
||||
setter = &SelectedRegion::setF1;
|
||||
#endif
|
||||
else
|
||||
return false;
|
||||
|
||||
double dblValue;
|
||||
if (!Internat::CompatibleToDouble(value, &dblValue))
|
||||
return false;
|
||||
|
||||
// False means don't flip time or frequency boundaries
|
||||
(void)(this->*setter)(dblValue, false);
|
||||
return true;
|
||||
}
|
@ -28,6 +28,10 @@
|
||||
#include "Audacity.h"
|
||||
#include "Experimental.h"
|
||||
|
||||
#include <wx/defs.h>
|
||||
#include <wx/wxchar.h>
|
||||
class XMLWriter;
|
||||
|
||||
class AUDACITY_DLL_API SelectedRegion {
|
||||
|
||||
// Maintains the invariant: t1() >= t0()
|
||||
@ -156,15 +160,31 @@ public:
|
||||
|
||||
#ifdef EXPERIMENTAL_SPECTRAL_EDITING
|
||||
// Returns true iff the bounds got swapped
|
||||
bool setF0(double f) {
|
||||
bool setF0(double f, bool maySwap = true) {
|
||||
if (f < 0)
|
||||
f = UndefinedFrequency;
|
||||
mF0 = f;
|
||||
if (maySwap)
|
||||
return ensureFrequencyOrdering();
|
||||
else {
|
||||
if (mF1 >= 0 && mF1 < mF0)
|
||||
mF1 = mF0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Returns true iff the bounds got swapped
|
||||
bool setF1(double f) {
|
||||
bool setF1(double f, bool maySwap = true) {
|
||||
if (f < 0)
|
||||
f = UndefinedFrequency;
|
||||
mF1 = f;
|
||||
if (maySwap)
|
||||
return ensureFrequencyOrdering();
|
||||
else {
|
||||
if (mF0 >= 0 && mF1 < mF0)
|
||||
mF0 = mF1;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Returns true iff the bounds got swapped
|
||||
@ -176,6 +196,30 @@ public:
|
||||
}
|
||||
#endif
|
||||
|
||||
// Serialization: historically, selections were written to file
|
||||
// in two places (project, and each label) but only as attributes
|
||||
// in the tags, and different names were used in the two places.
|
||||
// For compatibility, continue that, but possibly add attributes
|
||||
// as SelectedRegion is extended. Therefore, this is not an
|
||||
// XMLTagHandler.
|
||||
|
||||
static const wxChar *sDefaultT0Name;
|
||||
static const wxChar *sDefaultT1Name;
|
||||
|
||||
// Serialize, not with tags of its own, but as attributes within a tag.
|
||||
// Don't add more legacy arguments as the structure grows.
|
||||
void WriteXMLAttributes
|
||||
(XMLWriter &xmlFile,
|
||||
const wxChar *legacyT0Name = sDefaultT0Name,
|
||||
const wxChar *legacyT1Name = sDefaultT1Name) const;
|
||||
|
||||
// Return true iff the attribute is recognized.
|
||||
// Don't add more legacy arguments as the structure grows.
|
||||
bool HandleXMLAttribute
|
||||
(const wxChar *attr, const wxChar *value,
|
||||
const wxChar *legacyT0Name = sDefaultT0Name,
|
||||
const wxChar *legacyT1Name = sDefaultT1Name);
|
||||
|
||||
private:
|
||||
bool ensureOrdering()
|
||||
{
|
||||
|
@ -76,7 +76,7 @@ BEGIN_EVENT_TABLE(SpectralSelectionBar, ToolBar)
|
||||
EVT_TEXT(OnHighID, SpectralSelectionBar::OnCtrl)
|
||||
EVT_CHOICE(OnChoiceID, SpectralSelectionBar::OnChoice)
|
||||
EVT_COMMAND(wxID_ANY, EVT_FREQUENCYTEXTCTRL_UPDATED, SpectralSelectionBar::OnUpdate)
|
||||
EVT_COMMAND(wxID_ANY, EVT_LOGFREQUENCYTEXTCTRL_UPDATED, SpectralSelectionBar::OnUpdate)
|
||||
EVT_COMMAND(wxID_ANY, EVT_BANDWIDTHTEXTCTRL_UPDATED, SpectralSelectionBar::OnUpdate)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
static const wxString preferencePath
|
||||
@ -117,8 +117,8 @@ void SpectralSelectionBar::Populate()
|
||||
wxString frequencyFormatName = mListener
|
||||
? mListener->SSBL_GetFrequencySelectionFormatName()
|
||||
: wxString(wxEmptyString);
|
||||
wxString logFrequencyFormatName = mListener
|
||||
? mListener->SSBL_GetLogFrequencySelectionFormatName()
|
||||
wxString bandwidthFormatName = mListener
|
||||
? mListener->SSBL_GetBandwidthSelectionFormatName()
|
||||
: wxString(wxEmptyString);
|
||||
|
||||
wxFlexGridSizer *mainSizer = new wxFlexGridSizer(1, 1, 1);
|
||||
@ -151,7 +151,7 @@ void SpectralSelectionBar::Populate()
|
||||
subSizer->Add(mCenterCtrl, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5);
|
||||
|
||||
mWidthCtrl = new NumericTextCtrl(
|
||||
NumericConverter::LOG_FREQUENCY, this, OnWidthID, logFrequencyFormatName, 0.0);
|
||||
NumericConverter::BANDWIDTH, this, OnWidthID, bandwidthFormatName, 0.0);
|
||||
mWidthCtrl->SetName(wxString(_("Bandwidth:")));
|
||||
mWidthCtrl->EnableMenu();
|
||||
subSizer->Add(mWidthCtrl, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 0);
|
||||
@ -192,7 +192,7 @@ void SpectralSelectionBar::UpdatePrefs()
|
||||
|
||||
if (mbCenterAndWidth)
|
||||
{
|
||||
wxCommandEvent e(EVT_LOGFREQUENCYTEXTCTRL_UPDATED);
|
||||
wxCommandEvent e(EVT_BANDWIDTHTEXTCTRL_UPDATED);
|
||||
e.SetInt(mWidthCtrl->GetFormatIndex());
|
||||
OnUpdate(e);
|
||||
}
|
||||
@ -208,7 +208,7 @@ void SpectralSelectionBar::SetListener(SpectralSelectionBarListener *l)
|
||||
{
|
||||
mListener = l;
|
||||
SetFrequencySelectionFormatName(mListener->SSBL_GetFrequencySelectionFormatName());
|
||||
SetLogFrequencySelectionFormatName(mListener->SSBL_GetLogFrequencySelectionFormatName());
|
||||
SetBandwidthSelectionFormatName(mListener->SSBL_GetBandwidthSelectionFormatName());
|
||||
};
|
||||
|
||||
void SpectralSelectionBar::OnSize(wxSizeEvent &evt)
|
||||
@ -312,9 +312,9 @@ void SpectralSelectionBar::OnUpdate(wxCommandEvent &evt)
|
||||
mListener->SSBL_SetFrequencySelectionFormatName(frequencyFormatName);
|
||||
}
|
||||
else if (mbCenterAndWidth &&
|
||||
type == EVT_LOGFREQUENCYTEXTCTRL_UPDATED) {
|
||||
wxString logFrequencyFormatName = mWidthCtrl->GetBuiltinName(index);
|
||||
mListener->SSBL_SetLogFrequencySelectionFormatName(logFrequencyFormatName);
|
||||
type == EVT_BANDWIDTHTEXTCTRL_UPDATED) {
|
||||
wxString bandwidthFormatName = mWidthCtrl->GetBuiltinName(index);
|
||||
mListener->SSBL_SetBandwidthSelectionFormatName(bandwidthFormatName);
|
||||
}
|
||||
|
||||
// ToolBar::ReCreateButtons() will get rid of our sizers and controls
|
||||
@ -377,12 +377,12 @@ void SpectralSelectionBar::SetFrequencySelectionFormatName(const wxString & form
|
||||
OnUpdate(e);
|
||||
}
|
||||
|
||||
void SpectralSelectionBar::SetLogFrequencySelectionFormatName(const wxString & formatName)
|
||||
void SpectralSelectionBar::SetBandwidthSelectionFormatName(const wxString & formatName)
|
||||
{
|
||||
if (mbCenterAndWidth) {
|
||||
mWidthCtrl->SetFormatName(formatName);
|
||||
|
||||
wxCommandEvent e(EVT_LOGFREQUENCYTEXTCTRL_UPDATED);
|
||||
wxCommandEvent e(EVT_BANDWIDTHTEXTCTRL_UPDATED);
|
||||
e.SetInt(mWidthCtrl->GetFormatIndex());
|
||||
OnUpdate(e);
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ public:
|
||||
|
||||
void SetFrequencies(double bottom, double top);
|
||||
void SetFrequencySelectionFormatName(const wxString & formatName);
|
||||
void SetLogFrequencySelectionFormatName(const wxString & formatName);
|
||||
void SetBandwidthSelectionFormatName(const wxString & formatName);
|
||||
void SetListener(SpectralSelectionBarListener *l);
|
||||
|
||||
private:
|
||||
|
@ -14,22 +14,21 @@
|
||||
#include "../Audacity.h"
|
||||
|
||||
class wxString;
|
||||
class SelectedRegion;
|
||||
|
||||
class AUDACITY_DLL_API SpectralSelectionBarListener {
|
||||
|
||||
public:
|
||||
|
||||
SpectralSelectionBarListener(){};
|
||||
virtual ~SpectralSelectionBarListener(){};
|
||||
SpectralSelectionBarListener(){}
|
||||
virtual ~SpectralSelectionBarListener(){}
|
||||
|
||||
virtual double SSBL_GetRate() const = 0;
|
||||
|
||||
virtual const wxString & SSBL_GetFrequencySelectionFormatName() = 0;
|
||||
virtual void SSBL_SetFrequencySelectionFormatName(const wxString & formatName) = 0;
|
||||
|
||||
virtual const wxString & SSBL_GetLogFrequencySelectionFormatName() = 0;
|
||||
virtual void SSBL_SetLogFrequencySelectionFormatName(const wxString & formatName) = 0;
|
||||
virtual const wxString & SSBL_GetBandwidthSelectionFormatName() = 0;
|
||||
virtual void SSBL_SetBandwidthSelectionFormatName(const wxString & formatName) = 0;
|
||||
|
||||
virtual void SSBL_ModifySpectralSelection(double &bottom, double &top, bool done) = 0;
|
||||
};
|
||||
|
@ -486,7 +486,7 @@ const BuiltinFormatString FrequencyConverterFormats[] = {
|
||||
* array of string pairs for name of the format and the format string
|
||||
* needed to create that format output. This is used for the pop-up
|
||||
* list of formats to choose from in the control. */
|
||||
const BuiltinFormatString LogFrequencyConverterFormats[] = {
|
||||
const BuiltinFormatString BandwidthConverterFormats[] = {
|
||||
{
|
||||
/* i18n-hint: Name of display format that shows log of frequency
|
||||
* in octaves */
|
||||
@ -546,10 +546,10 @@ NumericConverter::NumericConverter(Type type,
|
||||
mNBuiltins = sizeof(FrequencyConverterFormats) /
|
||||
sizeof (FrequencyConverterFormats[0]);
|
||||
break;
|
||||
case LOG_FREQUENCY:
|
||||
mBuiltinFormatStrings = LogFrequencyConverterFormats;
|
||||
mNBuiltins = sizeof(LogFrequencyConverterFormats) /
|
||||
sizeof (LogFrequencyConverterFormats[0]);
|
||||
case BANDWIDTH:
|
||||
mBuiltinFormatStrings = BandwidthConverterFormats;
|
||||
mNBuiltins = sizeof(BandwidthConverterFormats) /
|
||||
sizeof(BandwidthConverterFormats[0]);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -1099,7 +1099,7 @@ void NumericConverter::Adjust(int steps, int dir)
|
||||
|
||||
DEFINE_EVENT_TYPE(EVT_TIMETEXTCTRL_UPDATED)
|
||||
DEFINE_EVENT_TYPE(EVT_FREQUENCYTEXTCTRL_UPDATED)
|
||||
DEFINE_EVENT_TYPE(EVT_LOGFREQUENCYTEXTCTRL_UPDATED)
|
||||
DEFINE_EVENT_TYPE(EVT_BANDWIDTHTEXTCTRL_UPDATED)
|
||||
|
||||
BEGIN_EVENT_TABLE(NumericTextCtrl, wxControl)
|
||||
EVT_ERASE_BACKGROUND(NumericTextCtrl::OnErase)
|
||||
@ -1470,8 +1470,8 @@ void NumericTextCtrl::OnContext(wxContextMenuEvent &event)
|
||||
case NumericConverter::FREQUENCY:
|
||||
eventType = EVT_FREQUENCYTEXTCTRL_UPDATED;
|
||||
break;
|
||||
case NumericConverter::LOG_FREQUENCY:
|
||||
eventType = EVT_LOGFREQUENCYTEXTCTRL_UPDATED;
|
||||
case NumericConverter::BANDWIDTH:
|
||||
eventType = EVT_BANDWIDTHTEXTCTRL_UPDATED;
|
||||
break;
|
||||
default:
|
||||
wxASSERT(false);
|
||||
|
@ -32,7 +32,7 @@
|
||||
// update their formats to agree.
|
||||
DECLARE_EXPORTED_EVENT_TYPE(AUDACITY_DLL_API, EVT_TIMETEXTCTRL_UPDATED, -1);
|
||||
DECLARE_EXPORTED_EVENT_TYPE(AUDACITY_DLL_API, EVT_FREQUENCYTEXTCTRL_UPDATED, -1);
|
||||
DECLARE_EXPORTED_EVENT_TYPE(AUDACITY_DLL_API, EVT_LOGFREQUENCYTEXTCTRL_UPDATED,
|
||||
DECLARE_EXPORTED_EVENT_TYPE(AUDACITY_DLL_API, EVT_BANDWIDTHTEXTCTRL_UPDATED,
|
||||
-1);
|
||||
|
||||
/** \brief struct to hold a formatting control string and it's user facing name
|
||||
@ -53,7 +53,7 @@ public:
|
||||
enum Type {
|
||||
TIME,
|
||||
FREQUENCY,
|
||||
LOG_FREQUENCY,
|
||||
BANDWIDTH,
|
||||
};
|
||||
|
||||
NumericConverter(Type type,
|
||||
|
@ -293,6 +293,7 @@
|
||||
<ClCompile Include="..\..\..\src\RingBuffer.cpp" />
|
||||
<ClCompile Include="..\..\..\src\SampleFormat.cpp" />
|
||||
<ClCompile Include="..\..\..\src\Screenshot.cpp" />
|
||||
<ClCompile Include="..\..\..\src\SelectedRegion.cpp" />
|
||||
<ClCompile Include="..\..\..\src\Sequence.cpp" />
|
||||
<ClCompile Include="..\..\..\src\Shuttle.cpp" />
|
||||
<ClCompile Include="..\..\..\src\ShuttleGui.cpp" />
|
||||
@ -530,6 +531,7 @@
|
||||
<ClInclude Include="..\..\..\src\import\SpecPowerMeter.h" />
|
||||
<ClInclude Include="..\..\..\src\ModuleManager.h" />
|
||||
<ClInclude Include="..\..\..\src\RevisionIdent.h" />
|
||||
<ClInclude Include="..\..\..\src\SelectedRegion.h" />
|
||||
<ClInclude Include="..\..\..\src\SseMathFuncs.h" />
|
||||
<ClInclude Include="..\..\..\src\toolbars\SpectralSelectionBar.h" />
|
||||
<ClInclude Include="..\..\..\src\toolbars\SpectralSelectionBarListener.h" />
|
||||
|
@ -837,6 +837,9 @@
|
||||
<ClCompile Include="..\..\..\src\DeviceChange.cpp">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\src\SelectedRegion.cpp">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\..\src\AboutDialog.h">
|
||||
@ -1673,6 +1676,9 @@
|
||||
<ClInclude Include="..\..\..\src\RevisionIdent.h">
|
||||
<Filter>src</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\src\SelectedRegion.h">
|
||||
<Filter>src</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="..\..\audacity.ico">
|
||||
|
Loading…
x
Reference in New Issue
Block a user