RulerPanel uses TranslatableString for units string...
... also fixing missed translation of "k" in spectrum vertical ruler
This commit is contained in:
parent
1887928fe2
commit
6e14d2e56c
|
@ -301,7 +301,7 @@ FrequencyPlotDialog::FrequencyPlotDialog(wxWindow * parent, wxWindowID id,
|
|||
wxSize{ 100, 100 }, // Ruler can't handle small sizes
|
||||
RulerPanel::Range{ 0.0, -dBRange },
|
||||
Ruler::LinearDBFormat,
|
||||
_("dB"),
|
||||
XO("dB"),
|
||||
RulerPanel::Options{}
|
||||
.LabelEdges(true)
|
||||
.TickColour( theTheme.Colour( clrGraphLabels ) )
|
||||
|
@ -384,7 +384,7 @@ FrequencyPlotDialog::FrequencyPlotDialog(wxWindow * parent, wxWindowID id,
|
|||
wxSize{ 100, 100 }, // Ruler can't handle small sizes
|
||||
RulerPanel::Range{ 10, 20000 },
|
||||
Ruler::RealFormat,
|
||||
_("Hz"),
|
||||
XO("Hz"),
|
||||
RulerPanel::Options{}
|
||||
.Log(true)
|
||||
.Flip(true)
|
||||
|
@ -721,10 +721,10 @@ void FrequencyPlotDialog::DrawPlot()
|
|||
// Set up y axis ruler
|
||||
|
||||
if (mAlg == SpectrumAnalyst::Spectrum) {
|
||||
vRuler->ruler.SetUnits(_("dB"));
|
||||
vRuler->ruler.SetUnits(XO("dB"));
|
||||
vRuler->ruler.SetFormat(Ruler::LinearDBFormat);
|
||||
} else {
|
||||
vRuler->ruler.SetUnits(wxT(""));
|
||||
vRuler->ruler.SetUnits({});
|
||||
vRuler->ruler.SetFormat(Ruler::RealFormat);
|
||||
}
|
||||
int w1, w2, h;
|
||||
|
@ -767,13 +767,14 @@ void FrequencyPlotDialog::DrawPlot()
|
|||
xStep = (xMax - xMin) / width;
|
||||
hRuler->ruler.SetLog(false);
|
||||
}
|
||||
hRuler->ruler.SetUnits(_("Hz"));
|
||||
hRuler->ruler.SetUnits(XO("Hz"));
|
||||
} else {
|
||||
xMin = 0;
|
||||
xMax = mAnalyst->GetProcessedSize() / mRate;
|
||||
xStep = (xMax - xMin) / width;
|
||||
hRuler->ruler.SetLog(false);
|
||||
hRuler->ruler.SetUnits(_("s"));
|
||||
/* i18n-hint: short form of 'seconds'.*/
|
||||
hRuler->ruler.SetUnits(XO("s"));
|
||||
}
|
||||
hRuler->ruler.SetRange(xMin, xMax-xStep);
|
||||
hRuler->Refresh(false);
|
||||
|
|
|
@ -716,7 +716,7 @@ void EffectCompressorPanel::OnPaint(wxPaintEvent & WXUNUSED(evt))
|
|||
vRuler.SetOrientation(wxVERTICAL);
|
||||
vRuler.SetRange(0, -rangeDB);
|
||||
vRuler.SetFormat(Ruler::LinearDBFormat);
|
||||
vRuler.SetUnits(_("dB"));
|
||||
vRuler.SetUnits(XO("dB"));
|
||||
vRuler.GetMaxSize(&w, NULL);
|
||||
|
||||
Ruler hRuler;
|
||||
|
@ -724,7 +724,7 @@ void EffectCompressorPanel::OnPaint(wxPaintEvent & WXUNUSED(evt))
|
|||
hRuler.SetOrientation(wxHORIZONTAL);
|
||||
hRuler.SetRange(-rangeDB, 0);
|
||||
hRuler.SetFormat(Ruler::LinearDBFormat);
|
||||
hRuler.SetUnits(_("dB"));
|
||||
hRuler.SetUnits(XO("dB"));
|
||||
hRuler.SetFlip(true);
|
||||
hRuler.GetMaxSize(NULL, &h);
|
||||
|
||||
|
|
|
@ -776,7 +776,7 @@ void EffectEqualization::PopulateOrExchange(ShuttleGui & S)
|
|||
wxSize{ 100, 100 }, // Ruler can't handle small sizes
|
||||
RulerPanel::Range{ 60.0, -120.0 },
|
||||
Ruler::LinearDBFormat,
|
||||
_("dB"),
|
||||
XO("dB"),
|
||||
RulerPanel::Options{}
|
||||
.LabelEdges(true)
|
||||
.TicksAtExtremes(true)
|
||||
|
@ -833,7 +833,7 @@ void EffectEqualization::PopulateOrExchange(ShuttleGui & S)
|
|||
wxSize{ 100, 100 }, // Ruler can't handle small sizes
|
||||
RulerPanel::Range{ mLoFreq, mHiFreq },
|
||||
Ruler::IntFormat,
|
||||
_("Hz"),
|
||||
XO("Hz"),
|
||||
RulerPanel::Options{}
|
||||
.Log(true)
|
||||
.Flip(true)
|
||||
|
|
|
@ -380,7 +380,7 @@ void EffectScienFilter::PopulateOrExchange(ShuttleGui & S)
|
|||
wxSize{ 100, 100 }, // Ruler can't handle small sizes
|
||||
RulerPanel::Range{ 30.0, -120.0 },
|
||||
Ruler::LinearDBFormat,
|
||||
_("dB"),
|
||||
XO("dB"),
|
||||
RulerPanel::Options{}
|
||||
.LabelEdges(true)
|
||||
);
|
||||
|
@ -438,7 +438,7 @@ void EffectScienFilter::PopulateOrExchange(ShuttleGui & S)
|
|||
wxSize{ 100, 100 }, // Ruler can't handle small sizes
|
||||
RulerPanel::Range{ mLoFreq, mNyquist },
|
||||
Ruler::IntFormat,
|
||||
wxT(""),
|
||||
{},
|
||||
RulerPanel::Options{}
|
||||
.Log(true)
|
||||
.Flip(true)
|
||||
|
|
|
@ -162,12 +162,13 @@ void SpectrumVRulerControls::DoUpdateVRuler(
|
|||
// use kHz in scale, if appropriate
|
||||
if (maxFreq >= 2000) {
|
||||
vruler->SetRange((maxFreq / 1000.), (minFreq / 1000.));
|
||||
vruler->SetUnits(wxT("k"));
|
||||
/* i18n-hint k abbreviating kilo meaning thousands */
|
||||
vruler->SetUnits(XO("k"));
|
||||
}
|
||||
else {
|
||||
// use Hz
|
||||
vruler->SetRange((int)(maxFreq), (int)(minFreq));
|
||||
vruler->SetUnits(wxT(""));
|
||||
vruler->SetUnits({});
|
||||
}
|
||||
vruler->SetLog(false);
|
||||
}
|
||||
|
@ -193,7 +194,7 @@ void SpectrumVRulerControls::DoUpdateVRuler(
|
|||
vruler->SetFormat(Ruler::IntFormat);
|
||||
vruler->SetLabelEdges(true);
|
||||
vruler->SetRange(maxFreq, minFreq);
|
||||
vruler->SetUnits(wxT(""));
|
||||
vruler->SetUnits({});
|
||||
vruler->SetLog(true);
|
||||
NumberScale scale(
|
||||
wt->GetSpectrogramSettings().GetScale( minFreq, maxFreq )
|
||||
|
|
|
@ -220,7 +220,7 @@ void WaveformVRulerControls::DoUpdateVRuler(
|
|||
vruler->SetOrientation(wxVERTICAL);
|
||||
vruler->SetRange(max, min);
|
||||
vruler->SetFormat(Ruler::RealFormat);
|
||||
vruler->SetUnits(wxT(""));
|
||||
vruler->SetUnits({});
|
||||
vruler->SetLabelEdges(false);
|
||||
vruler->SetLog(false);
|
||||
}
|
||||
|
@ -228,7 +228,7 @@ void WaveformVRulerControls::DoUpdateVRuler(
|
|||
wxASSERT(scaleType == WaveformSettings::stLogarithmic);
|
||||
scaleType = WaveformSettings::stLogarithmic;
|
||||
|
||||
vruler->SetUnits(wxT(""));
|
||||
vruler->SetUnits({});
|
||||
|
||||
float min, max;
|
||||
wt->GetDisplayBounds(&min, &max);
|
||||
|
|
|
@ -90,7 +90,7 @@ void TimeTrackVRulerControls::UpdateRuler( const wxRect &rect )
|
|||
vruler->SetOrientation(wxVERTICAL);
|
||||
vruler->SetRange(max, min);
|
||||
vruler->SetFormat((tt->GetDisplayLog()) ? Ruler::RealLogFormat : Ruler::RealFormat);
|
||||
vruler->SetUnits(wxT(""));
|
||||
vruler->SetUnits({});
|
||||
vruler->SetLabelEdges(false);
|
||||
vruler->SetLog(tt->GetDisplayLog());
|
||||
|
||||
|
|
|
@ -166,7 +166,7 @@ void Ruler::SetLog(bool log)
|
|||
}
|
||||
}
|
||||
|
||||
void Ruler::SetUnits(const wxString &units)
|
||||
void Ruler::SetUnits(const TranslatableString &units)
|
||||
{
|
||||
// Specify the name of the units (like "dB") if you
|
||||
// want numbers like "1.6" formatted as "1.6 dB".
|
||||
|
@ -576,7 +576,7 @@ void Ruler::FindLinearTickSizes(double UPP)
|
|||
}
|
||||
}
|
||||
|
||||
wxString Ruler::LabelString(double d, bool major)
|
||||
TranslatableString Ruler::LabelString(double d, bool major)
|
||||
{
|
||||
// Given a value, turn it into a string according
|
||||
// to the current ruler format. The number of digits of
|
||||
|
@ -585,6 +585,9 @@ wxString Ruler::LabelString(double d, bool major)
|
|||
|
||||
wxString s;
|
||||
|
||||
// PRL Todo: are all these cases properly localized? (Decimal points,
|
||||
// hour-minute-second, etc.?)
|
||||
|
||||
// Replace -0 with 0
|
||||
if (d < 0.0 && (d+mMinor > 0.0) && ( mFormat != RealLogFormat ))
|
||||
d = 0.0;
|
||||
|
@ -718,15 +721,15 @@ wxString Ruler::LabelString(double d, bool major)
|
|||
}
|
||||
}
|
||||
|
||||
auto result = Verbatim( s );
|
||||
if (!mUnits.empty())
|
||||
s = (s + mUnits);
|
||||
result += mUnits;
|
||||
|
||||
return s;
|
||||
return result;
|
||||
}
|
||||
|
||||
void Ruler::Tick(int pos, double d, bool major, bool minor)
|
||||
{
|
||||
wxString l;
|
||||
wxCoord strW, strH, strD, strL;
|
||||
int strPos, strLen, strLeft, strTop;
|
||||
|
||||
|
@ -751,14 +754,14 @@ void Ruler::Tick(int pos, double d, bool major, bool minor)
|
|||
label->pos = pos;
|
||||
label->lx = mLeft - 1000; // don't display
|
||||
label->ly = mTop - 1000; // don't display
|
||||
label->text = wxT("");
|
||||
label->text = {};
|
||||
|
||||
mDC->SetFont(major? *mMajorFont: minor? *mMinorFont : *mMinorMinorFont);
|
||||
// Bug 521. dB view for waveforms needs a 2-sided scale.
|
||||
if(( mDbMirrorValue > 1.0 ) && ( -d > mDbMirrorValue ))
|
||||
d = -2*mDbMirrorValue - d;
|
||||
l = LabelString(d, major);
|
||||
mDC->GetTextExtent(l, &strW, &strH, &strD, &strL);
|
||||
auto l = LabelString(d, major);
|
||||
mDC->GetTextExtent(l.Translation(), &strW, &strH, &strD, &strL);
|
||||
|
||||
if (mOrientation == wxHORIZONTAL) {
|
||||
strLen = strW;
|
||||
|
@ -842,7 +845,6 @@ void Ruler::TickCustom(int labelIdx, bool major, bool minor)
|
|||
// be optimized.
|
||||
|
||||
int pos;
|
||||
wxString l;
|
||||
wxCoord strW, strH, strD, strL;
|
||||
int strPos, strLen, strLeft, strTop;
|
||||
|
||||
|
@ -863,13 +865,13 @@ void Ruler::TickCustom(int labelIdx, bool major, bool minor)
|
|||
|
||||
label->value = 0.0;
|
||||
pos = label->pos; // already stored in label class
|
||||
l = label->text;
|
||||
auto l = label->text;
|
||||
label->lx = mLeft - 1000; // don't display
|
||||
label->ly = mTop - 1000; // don't display
|
||||
|
||||
mDC->SetFont(major? *mMajorFont: minor? *mMinorFont : *mMinorMinorFont);
|
||||
|
||||
mDC->GetTextExtent(l, &strW, &strH, &strD, &strL);
|
||||
mDC->GetTextExtent(l.Translation(), &strW, &strH, &strD, &strL);
|
||||
|
||||
if (mOrientation == wxHORIZONTAL) {
|
||||
strLen = strW;
|
||||
|
@ -1170,7 +1172,7 @@ void Ruler::Update(const Envelope* envelope)// Envelope *speedEnv, long minSpeed
|
|||
// mNumMinor = 0;
|
||||
// Nowadays we just drop the labels.
|
||||
for(i=0; i<mNumMinor; i++)
|
||||
mMinorLabels[i].text = "";
|
||||
mMinorLabels[i].text = {};
|
||||
}
|
||||
|
||||
// Left and Right Edges
|
||||
|
@ -1541,25 +1543,29 @@ void Ruler::GetMaxSize(wxCoord *width, wxCoord *height)
|
|||
|
||||
void Ruler::SetCustomMode(bool value) { mCustom = value; }
|
||||
|
||||
void Ruler::SetCustomMajorLabels(wxArrayString *label, size_t numLabel, int start, int step)
|
||||
void Ruler::SetCustomMajorLabels(
|
||||
const TranslatableStrings &labels, int start, int step)
|
||||
{
|
||||
const auto numLabel = labels.size();
|
||||
mNumMajor = numLabel;
|
||||
mMajorLabels.reinit(numLabel);
|
||||
|
||||
for(size_t i = 0; i<numLabel; i++) {
|
||||
mMajorLabels[i].text = (*label)[i];
|
||||
mMajorLabels[i].text = labels[i];
|
||||
mMajorLabels[i].pos = start + i*step;
|
||||
}
|
||||
//Remember: DELETE majorlabels....
|
||||
}
|
||||
|
||||
void Ruler::SetCustomMinorLabels(wxArrayString *label, size_t numLabel, int start, int step)
|
||||
void Ruler::SetCustomMinorLabels(
|
||||
const TranslatableStrings &labels, int start, int step)
|
||||
{
|
||||
const auto numLabel = labels.size();
|
||||
mNumMinor = numLabel;
|
||||
mMinorLabels.reinit(numLabel);
|
||||
|
||||
for(size_t i = 0; i<numLabel; i++) {
|
||||
mMinorLabels[i].text = (*label)[i];
|
||||
mMinorLabels[i].text = labels[i];
|
||||
mMinorLabels[i].pos = start + i*step;
|
||||
}
|
||||
//Remember: DELETE majorlabels....
|
||||
|
@ -1576,7 +1582,7 @@ void Ruler::Label::Draw(wxDC&dc, bool twoTone, wxColour c) const
|
|||
dc.SetTextForeground(altColor ? *wxBLUE : *wxBLACK);
|
||||
#endif
|
||||
|
||||
dc.DrawText(text, lx, ly);
|
||||
dc.DrawText(text.Translation(), lx, ly);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1603,7 +1609,7 @@ RulerPanel::RulerPanel(wxWindow* parent, wxWindowID id,
|
|||
const wxSize &bounds,
|
||||
const Range &range,
|
||||
Ruler::RulerFormat format,
|
||||
const wxString &units,
|
||||
const TranslatableString &units,
|
||||
const Options &options,
|
||||
const wxPoint& pos /*= wxDefaultPosition*/,
|
||||
const wxSize& size /*= wxDefaultSize*/):
|
||||
|
|
|
@ -75,7 +75,7 @@ class AUDACITY_DLL_API Ruler {
|
|||
|
||||
// Specify the name of the units (like "dB") if you
|
||||
// want numbers like "1.6" formatted as "1.6 dB".
|
||||
void SetUnits(const wxString &units);
|
||||
void SetUnits(const TranslatableString &units);
|
||||
void SetDbMirrorValue( const double d ){ mDbMirrorValue = d ; };
|
||||
|
||||
// Logarithmic
|
||||
|
@ -125,8 +125,10 @@ class AUDACITY_DLL_API Ruler {
|
|||
// If this is the case, you should provide a wxString array of labels, start
|
||||
// label position, and labels step. The range eventually specified will be
|
||||
// ignored.
|
||||
void SetCustomMajorLabels(wxArrayString *label, size_t numLabel, int start, int step);
|
||||
void SetCustomMinorLabels(wxArrayString *label, size_t numLabel, int start, int step);
|
||||
void SetCustomMajorLabels(
|
||||
const TranslatableStrings &labels, int start, int step);
|
||||
void SetCustomMinorLabels(
|
||||
const TranslatableStrings &labels, int start, int step);
|
||||
|
||||
void SetUseZoomInfo(int leftOffset, const ZoomInfo *zoomInfo);
|
||||
|
||||
|
@ -154,7 +156,7 @@ class AUDACITY_DLL_API Ruler {
|
|||
void Update(const Envelope* envelope);
|
||||
void FindTickSizes();
|
||||
void FindLinearTickSizes(double UPP);
|
||||
wxString LabelString(double d, bool major);
|
||||
TranslatableString LabelString(double d, bool major);
|
||||
|
||||
void Tick(int pos, double d, bool major, bool minor);
|
||||
|
||||
|
@ -198,7 +200,7 @@ private:
|
|||
double value;
|
||||
int pos;
|
||||
int lx, ly;
|
||||
wxString text;
|
||||
TranslatableString text;
|
||||
|
||||
void Draw(wxDC &dc, bool twoTone, wxColour c) const;
|
||||
};
|
||||
|
@ -230,7 +232,7 @@ private:
|
|||
bool mMajorGrid; // for grid drawing
|
||||
bool mMinorGrid; // .
|
||||
int mGridLineLength; // end
|
||||
wxString mUnits;
|
||||
TranslatableString mUnits;
|
||||
bool mTwoTone;
|
||||
const ZoomInfo *mUseZoomInfo;
|
||||
int mLeftOffset;
|
||||
|
@ -275,7 +277,7 @@ class AUDACITY_DLL_API RulerPanel final : public wxPanelWrapper {
|
|||
const wxSize &bounds,
|
||||
const Range &range,
|
||||
Ruler::RulerFormat format,
|
||||
const wxString &units,
|
||||
const TranslatableString &units,
|
||||
const Options &options = {},
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize);
|
||||
|
|
Loading…
Reference in New Issue