mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-22 15:20:15 +02:00
More restructuring of Ruler update code
This commit is contained in:
commit
c56a10c5bb
@ -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.
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -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;
|
||||
|
||||
@ -102,11 +102,9 @@ class AUDACITY_DLL_API Ruler {
|
||||
wxFont major, minor, minorMinor;
|
||||
int lead;
|
||||
};
|
||||
Fonts GetFonts() const
|
||||
{ return mFonts; }
|
||||
Fonts GetFonts() const;
|
||||
|
||||
// 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
|
||||
@ -140,12 +138,12 @@ class AUDACITY_DLL_API Ruler {
|
||||
//
|
||||
|
||||
// Note that it will not erase for you...
|
||||
void Draw(wxDC& dc);
|
||||
void Draw(wxDC& dc, const Envelope* envelope);
|
||||
void Draw(wxDC& dc) const;
|
||||
void Draw(wxDC& dc, const Envelope* envelope) const;
|
||||
// If length <> 0, draws lines perpendiculars to ruler corresponding
|
||||
// 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.
|
||||
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...
|
||||
void SetTickColour( const wxColour & colour)
|
||||
@ -170,16 +168,15 @@ class AUDACITY_DLL_API Ruler {
|
||||
|
||||
using Bits = std::vector< bool >;
|
||||
|
||||
static void ChooseFonts( Fonts &fonts, wxDC &dc, int desiredPixelHeight );
|
||||
void Update( wxDC &dc, const Envelope* envelope );
|
||||
void ChooseFonts( wxDC &dc ) const;
|
||||
|
||||
void UpdateCache( wxDC &dc, const Envelope* envelope ) const;
|
||||
|
||||
struct TickOutputs;
|
||||
struct Updater;
|
||||
|
||||
public:
|
||||
bool mbTicksOnly; // true => no line the length of the ruler
|
||||
bool mbTicksAtExtremes;
|
||||
wxRect mRect;
|
||||
|
||||
private:
|
||||
wxColour mTickColour;
|
||||
@ -188,16 +185,13 @@ private:
|
||||
int mLeft, mTop, mRight, mBottom;
|
||||
int mLength;
|
||||
|
||||
Fonts mFonts;
|
||||
bool mUserFonts;
|
||||
std::unique_ptr<Fonts> mpUserFonts;
|
||||
mutable std::unique_ptr<Fonts> mpFonts;
|
||||
|
||||
double mMin, mMax;
|
||||
double mHiddenMin, mHiddenMax;
|
||||
|
||||
Bits mUserBits;
|
||||
Bits mBits;
|
||||
|
||||
bool mValid;
|
||||
|
||||
static std::pair< wxRect, Label > MakeTick(
|
||||
Label lab,
|
||||
@ -206,17 +200,14 @@ private:
|
||||
int left, int top, int spacing, int lead,
|
||||
bool flip, int orientation );
|
||||
|
||||
Labels mMajorLabels;
|
||||
Labels mMinorLabels;
|
||||
Labels mMinorMinorLabels;
|
||||
struct Cache;
|
||||
mutable std::unique_ptr<Cache> mpCache;
|
||||
|
||||
// Returns 'zero' label coordinate (for grid drawing)
|
||||
int FindZero( const Labels &labels );
|
||||
int FindZero( const Labels &labels ) const;
|
||||
|
||||
public:
|
||||
int GetZeroPosition();
|
||||
int GetZeroPosition() const;
|
||||
|
||||
private:
|
||||
int mOrientation;
|
||||
int mSpacing;
|
||||
double mDbMirrorValue;
|
||||
@ -227,15 +218,12 @@ private:
|
||||
bool mFlip;
|
||||
bool mCustom;
|
||||
bool mbMinor;
|
||||
bool mMajorGrid; // for grid drawing
|
||||
bool mMinorGrid; // .
|
||||
int mGridLineLength; // end
|
||||
TranslatableString mUnits;
|
||||
bool mTwoTone;
|
||||
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