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#ifdef EXPERIMENTAL_THEMING
94 dc.SetTextForeground(altColor ? theTheme.Colour(clrTextNegativeNumbers) : c);
95#else
96 dc.SetTextForeground(altColor ? *wxBLUE : *wxBLACK);
97#endif
98 dc.SetBackgroundMode(wxTRANSPARENT);
99 if (dc.GetFont() == fonts->major) {
100 // Do not draw units as bolded
101 dc.DrawText(text->Translation(), lx, ly);
102 wxSize textSize = dc.GetTextExtent(text->Translation());
103 dc.SetFont(fonts->minor);
104 int unitX = lx + textSize.GetWidth();
105 dc.DrawText(units.Translation(), unitX, ly);
106 dc.SetFont(fonts->major);
107 }
108 else {
109 auto str = *text + units;
110 dc.DrawText(str.Translation(), lx, ly);
111 }
112 }
113}
#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: