1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-11-22 00:47:13 +01:00

TickSizes::LabelString takes one less argument...

... so that Ruler::Tick uses major in one less place
This commit is contained in:
Paul Licameli
2020-01-22 11:22:00 -05:00
parent 80dd2fbec9
commit 2c0afdd77a

View File

@@ -353,6 +353,7 @@ void Ruler::Invalidate()
struct Ruler::TickSizes struct Ruler::TickSizes
{ {
bool useMajor = true;
double mMajor; double mMajor;
double mMinor; double mMinor;
@@ -596,7 +597,7 @@ TickSizes( double UPP, int orientation, RulerFormat format, bool log )
} }
TranslatableString LabelString( TranslatableString LabelString(
double d, bool major, RulerFormat format, const TranslatableString &units ) double d, RulerFormat format, const TranslatableString &units )
const const
{ {
// Given a value, turn it into a string according // Given a value, turn it into a string according
@@ -640,7 +641,7 @@ TranslatableString LabelString(
} }
break; break;
case TimeFormat: case TimeFormat:
if (major) { if (useMajor) {
if (d < 0) { if (d < 0) {
s = wxT("-"); s = wxT("-");
d = -d; d = -d;
@@ -862,7 +863,7 @@ bool Ruler::Tick(
Label lab; Label lab;
lab.value = d; lab.value = d;
lab.pos = pos; lab.pos = pos;
lab.text = tickSizes.LabelString( d, major, mFormat, mUnits ); lab.text = tickSizes.LabelString( d, mFormat, mUnits );
const auto result = MakeTick( const auto result = MakeTick(
lab, lab,
@@ -1127,6 +1128,7 @@ void Ruler::Update(
if (floor(sg * warpedD / denom) > step) { if (floor(sg * warpedD / denom) > step) {
step = floor(sg * warpedD / denom); step = floor(sg * warpedD / denom);
bool major = jj == 0; bool major = jj == 0;
tickSizes.useMajor = major;
bool ticked = Tick( dc, ii, sg * step * denom, major, !major, tickSizes ); bool ticked = Tick( dc, ii, sg * step * denom, major, !major, tickSizes );
if( !major && !ticked ){ if( !major && !ticked ){
nDroppedMinorLabels++; nDroppedMinorLabels++;
@@ -1135,6 +1137,8 @@ void Ruler::Update(
} }
} }
tickSizes.useMajor = true;
// If we've dropped minor labels through overcrowding, then don't show // If we've dropped minor labels through overcrowding, then don't show
// any of them. We're allowed though to drop ones which correspond to the // any of them. We're allowed though to drop ones which correspond to the
// major numbers. // major numbers.
@@ -1197,6 +1201,7 @@ void Ruler::Update(
{ start=9; end=1; mstep=-1; { start=9; end=1; mstep=-1;
} }
steps++; steps++;
tickSizes.useMajor = false;
for(int i=0; i<=steps; i++) { for(int i=0; i<=steps; i++) {
for(int j=start; j!=end; j+=mstep) { for(int j=start; j!=end; j+=mstep) {
val = decade * j; val = decade * j;