mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-02 17:09:26 +02:00
Bugs 1043, 1044 -- Even better fix...
... With a careful sweep of uses of WaveTrack::GetDisplay() to remove assumptions about the ordering of the values. Using < and <= on enum values is mostly a bad idea.
This commit is contained in:
parent
b25994a82d
commit
508abda309
@ -1732,7 +1732,7 @@ void TrackPanel::SetCursorAndTipWhenInLabel( Track * t,
|
|||||||
{
|
{
|
||||||
if (event.m_x >= GetVRulerOffset() &&
|
if (event.m_x >= GetVRulerOffset() &&
|
||||||
(t->GetKind() == Track::Wave) &&
|
(t->GetKind() == Track::Wave) &&
|
||||||
( ((WaveTrack *) t)->GetDisplay() <= WaveTrack::SpectralSelectionLogDisplay) )
|
( ((WaveTrack *) t)->GetDisplay() != WaveTrack::PitchDisplay) )
|
||||||
{
|
{
|
||||||
*ppTip = _("Click to vertically zoom in. Shift-click to zoom out. Drag to specify a zoom region.");
|
*ppTip = _("Click to vertically zoom in. Shift-click to zoom out. Drag to specify a zoom region.");
|
||||||
SetCursor(event.ShiftDown()? *mZoomOutCursor : *mZoomInCursor);
|
SetCursor(event.ShiftDown()? *mZoomOutCursor : *mZoomInCursor);
|
||||||
@ -3854,8 +3854,8 @@ void TrackPanel::ForwardEventToWaveTrackEnvelope(wxMouseEvent & event)
|
|||||||
|
|
||||||
// AS: If we're using the right type of display for envelope operations
|
// AS: If we're using the right type of display for envelope operations
|
||||||
// ie one of the Wave displays
|
// ie one of the Wave displays
|
||||||
if (display <= 1) {
|
const bool dB = (display == WaveTrack::WaveformDBDisplay);
|
||||||
bool dB = (display == 1);
|
if (dB || (display == WaveTrack::WaveformDisplay)) {
|
||||||
bool needUpdate;
|
bool needUpdate;
|
||||||
|
|
||||||
// AS: Then forward our mouse event to the envelope.
|
// AS: Then forward our mouse event to the envelope.
|
||||||
@ -4629,7 +4629,7 @@ void TrackPanel::HandleVZoomClick( wxMouseEvent & event )
|
|||||||
|
|
||||||
// don't do anything if track is not wave or Spectrum/log Spectrum
|
// don't do anything if track is not wave or Spectrum/log Spectrum
|
||||||
if (((mCapturedTrack->GetKind() == Track::Wave) &&
|
if (((mCapturedTrack->GetKind() == Track::Wave) &&
|
||||||
(((WaveTrack*)mCapturedTrack)->GetDisplay() <= WaveTrack::SpectralSelectionLogDisplay))
|
(((WaveTrack*)mCapturedTrack)->GetDisplay() != WaveTrack::PitchDisplay))
|
||||||
#ifdef USE_MIDI
|
#ifdef USE_MIDI
|
||||||
|| mCapturedTrack->GetKind() == Track::Note
|
|| mCapturedTrack->GetKind() == Track::Note
|
||||||
#endif
|
#endif
|
||||||
@ -7016,11 +7016,13 @@ bool TrackPanel::HitTestEnvelope(Track *track, wxRect &r, wxMouseEvent & event)
|
|||||||
int displayType = wavetrack->GetDisplay();
|
int displayType = wavetrack->GetDisplay();
|
||||||
// Not an envelope hit, unless we're using a type of wavetrack display
|
// Not an envelope hit, unless we're using a type of wavetrack display
|
||||||
// suitable for envelopes operations, ie one of the Wave displays.
|
// suitable for envelopes operations, ie one of the Wave displays.
|
||||||
if ( displayType > 1)
|
const bool dB = (displayType == WaveTrack::WaveformDBDisplay);
|
||||||
|
if (!
|
||||||
|
(dB || (displayType == WaveTrack::WaveformDisplay))
|
||||||
|
)
|
||||||
return false; // No envelope, not a hit, so return.
|
return false; // No envelope, not a hit, so return.
|
||||||
|
|
||||||
// Get envelope point, range 0.0 to 1.0
|
// Get envelope point, range 0.0 to 1.0
|
||||||
bool dB = (displayType == 1);
|
|
||||||
double envValue = envelope->GetValueAtX(
|
double envValue = envelope->GetValueAtX(
|
||||||
event.m_x, r, mViewInfo->h, mViewInfo->zoom );
|
event.m_x, r, mViewInfo->h, mViewInfo->zoom );
|
||||||
|
|
||||||
@ -8979,12 +8981,29 @@ void TrackPanel::OnMergeStereo(wxCommandEvent & WXUNUSED(event))
|
|||||||
/// wxT("spectrum"), wxT("pitch") };
|
/// wxT("spectrum"), wxT("pitch") };
|
||||||
void TrackPanel::OnSetDisplay(wxCommandEvent & event)
|
void TrackPanel::OnSetDisplay(wxCommandEvent & event)
|
||||||
{
|
{
|
||||||
int id = event.GetId();
|
int idInt = event.GetId();
|
||||||
wxASSERT(id >= OnWaveformID && id <= OnPitchID);
|
wxASSERT(idInt >= OnWaveformID && idInt <= OnPitchID);
|
||||||
wxASSERT(mPopupMenuTarget
|
wxASSERT(mPopupMenuTarget
|
||||||
&& mPopupMenuTarget->GetKind() == Track::Wave);
|
&& mPopupMenuTarget->GetKind() == Track::Wave);
|
||||||
|
|
||||||
id -= OnWaveformID;
|
WaveTrack::WaveTrackDisplay id;
|
||||||
|
switch (idInt) {
|
||||||
|
default:
|
||||||
|
case OnWaveformID:
|
||||||
|
id = WaveTrack::WaveformDisplay; break;
|
||||||
|
case OnWaveformDBID:
|
||||||
|
id = WaveTrack::WaveformDBDisplay; break;
|
||||||
|
case OnSpectrumID:
|
||||||
|
id = WaveTrack::SpectralSelectionDisplay; break;
|
||||||
|
case OnSpectrumLogID:
|
||||||
|
id = WaveTrack::SpectralSelectionLogDisplay; break;
|
||||||
|
case OnSpectralSelID:
|
||||||
|
id = WaveTrack::SpectralSelectionDisplay; break;
|
||||||
|
case OnSpectralSelLogID:
|
||||||
|
id = WaveTrack::SpectralSelectionLogDisplay; break;
|
||||||
|
case OnPitchID:
|
||||||
|
id = WaveTrack::PitchDisplay; break;
|
||||||
|
}
|
||||||
WaveTrack *wt = (WaveTrack *) mPopupMenuTarget;
|
WaveTrack *wt = (WaveTrack *) mPopupMenuTarget;
|
||||||
if (wt->GetDisplay() != id) {
|
if (wt->GetDisplay() != id) {
|
||||||
wt->SetDisplay(WaveTrack::WaveTrackDisplay(id));
|
wt->SetDisplay(WaveTrack::WaveTrackDisplay(id));
|
||||||
|
@ -444,7 +444,7 @@ class AUDACITY_DLL_API WaveTrack: public Track {
|
|||||||
if( mDisplay == SpectralSelectionLogDisplay ){
|
if( mDisplay == SpectralSelectionLogDisplay ){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int GetDisplay() const {return mDisplay;}
|
WaveTrackDisplay GetDisplay() const { return mDisplay; }
|
||||||
int GetLastDisplay() {return mLastDisplay;}
|
int GetLastDisplay() {return mLastDisplay;}
|
||||||
|
|
||||||
void GetDisplayBounds(float *min, float *max);
|
void GetDisplayBounds(float *min, float *max);
|
||||||
|
@ -56,23 +56,29 @@ void TracksPrefs::Populate()
|
|||||||
mSoloChoices.Add(_("None"));
|
mSoloChoices.Add(_("None"));
|
||||||
|
|
||||||
|
|
||||||
// Keep the same order as in TrackPanel.cpp menu: OnWaveformID, OnWaveformDBID, OnSpectrumID, OnSpectrumLogID,
|
// Keep view choices and codes in proper correspondence --
|
||||||
// OnSpectralSelID, OnSpectralSelLogID, OnPitchID
|
// we don't display them by increasing integer values.
|
||||||
mViewCodes.Add(0);
|
|
||||||
mViewCodes.Add(1);
|
|
||||||
mViewCodes.Add(2);
|
|
||||||
mViewCodes.Add(3);
|
|
||||||
mViewCodes.Add(4);
|
|
||||||
mViewCodes.Add(5);
|
|
||||||
mViewCodes.Add(6);
|
|
||||||
|
|
||||||
mViewChoices.Add(_("Waveform"));
|
mViewChoices.Add(_("Waveform"));
|
||||||
|
mViewCodes.Add(int(WaveTrack::WaveformDisplay));
|
||||||
|
|
||||||
mViewChoices.Add(_("Waveform (dB)"));
|
mViewChoices.Add(_("Waveform (dB)"));
|
||||||
|
mViewCodes.Add(int(WaveTrack::WaveformDBDisplay));
|
||||||
|
|
||||||
mViewChoices.Add(_("Spectrogram"));
|
mViewChoices.Add(_("Spectrogram"));
|
||||||
|
mViewCodes.Add(int(WaveTrack::SpectrumDisplay));
|
||||||
|
|
||||||
mViewChoices.Add(_("Spectrogram log(f)"));
|
mViewChoices.Add(_("Spectrogram log(f)"));
|
||||||
|
mViewCodes.Add(int(WaveTrack::SpectrumLogDisplay));
|
||||||
|
|
||||||
mViewChoices.Add(_("Spectral Selection"));
|
mViewChoices.Add(_("Spectral Selection"));
|
||||||
|
mViewCodes.Add(int(WaveTrack::SpectralSelectionDisplay));
|
||||||
|
|
||||||
mViewChoices.Add(_("Spectral Selection log(f)"));
|
mViewChoices.Add(_("Spectral Selection log(f)"));
|
||||||
|
mViewCodes.Add(int(WaveTrack::SpectralSelectionLogDisplay));
|
||||||
|
|
||||||
mViewChoices.Add(_("Pitch (EAC)"));
|
mViewChoices.Add(_("Pitch (EAC)"));
|
||||||
|
mViewCodes.Add(int(WaveTrack::PitchDisplay));
|
||||||
|
|
||||||
//------------------------- Main section --------------------
|
//------------------------- Main section --------------------
|
||||||
// Now construct the GUI itself.
|
// Now construct the GUI itself.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user