1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-12-21 16:11:11 +01:00

Split up Ruler::Updater::Update

This commit is contained in:
Paul Licameli
2020-01-23 11:35:42 -05:00
parent 580ad8221e
commit 68281fe0ee

View File

@@ -903,6 +903,11 @@ struct Ruler::Updater {
UpdateOutputs &allOutputs UpdateOutputs &allOutputs
)// Envelope *speedEnv, long minSpeed, long maxSpeed ) )// Envelope *speedEnv, long minSpeed, long maxSpeed )
const; const;
void UpdateCustom( wxDC &dc, UpdateOutputs &allOutputs ) const;
void UpdateLinear(
wxDC &dc, const Envelope *envelope, UpdateOutputs &allOutputs ) const;
void UpdateNonlinear( wxDC &dc, UpdateOutputs &allOutputs ) const;
}; };
struct Ruler::Cache { struct Ruler::Cache {
@@ -1036,18 +1041,11 @@ void Ruler::Updater::ChooseFonts(
fonts.minorMinor = wxFont{ fontSize - 1, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL }; fonts.minorMinor = wxFont{ fontSize - 1, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL };
} }
void Ruler::Updater::Update( void Ruler::Updater::UpdateCustom( wxDC &dc, UpdateOutputs &allOutputs ) const
wxDC &dc, const Envelope* envelope,
UpdateOutputs &allOutputs
)// Envelope *speedEnv, long minSpeed, long maxSpeed )
const
{ {
TickOutputs majorOutputs{ TickOutputs majorOutputs{
allOutputs.majorLabels, allOutputs.bits, allOutputs.box }; allOutputs.majorLabels, allOutputs.bits, allOutputs.box };
// *************** Label calculation routine **************
if( mCustom ) {
// SET PARAMETER IN MCUSTOM CASE // SET PARAMETER IN MCUSTOM CASE
// Works only with major labels // Works only with major labels
@@ -1055,9 +1053,13 @@ void Ruler::Updater::Update(
for( int i = 0; (i<numLabel) && (i<=mLength); ++i ) for( int i = 0; (i<numLabel) && (i<=mLength); ++i )
TickCustom( dc, i, mFonts.major, majorOutputs ); TickCustom( dc, i, mFonts.major, majorOutputs );
} }
else if( !mLog ) {
void Ruler::Updater::UpdateLinear(
wxDC &dc, const Envelope *envelope, UpdateOutputs &allOutputs ) const
{
TickOutputs majorOutputs{
allOutputs.majorLabels, allOutputs.bits, allOutputs.box };
// Use the "hidden" min and max to determine the tick size. // Use the "hidden" min and max to determine the tick size.
// That may make a difference with fisheye. // That may make a difference with fisheye.
@@ -1199,8 +1201,12 @@ void Ruler::Updater::Update(
Tick( dc, mLength, mMax, tickSizes, mFonts.major, majorOutputs ); Tick( dc, mLength, mMax, tickSizes, mFonts.major, majorOutputs );
} }
} }
else {
// log case void Ruler::Updater::UpdateNonlinear(
wxDC &dc, UpdateOutputs &allOutputs ) const
{
TickOutputs majorOutputs{
allOutputs.majorLabels, allOutputs.bits, allOutputs.box };
auto numberScale = ( mNumberScale == NumberScale{} ) auto numberScale = ( mNumberScale == NumberScale{} )
? NumberScale( nstLogarithmic, mMin, mMax ) ? NumberScale( nstLogarithmic, mMin, mMax )
@@ -1285,6 +1291,22 @@ void Ruler::Updater::Update(
} }
} }
void Ruler::Updater::Update(
wxDC &dc, const Envelope* envelope,
UpdateOutputs &allOutputs
)// Envelope *speedEnv, long minSpeed, long maxSpeed )
const
{
TickOutputs majorOutputs{
allOutputs.majorLabels, allOutputs.bits, allOutputs.box };
if ( mCustom )
UpdateCustom( dc, allOutputs );
else if ( !mLog )
UpdateLinear( dc, envelope, allOutputs );
else
UpdateNonlinear( dc, allOutputs );
int displacementx=0, displacementy=0; int displacementx=0, displacementy=0;
auto &box = allOutputs.box; auto &box = allOutputs.box;
if (!mFlip) { if (!mFlip) {