mirror of
https://github.com/cookiengineer/audacity
synced 2025-04-30 15:49:41 +02:00
Remove indirection storing number scale in Ruler
This commit is contained in:
parent
fec3b11674
commit
21306d6186
@ -24,6 +24,7 @@ enum NumberScaleType {
|
||||
nstPeriod,
|
||||
|
||||
nstNumScaleTypes,
|
||||
nstNone,
|
||||
};
|
||||
|
||||
|
||||
@ -31,7 +32,7 @@ class NumberScale
|
||||
{
|
||||
public:
|
||||
NumberScale()
|
||||
: mType(nstLinear), mValue0(0), mValue1(1)
|
||||
: mType(nstNone), mValue0(0), mValue1(1)
|
||||
{}
|
||||
|
||||
NumberScale(NumberScaleType type, float value0, float value1)
|
||||
@ -39,6 +40,7 @@ public:
|
||||
{
|
||||
switch (mType) {
|
||||
case nstLinear:
|
||||
case nstNone:
|
||||
{
|
||||
mValue0 = value0;
|
||||
mValue1 = value1;
|
||||
@ -156,6 +158,7 @@ public:
|
||||
default:
|
||||
wxASSERT(false);
|
||||
case nstLinear:
|
||||
case nstNone:
|
||||
return mValue0 + pp * (mValue1 - mValue0);
|
||||
case nstLogarithmic:
|
||||
return exp(mValue0 + pp * (mValue1 - mValue0));
|
||||
@ -186,6 +189,7 @@ public:
|
||||
default:
|
||||
wxASSERT(false);
|
||||
case nstLinear:
|
||||
case nstNone:
|
||||
case nstLogarithmic:
|
||||
return mValue;
|
||||
case nstMel:
|
||||
@ -203,6 +207,7 @@ public:
|
||||
{
|
||||
switch (mType) {
|
||||
case nstLinear:
|
||||
case nstNone:
|
||||
case nstMel:
|
||||
case nstBark:
|
||||
case nstErb:
|
||||
@ -230,6 +235,7 @@ public:
|
||||
default:
|
||||
wxASSERT(false);
|
||||
case nstLinear:
|
||||
case nstNone:
|
||||
case nstMel:
|
||||
case nstBark:
|
||||
case nstErb:
|
||||
@ -253,6 +259,7 @@ public:
|
||||
default:
|
||||
wxASSERT(false);
|
||||
case nstLinear:
|
||||
case nstNone:
|
||||
return ((val - mValue0) / (mValue1 - mValue0));
|
||||
case nstLogarithmic:
|
||||
return ((log(val) - mValue0) / (mValue1 - mValue0));
|
||||
|
@ -193,7 +193,7 @@ void SpectrumVRulerControls::DoUpdateVRuler(
|
||||
NumberScale scale(
|
||||
wt->GetSpectrogramSettings().GetScale( minFreq, maxFreq )
|
||||
.Reversal() );
|
||||
vruler->SetNumberScale(&scale);
|
||||
vruler->SetNumberScale(scale);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -120,7 +120,6 @@ void WaveformVZoomHandle::DoZoom(
|
||||
const float halfrate = rate / 2;
|
||||
float maxFreq = 8000.0;
|
||||
const SpectrogramSettings &specSettings = pTrack->GetSpectrogramSettings();
|
||||
NumberScale scale;
|
||||
|
||||
bool bDragZoom = WaveTrackVZoomHandle::IsDragZooming(zoomStart, zoomEnd);
|
||||
// Add 100 if spectral to separate the kinds of zoom.
|
||||
|
@ -78,7 +78,6 @@ using std::max;
|
||||
//
|
||||
|
||||
Ruler::Ruler()
|
||||
: mpNumberScale{}
|
||||
{
|
||||
mMin = mHiddenMin = 0.0;
|
||||
mMax = mHiddenMax = 100.0;
|
||||
@ -290,19 +289,11 @@ void Ruler::SetFonts(const wxFont &minorFont, const wxFont &majorFont, const wxF
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
void Ruler::SetNumberScale(const NumberScale *pScale)
|
||||
void Ruler::SetNumberScale(const NumberScale &scale)
|
||||
{
|
||||
if (!pScale) {
|
||||
if (mpNumberScale) {
|
||||
mpNumberScale.reset();
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!mpNumberScale || *mpNumberScale != *pScale) {
|
||||
mpNumberScale = std::make_unique<NumberScale>(*pScale);
|
||||
Invalidate();
|
||||
}
|
||||
if ( mNumberScale != scale ) {
|
||||
mNumberScale = scale;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
@ -886,7 +877,7 @@ struct Ruler::Updater {
|
||||
const double mMin = mRuler.mMin;
|
||||
const double mMax = mRuler.mMax;
|
||||
const int mLeftOffset = mRuler.mLeftOffset;
|
||||
const NumberScale *mpNumberScale = mRuler.mpNumberScale.get();
|
||||
const NumberScale mNumberScale = mRuler.mNumberScale;
|
||||
|
||||
struct TickOutputs;
|
||||
|
||||
@ -1189,10 +1180,9 @@ void Ruler::Updater::Update(
|
||||
else {
|
||||
// log case
|
||||
|
||||
NumberScale numberScale(mpNumberScale
|
||||
? *mpNumberScale
|
||||
: NumberScale(nstLogarithmic, mMin, mMax)
|
||||
);
|
||||
auto numberScale = ( mNumberScale == NumberScale{} )
|
||||
? NumberScale( nstLogarithmic, mMin, mMax )
|
||||
: mNumberScale;
|
||||
|
||||
double UPP = (mHiddenMax-mHiddenMin)/mLength; // Units per pixel
|
||||
TickSizes tickSizes{ UPP, mOrientation, mFormat, true };
|
||||
|
@ -12,6 +12,7 @@
|
||||
#define __AUDACITY_RULER__
|
||||
|
||||
#include "wxPanelWrapper.h" // to inherit
|
||||
#include "../NumberScale.h" // member variable
|
||||
|
||||
#include <wx/colour.h> // member variable
|
||||
#include <wx/pen.h> // member variable
|
||||
@ -20,7 +21,6 @@ class wxArrayString;
|
||||
class wxDC;
|
||||
class wxFont;
|
||||
|
||||
class NumberScale;
|
||||
class Envelope;
|
||||
class ZoomInfo;
|
||||
|
||||
@ -105,8 +105,7 @@ class AUDACITY_DLL_API Ruler {
|
||||
Fonts GetFonts() const
|
||||
{ return mFonts; }
|
||||
|
||||
// Copies *pScale if it is not NULL
|
||||
void SetNumberScale(const NumberScale *pScale);
|
||||
void SetNumberScale(const NumberScale &scale);
|
||||
|
||||
// The ruler will not draw text within this (pixel) range.
|
||||
// Use this if you have another graphic object obscuring part
|
||||
@ -230,7 +229,7 @@ private:
|
||||
const ZoomInfo *mUseZoomInfo;
|
||||
int mLeftOffset;
|
||||
|
||||
std::unique_ptr<NumberScale> mpNumberScale;
|
||||
NumberScale mNumberScale;
|
||||
};
|
||||
|
||||
class AUDACITY_DLL_API RulerPanel final : public wxPanelWrapper {
|
||||
|
Loading…
x
Reference in New Issue
Block a user