Audacity 3.2.0
Public Member Functions | Public Attributes | List of all members
RulerUpdater::Label Class Reference

An array of these created by the Updater is used to determine what and where text annotations to the numbers on the Ruler get drawn. More...

#include <RulerUpdater.h>

Collaboration diagram for RulerUpdater::Label:
[legend]

Public Member Functions

void Draw (wxDC &dc, bool twoTone, wxColour c, std::unique_ptr< RulerStruct::Fonts > &fonts) const
 

Public Attributes

double value
 
int pos
 
int lx
 
int ly
 
std::optional< TranslatableStringtext
 
TranslatableString units
 

Detailed Description

An array of these created by the Updater is used to determine what and where text annotations to the numbers on the Ruler get drawn.

Todo:
Check whether RulerUpdater is costing too much time in allocation/free of array of RulerUpdater::Label.

Definition at line 60 of file RulerUpdater.h.

Member Function Documentation

◆ Draw()

void RulerUpdater::Label::Draw ( wxDC &  dc,
bool  twoTone,
wxColour  c,
std::unique_ptr< RulerStruct::Fonts > &  fonts 
) const

Definition at line 86 of file RulerUpdater.cpp.

89{
90 if (text.has_value() && !text->empty()) {
91 bool altColor = twoTone && value < 0.0;
92
93 dc.SetTextForeground(altColor ? theTheme.Colour(clrTextNegativeNumbers) : c);
94 dc.SetBackgroundMode(wxTRANSPARENT);
95 if (dc.GetFont() == fonts->major) {
96 // Do not draw units as bolded
97 dc.DrawText(text->Translation(), lx, ly);
98 wxSize textSize = dc.GetTextExtent(text->Translation());
99 dc.SetFont(fonts->minor);
100 int unitX = lx + textSize.GetWidth();
101 dc.DrawText(units.Translation(), unitX, ly);
102 dc.SetFont(fonts->major);
103 }
104 else {
105 auto str = *text + units;
106 dc.DrawText(str.Translation(), lx, ly);
107 }
108 }
109}
#define str(a)
THEME_API Theme theTheme
Definition: Theme.cpp:82
wxColour & Colour(int iIndex)
wxString Translation() const
std::optional< TranslatableString > text
Definition: RulerUpdater.h:67
TranslatableString units
Definition: RulerUpdater.h:69

References ThemeBase::Colour(), str, and theTheme.

Here is the call graph for this function:

Member Data Documentation

◆ lx

int RulerUpdater::Label::lx

Definition at line 63 of file RulerUpdater.h.

◆ ly

int RulerUpdater::Label::ly

Definition at line 63 of file RulerUpdater.h.

◆ pos

int RulerUpdater::Label::pos

◆ text

std::optional<TranslatableString> RulerUpdater::Label::text

◆ units

TranslatableString RulerUpdater::Label::units

◆ value

double RulerUpdater::Label::value

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