mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-22 23:30:07 +02:00
More restructuring of Ruler update code
This commit is contained in:
commit
c56a10c5bb
@ -24,6 +24,7 @@ enum NumberScaleType {
|
|||||||
nstPeriod,
|
nstPeriod,
|
||||||
|
|
||||||
nstNumScaleTypes,
|
nstNumScaleTypes,
|
||||||
|
nstNone,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -31,7 +32,7 @@ class NumberScale
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NumberScale()
|
NumberScale()
|
||||||
: mType(nstLinear), mValue0(0), mValue1(1)
|
: mType(nstNone), mValue0(0), mValue1(1)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
NumberScale(NumberScaleType type, float value0, float value1)
|
NumberScale(NumberScaleType type, float value0, float value1)
|
||||||
@ -39,6 +40,7 @@ public:
|
|||||||
{
|
{
|
||||||
switch (mType) {
|
switch (mType) {
|
||||||
case nstLinear:
|
case nstLinear:
|
||||||
|
case nstNone:
|
||||||
{
|
{
|
||||||
mValue0 = value0;
|
mValue0 = value0;
|
||||||
mValue1 = value1;
|
mValue1 = value1;
|
||||||
@ -156,6 +158,7 @@ public:
|
|||||||
default:
|
default:
|
||||||
wxASSERT(false);
|
wxASSERT(false);
|
||||||
case nstLinear:
|
case nstLinear:
|
||||||
|
case nstNone:
|
||||||
return mValue0 + pp * (mValue1 - mValue0);
|
return mValue0 + pp * (mValue1 - mValue0);
|
||||||
case nstLogarithmic:
|
case nstLogarithmic:
|
||||||
return exp(mValue0 + pp * (mValue1 - mValue0));
|
return exp(mValue0 + pp * (mValue1 - mValue0));
|
||||||
@ -186,6 +189,7 @@ public:
|
|||||||
default:
|
default:
|
||||||
wxASSERT(false);
|
wxASSERT(false);
|
||||||
case nstLinear:
|
case nstLinear:
|
||||||
|
case nstNone:
|
||||||
case nstLogarithmic:
|
case nstLogarithmic:
|
||||||
return mValue;
|
return mValue;
|
||||||
case nstMel:
|
case nstMel:
|
||||||
@ -203,6 +207,7 @@ public:
|
|||||||
{
|
{
|
||||||
switch (mType) {
|
switch (mType) {
|
||||||
case nstLinear:
|
case nstLinear:
|
||||||
|
case nstNone:
|
||||||
case nstMel:
|
case nstMel:
|
||||||
case nstBark:
|
case nstBark:
|
||||||
case nstErb:
|
case nstErb:
|
||||||
@ -230,6 +235,7 @@ public:
|
|||||||
default:
|
default:
|
||||||
wxASSERT(false);
|
wxASSERT(false);
|
||||||
case nstLinear:
|
case nstLinear:
|
||||||
|
case nstNone:
|
||||||
case nstMel:
|
case nstMel:
|
||||||
case nstBark:
|
case nstBark:
|
||||||
case nstErb:
|
case nstErb:
|
||||||
@ -253,6 +259,7 @@ public:
|
|||||||
default:
|
default:
|
||||||
wxASSERT(false);
|
wxASSERT(false);
|
||||||
case nstLinear:
|
case nstLinear:
|
||||||
|
case nstNone:
|
||||||
return ((val - mValue0) / (mValue1 - mValue0));
|
return ((val - mValue0) / (mValue1 - mValue0));
|
||||||
case nstLogarithmic:
|
case nstLogarithmic:
|
||||||
return ((log(val) - mValue0) / (mValue1 - mValue0));
|
return ((log(val) - mValue0) / (mValue1 - mValue0));
|
||||||
|
@ -193,7 +193,7 @@ void SpectrumVRulerControls::DoUpdateVRuler(
|
|||||||
NumberScale scale(
|
NumberScale scale(
|
||||||
wt->GetSpectrogramSettings().GetScale( minFreq, maxFreq )
|
wt->GetSpectrogramSettings().GetScale( minFreq, maxFreq )
|
||||||
.Reversal() );
|
.Reversal() );
|
||||||
vruler->SetNumberScale(&scale);
|
vruler->SetNumberScale(scale);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -120,7 +120,6 @@ void WaveformVZoomHandle::DoZoom(
|
|||||||
const float halfrate = rate / 2;
|
const float halfrate = rate / 2;
|
||||||
float maxFreq = 8000.0;
|
float maxFreq = 8000.0;
|
||||||
const SpectrogramSettings &specSettings = pTrack->GetSpectrogramSettings();
|
const SpectrogramSettings &specSettings = pTrack->GetSpectrogramSettings();
|
||||||
NumberScale scale;
|
|
||||||
|
|
||||||
bool bDragZoom = WaveTrackVZoomHandle::IsDragZooming(zoomStart, zoomEnd);
|
bool bDragZoom = WaveTrackVZoomHandle::IsDragZooming(zoomStart, zoomEnd);
|
||||||
// Add 100 if spectral to separate the kinds of zoom.
|
// Add 100 if spectral to separate the kinds of zoom.
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -12,6 +12,7 @@
|
|||||||
#define __AUDACITY_RULER__
|
#define __AUDACITY_RULER__
|
||||||
|
|
||||||
#include "wxPanelWrapper.h" // to inherit
|
#include "wxPanelWrapper.h" // to inherit
|
||||||
|
#include "../NumberScale.h" // member variable
|
||||||
|
|
||||||
#include <wx/colour.h> // member variable
|
#include <wx/colour.h> // member variable
|
||||||
#include <wx/pen.h> // member variable
|
#include <wx/pen.h> // member variable
|
||||||
@ -20,7 +21,6 @@ class wxArrayString;
|
|||||||
class wxDC;
|
class wxDC;
|
||||||
class wxFont;
|
class wxFont;
|
||||||
|
|
||||||
class NumberScale;
|
|
||||||
class Envelope;
|
class Envelope;
|
||||||
class ZoomInfo;
|
class ZoomInfo;
|
||||||
|
|
||||||
@ -102,11 +102,9 @@ class AUDACITY_DLL_API Ruler {
|
|||||||
wxFont major, minor, minorMinor;
|
wxFont major, minor, minorMinor;
|
||||||
int lead;
|
int lead;
|
||||||
};
|
};
|
||||||
Fonts GetFonts() const
|
Fonts GetFonts() const;
|
||||||
{ return mFonts; }
|
|
||||||
|
|
||||||
// Copies *pScale if it is not NULL
|
void SetNumberScale(const NumberScale &scale);
|
||||||
void SetNumberScale(const NumberScale *pScale);
|
|
||||||
|
|
||||||
// The ruler will not draw text within this (pixel) range.
|
// The ruler will not draw text within this (pixel) range.
|
||||||
// Use this if you have another graphic object obscuring part
|
// Use this if you have another graphic object obscuring part
|
||||||
@ -140,12 +138,12 @@ class AUDACITY_DLL_API Ruler {
|
|||||||
//
|
//
|
||||||
|
|
||||||
// Note that it will not erase for you...
|
// Note that it will not erase for you...
|
||||||
void Draw(wxDC& dc);
|
void Draw(wxDC& dc) const;
|
||||||
void Draw(wxDC& dc, const Envelope* envelope);
|
void Draw(wxDC& dc, const Envelope* envelope) const;
|
||||||
// If length <> 0, draws lines perpendiculars to ruler corresponding
|
// If length <> 0, draws lines perpendiculars to ruler corresponding
|
||||||
// to selected ticks (major, minor, or both), in an adjacent window.
|
// to selected ticks (major, minor, or both), in an adjacent window.
|
||||||
// You may need to use the offsets if you are using part of the dc for rulers, borders etc.
|
// You may need to use the offsets if you are using part of the dc for rulers, borders etc.
|
||||||
void DrawGrid(wxDC& dc, int length, bool minor = true, bool major = true, int xOffset = 0, int yOffset = 0);
|
void DrawGrid(wxDC& dc, int length, bool minor = true, bool major = true, int xOffset = 0, int yOffset = 0) const;
|
||||||
|
|
||||||
// So we can have white ticks on black...
|
// So we can have white ticks on black...
|
||||||
void SetTickColour( const wxColour & colour)
|
void SetTickColour( const wxColour & colour)
|
||||||
@ -170,16 +168,15 @@ class AUDACITY_DLL_API Ruler {
|
|||||||
|
|
||||||
using Bits = std::vector< bool >;
|
using Bits = std::vector< bool >;
|
||||||
|
|
||||||
static void ChooseFonts( Fonts &fonts, wxDC &dc, int desiredPixelHeight );
|
void ChooseFonts( wxDC &dc ) const;
|
||||||
void Update( wxDC &dc, const Envelope* envelope );
|
|
||||||
|
void UpdateCache( wxDC &dc, const Envelope* envelope ) const;
|
||||||
|
|
||||||
struct TickOutputs;
|
|
||||||
struct Updater;
|
struct Updater;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool mbTicksOnly; // true => no line the length of the ruler
|
bool mbTicksOnly; // true => no line the length of the ruler
|
||||||
bool mbTicksAtExtremes;
|
bool mbTicksAtExtremes;
|
||||||
wxRect mRect;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
wxColour mTickColour;
|
wxColour mTickColour;
|
||||||
@ -188,16 +185,13 @@ private:
|
|||||||
int mLeft, mTop, mRight, mBottom;
|
int mLeft, mTop, mRight, mBottom;
|
||||||
int mLength;
|
int mLength;
|
||||||
|
|
||||||
Fonts mFonts;
|
std::unique_ptr<Fonts> mpUserFonts;
|
||||||
bool mUserFonts;
|
mutable std::unique_ptr<Fonts> mpFonts;
|
||||||
|
|
||||||
double mMin, mMax;
|
double mMin, mMax;
|
||||||
double mHiddenMin, mHiddenMax;
|
double mHiddenMin, mHiddenMax;
|
||||||
|
|
||||||
Bits mUserBits;
|
Bits mUserBits;
|
||||||
Bits mBits;
|
|
||||||
|
|
||||||
bool mValid;
|
|
||||||
|
|
||||||
static std::pair< wxRect, Label > MakeTick(
|
static std::pair< wxRect, Label > MakeTick(
|
||||||
Label lab,
|
Label lab,
|
||||||
@ -206,17 +200,14 @@ private:
|
|||||||
int left, int top, int spacing, int lead,
|
int left, int top, int spacing, int lead,
|
||||||
bool flip, int orientation );
|
bool flip, int orientation );
|
||||||
|
|
||||||
Labels mMajorLabels;
|
struct Cache;
|
||||||
Labels mMinorLabels;
|
mutable std::unique_ptr<Cache> mpCache;
|
||||||
Labels mMinorMinorLabels;
|
|
||||||
|
|
||||||
// Returns 'zero' label coordinate (for grid drawing)
|
// Returns 'zero' label coordinate (for grid drawing)
|
||||||
int FindZero( const Labels &labels );
|
int FindZero( const Labels &labels ) const;
|
||||||
|
|
||||||
public:
|
int GetZeroPosition() const;
|
||||||
int GetZeroPosition();
|
|
||||||
|
|
||||||
private:
|
|
||||||
int mOrientation;
|
int mOrientation;
|
||||||
int mSpacing;
|
int mSpacing;
|
||||||
double mDbMirrorValue;
|
double mDbMirrorValue;
|
||||||
@ -227,15 +218,12 @@ private:
|
|||||||
bool mFlip;
|
bool mFlip;
|
||||||
bool mCustom;
|
bool mCustom;
|
||||||
bool mbMinor;
|
bool mbMinor;
|
||||||
bool mMajorGrid; // for grid drawing
|
|
||||||
bool mMinorGrid; // .
|
|
||||||
int mGridLineLength; // end
|
|
||||||
TranslatableString mUnits;
|
TranslatableString mUnits;
|
||||||
bool mTwoTone;
|
bool mTwoTone;
|
||||||
const ZoomInfo *mUseZoomInfo;
|
const ZoomInfo *mUseZoomInfo;
|
||||||
int mLeftOffset;
|
int mLeftOffset;
|
||||||
|
|
||||||
std::unique_ptr<NumberScale> mpNumberScale;
|
NumberScale mNumberScale;
|
||||||
};
|
};
|
||||||
|
|
||||||
class AUDACITY_DLL_API RulerPanel final : public wxPanelWrapper {
|
class AUDACITY_DLL_API RulerPanel final : public wxPanelWrapper {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user