Audacity 3.2.0
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
CustomUpdaterPosition Class Referencefinal

#include <CustomUpdaterPosition.h>

Inheritance diagram for CustomUpdaterPosition:
[legend]
Collaboration diagram for CustomUpdaterPosition:
[legend]

Public Member Functions

 CustomUpdaterPosition ()=default
 
 ~CustomUpdaterPosition () override
 
- Public Member Functions inherited from CustomUpdater
 ~CustomUpdater () override
 
void Update (wxDC &dc, const Envelope *envelope, UpdateOutputs &allOutputs, const RulerStruct &context) const final
 
void SetData (RulerUpdater::Labels majorLabels, RulerUpdater::Labels minorLabels, RulerUpdater::Labels minorMinorLabels)
 
 RulerUpdater ()
 
- Public Member Functions inherited from RulerUpdater
 RulerUpdater ()
 
virtual ~RulerUpdater ()=0
 
virtual void Update (wxDC &dc, const Envelope *envelope, UpdateOutputs &allOutputs, const RulerStruct &context) const =0
 

Static Public Member Functions

static const CustomUpdaterPositionInstance ()
 

Protected Member Functions

bool TickCustom (wxDC &dc, int labelIdx, wxFont font, TickOutputs outputs, const RulerStruct &context) const override
 
virtual bool TickCustom (wxDC &dc, int labelIdx, wxFont font, TickOutputs outputs, const RulerStruct &context) const =0
 
- Protected Member Functions inherited from RulerUpdater
void BoxAdjust (UpdateOutputs &allOutputs, const RulerStruct &context) const
 

Additional Inherited Members

- Public Types inherited from RulerUpdater
using Labels = std::vector< Label >
 
using Bits = std::vector< bool >
 
- Static Protected Member Functions inherited from RulerUpdater
static std::pair< wxRect, LabelMakeTick (RulerUpdater::Label lab, wxDC &dc, wxFont font, std::vector< bool > &bits, int left, int top, int spacing, int lead, bool flip, int orientation)
 
- Protected Attributes inherited from CustomUpdater
RulerUpdater::Labels mMajorLabels
 
RulerUpdater::Labels mMinorLabels
 
RulerUpdater::Labels mMinorMinorLabels
 

Detailed Description

Definition at line 17 of file CustomUpdaterPosition.h.

Constructor & Destructor Documentation

◆ CustomUpdaterPosition()

CustomUpdaterPosition::CustomUpdaterPosition ( )
default

◆ ~CustomUpdaterPosition()

CustomUpdaterPosition::~CustomUpdaterPosition ( )
overridedefault

Member Function Documentation

◆ Instance()

const CustomUpdaterPosition & CustomUpdaterPosition::Instance ( )
static

Definition at line 15 of file CustomUpdaterPosition.cpp.

16{
17 static CustomUpdaterPosition instance;
18 return instance;
19}

◆ TickCustom()

bool CustomUpdaterPosition::TickCustom ( wxDC &  dc,
int  labelIdx,
wxFont  font,
TickOutputs  outputs,
const RulerStruct context 
) const
overrideprotectedvirtual

Implements CustomUpdater.

Definition at line 21 of file CustomUpdaterPosition.cpp.

25{
26 const int mLeft = context.mLeft;
27 const int mTop = context.mTop;
28 const int mOrientation = context.mOrientation;
29
30 const RulerStruct::Fonts& mFonts = *context.mpFonts;
31 // legacy behavior
32 const int spacing = (mOrientation == wxHORIZONTAL) ? 6 : 2;
33 const bool mFlip = context.mFlip;
34 const TranslatableString mUnits = context.mUnits;
35
36 // FIXME: We don't draw a tick if of end of our label arrays
37 // But we shouldn't have an array of labels.
38 if (labelIdx >= outputs.labels.size())
39 return false;
40
41 Label lab;
42
43 lab.value = 0.0;
44 lab.pos = outputs.labels[labelIdx].pos;
45 // Custom is flexible with text format
46 // We can assume they use the right format, but still append the right units.
47 lab.text = outputs.labels[labelIdx].text;
48 lab.units = mUnits;
49
50 auto result = MakeTick(
51 lab,
52 dc, font,
53 outputs.bits,
54 mLeft, mTop, spacing, mFonts.lead,
55 mFlip,
56 mOrientation);
57
58 if (!result.second.text)
59 // Always a non-empty optional
60 result.second.text = { TranslatableString{} };
61
62 auto& rect = result.first;
63 outputs.box.Union(rect);
64 outputs.labels[labelIdx] = (result.second);
65 return !rect.IsEmpty();
66}
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
int mOrientation
Definition: RulerUpdater.h:37

References RulerUpdater::TickOutputs::bits, RulerUpdater::TickOutputs::box, RulerUpdater::TickOutputs::labels, RulerStruct::Fonts::lead, RulerUpdater::MakeTick(), RulerStruct::mFlip, RulerStruct::mLeft, RulerStruct::mOrientation, RulerStruct::mpFonts, RulerStruct::mTop, RulerStruct::mUnits, RulerUpdater::Label::pos, RulerUpdater::Label::text, RulerUpdater::Label::units, and RulerUpdater::Label::value.

Here is the call graph for this function:

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