Audacity 3.2.0
GeneratedUpdater.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 GeneratedUpdater.cpp
6
7 Dominic Mazzoni
8 Michael Papadopoulos split from Ruler.cpp
9
10**********************************************************************/
11
12
13#include "GeneratedUpdater.h"
14
16 int pos, double d, const TickSizes& tickSizes, wxFont font,
17 // in/out:
18 TickOutputs outputs,
19 const RulerStruct& context) const
20{
21 const double mDbMirrorValue = context.mDbMirrorValue;
22 const int mLength = context.mLength;
23
24 const int mLeft = context.mLeft;
25 const int mTop = context.mTop;
26 const int mBottom = context.mBottom;
27 const int mRight = context.mRight;
28 const int mOrientation = context.mOrientation;
29
30 const RulerStruct::Fonts& mFonts = *context.mpFonts;
31 const TranslatableString mUnits = context.mUnits;
32 const int spacing = (mOrientation == wxHORIZONTAL) ? 6 : 2;
33 const bool mFlip = context.mFlip;
34
35 // Bug 521. dB view for waveforms needs a 2-sided scale.
36 if ((mDbMirrorValue > 1.0) && (-d > mDbMirrorValue))
37 d = -2 * mDbMirrorValue - d;
38
39 // FIXME: We don't draw a tick if off end of our label arrays
40 // But we shouldn't have an array of labels.
41 if (outputs.labels.size() >= mLength)
42 return false;
43
44 Label lab;
45 lab.value = d;
46 lab.pos = pos;
47 lab.text = tickSizes.LabelString(d, context.mpRulerFormat);
48 lab.units = mUnits;
49
50 const auto result = RulerUpdater::MakeTick(
51 lab,
52 dc, font,
53 outputs.bits,
54 mLeft, mTop, spacing, mFonts.lead,
55 mFlip,
56 mOrientation);
57
58 auto& rect = result.first;
59 outputs.box.Union(rect);
60 outputs.labels.emplace_back(result.second);
61 return !rect.IsEmpty();
62}
63
bool Tick(wxDC &dc, int pos, double d, const TickSizes &tickSizes, wxFont font, TickOutputs outputs, const RulerStruct &context) const
virtual ~GeneratedUpdater() override=0
static std::pair< wxRect, Label > MakeTick(RulerUpdater::Label lab, wxDC &dc, wxFont font, std::vector< bool > &bits, int left, int top, int spacing, int lead, bool flip, int orientation)
Holds a msgid for the translation catalog; may also bind format arguments.
std::unique_ptr< Fonts > mpFonts
Definition: RulerUpdater.h:52
TranslatableString mUnits
Definition: RulerUpdater.h:53
double mDbMirrorValue
Definition: RulerUpdater.h:49
int mOrientation
Definition: RulerUpdater.h:37
const RulerFormat * mpRulerFormat
Definition: RulerUpdater.h:41
An array of these created by the Updater is used to determine what and where text annotations to the ...
Definition: RulerUpdater.h:60
std::optional< TranslatableString > text
Definition: RulerUpdater.h:67
TranslatableString units
Definition: RulerUpdater.h:69
TranslatableString LabelString(double d, const RulerFormat *format) const