Audacity 3.2.0
Public Member Functions | Public Attributes | List of all members
RulerUpdater::TickSizes Struct Reference

#include <RulerUpdater.h>

Public Member Functions

 TickSizes (double UPP, int orientation, const RulerFormat *format, bool log)
 
TranslatableString LabelString (double d, const RulerFormat *format) const
 

Public Attributes

RulerFormat::TickType tickType = RulerFormat::t_major
 
double mMajor = 0
 
double mMinor = 0
 
double mMinorMinor = 0
 
double mUnits = 0
 
int mDigits
 

Detailed Description

Definition at line 96 of file RulerUpdater.h.

Constructor & Destructor Documentation

◆ TickSizes()

RulerUpdater::TickSizes::TickSizes ( double  UPP,
int  orientation,
const RulerFormat format,
bool  log 
)

Definition at line 35 of file RulerUpdater.cpp.

37 {
38 //TODO: better dynamic digit computation for the log case
39 (void)log;
40
41 // Given the dimensions of the ruler, the range of values it
42 // has to display, and the format (i.e. Int, Real, Time),
43 // figure out how many units are in one Minor tick, and
44 // in one Major tick.
45 //
46 // The goal is to always put tick marks on nice round numbers
47 // that are easy for humans to grok. This is the most tricky
48 // with time.
49
50 // As a heuristic, we want at least 22 pixels between each
51 // minor tick. We want to show numbers like "-48"
52 // in that space.
53 // If vertical, we don't need as much space.
54 mUnits = ((orientation == wxHORIZONTAL) ? 22 : 16) * fabs(UPP);
55
56 mDigits = 0;
57
58 if (format)
59 format->SetTickSizes(mUnits, mMajor, mMinor, mMinorMinor, mDigits);
60 }

References anonymous_namespace{ExportPCM.cpp}::format, mDigits, mMajor, mMinor, mMinorMinor, and mUnits.

Member Function Documentation

◆ LabelString()

TranslatableString RulerUpdater::TickSizes::LabelString ( double  d,
const RulerFormat format 
) const

Definition at line 62 of file RulerUpdater.cpp.

64 {
65 // Given a value, turn it into a string according
66 // to the current ruler format. The number of digits of
67 // accuracy depends on the resolution of the ruler,
68 // i.e. how far zoomed in or out you are.
69
70 // Should not be called unless TickSizes is instantiated
71 wxASSERT(mUnits > 0);
72
73 wxString s;
74
75 // PRL Todo: are all these cases properly localized? (Decimal points,
76 // hour-minute-second, etc.?)
77
78 if (format)
79 format->SetLabelString(s, d, mUnits, mMinor, mDigits, tickType);
80
81 auto result = Verbatim(s);
82
83 return result;
84 }
TranslatableString Verbatim(wxString str)
Require calls to the one-argument constructor to go through this distinct global function name.
RulerFormat::TickType tickType
Definition: RulerUpdater.h:98

References anonymous_namespace{ExportPCM.cpp}::format, and Verbatim().

Referenced by GeneratedUpdater::Tick().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ mDigits

int RulerUpdater::TickSizes::mDigits

Definition at line 105 of file RulerUpdater.h.

Referenced by TickSizes().

◆ mMajor

double RulerUpdater::TickSizes::mMajor = 0

Definition at line 100 of file RulerUpdater.h.

Referenced by TickSizes().

◆ mMinor

double RulerUpdater::TickSizes::mMinor = 0

Definition at line 101 of file RulerUpdater.h.

Referenced by TickSizes().

◆ mMinorMinor

double RulerUpdater::TickSizes::mMinorMinor = 0

Definition at line 102 of file RulerUpdater.h.

Referenced by TickSizes().

◆ mUnits

double RulerUpdater::TickSizes::mUnits = 0

Definition at line 103 of file RulerUpdater.h.

Referenced by TickSizes().

◆ tickType

RulerFormat::TickType RulerUpdater::TickSizes::tickType = RulerFormat::t_major

Definition at line 98 of file RulerUpdater.h.


The documentation for this struct was generated from the following files: