Audacity 3.2.0
RulerUpdater.h
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 RulerUpdater.h
6
7 Dominic Mazzoni
8 Michael Papadopoulos split from Ruler.h
9
10**********************************************************************/
11
12#ifndef __AUDACITY_UPDATER__
13#define __AUDACITY_UPDATER__
14
15#include "ViewInfo.h" // for children
16#include "Envelope.h"
17#include "NumberScale.h" // member variable
18#include "RulerFormat.h" // member variable
19
20#include <wx/font.h>
21#include <optional>
22
23class wxDC;
24class wxColor;
25
27 struct Fonts {
29 int lead;
30 };
31
32 double mMin{ 0.0 };
33 double mHiddenMin{ 0.0 };
34 double mMax{ 100.0 };
35 double mHiddenMax{ 100.0 };
36
37 int mOrientation{ wxHORIZONTAL };
38 bool mFlip{ false };
39 bool mLabelEdges{ false };
40
42
43 int mLeft{ -1 };
44 int mTop{ -1 };
45 int mRight{ -1 };
46 int mBottom{ -1 };
47 int mLength{ 0 };
48
49 double mDbMirrorValue{ 0.0 };
50
51 // Found on demand
52 mutable std::unique_ptr<Fonts> mpFonts;
54
56};
57
59public:
60 struct Label {
61 double value;
62 int pos;
63 int lx, ly;
64
65 // Minorminor tick draws only when optional is nonempty
66 // Major or minor tick draws regardless
67 std::optional<TranslatableString> text;
68
70
71 void Draw(wxDC& dc, bool twoTone, wxColour c,
72 std::unique_ptr<RulerStruct::Fonts>& fonts) const;
73 };
74 using Labels = std::vector<Label>;
75
76 using Bits = std::vector< bool >;
77
81 wxRect& box;
82 };
83
85 virtual ~RulerUpdater() = 0;
86
87 virtual void Update(
88 wxDC& dc, const Envelope* envelope,
89 UpdateOutputs& allOutputs, const RulerStruct &context
90 )// Envelope *speedEnv, long minSpeed, long maxSpeed )
91 const = 0;
92
93protected:
94 struct TickOutputs { Labels& labels; Bits& bits; wxRect& box; };
95
96 struct TickSizes
97 {
99
100 double mMajor = 0;
101 double mMinor = 0;
102 double mMinorMinor = 0;
103 double mUnits = 0;
104
106
107 TickSizes(
108 double UPP, int orientation, const RulerFormat *format, bool log
109 );
110
111 TranslatableString LabelString(double d, const RulerFormat *format) const;
112 };
113
114 static std::pair< wxRect, Label > MakeTick(
116 wxDC& dc, wxFont font,
117 std::vector<bool>& bits,
118 int left, int top, int spacing, int lead,
119 bool flip, int orientation);
120
121 void BoxAdjust(
122 UpdateOutputs& allOutputs,
123 const RulerStruct& context
124 ) const;
125};
126
127#endif //define __AUDACITY_UPDATER__
Piecewise linear or piecewise exponential function from double to double.
Definition: Envelope.h:72
Used to update a Ruler.
Definition: RulerUpdater.h:58
std::vector< bool > Bits
Definition: RulerUpdater.h:76
std::vector< Label > Labels
Definition: RulerUpdater.h:74
void BoxAdjust(UpdateOutputs &allOutputs, const RulerStruct &context) const
virtual void Update(wxDC &dc, const Envelope *envelope, UpdateOutputs &allOutputs, const RulerStruct &context) const =0
virtual ~RulerUpdater()=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
double mMax
Definition: RulerUpdater.h:34
double mHiddenMax
Definition: RulerUpdater.h:35
TranslatableString mUnits
Definition: RulerUpdater.h:53
double mDbMirrorValue
Definition: RulerUpdater.h:49
int mOrientation
Definition: RulerUpdater.h:37
NumberScale mNumberScale
Definition: RulerUpdater.h:55
bool mLabelEdges
Definition: RulerUpdater.h:39
const RulerFormat * mpRulerFormat
Definition: RulerUpdater.h:41
double mMin
Definition: RulerUpdater.h:32
double mHiddenMin
Definition: RulerUpdater.h:33
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
void Draw(wxDC &dc, bool twoTone, wxColour c, std::unique_ptr< RulerStruct::Fonts > &fonts) const
TranslatableString units
Definition: RulerUpdater.h:69
TranslatableString LabelString(double d, const RulerFormat *format) const
TickSizes(double UPP, int orientation, const RulerFormat *format, bool log)
RulerFormat::TickType tickType
Definition: RulerUpdater.h:98