Audacity 3.2.0
|
Used to display a Ruler. More...
#include <Ruler.h>
Classes | |
struct | Cache |
struct | TickLengths |
Public Member Functions | |
Ruler (const RulerUpdater &updater, const RulerFormat &format) | |
~Ruler () | |
void | SetBounds (int left, int top, int right, int bottom) |
void | SetOrientation (int orient) |
void | SetRange (double min, double max) |
void | SetRange (double min, double max, double hiddenMin, double hiddenMax) |
void | SetUpdater (const RulerUpdater *pUpdater) |
void | SetTwoTone (bool twoTone) |
void | SetFormat (const RulerFormat *pFormat) |
void | SetUnits (const TranslatableString &units) |
void | SetDbMirrorValue (const double d) |
void | SetLabelEdges (bool labelEdges) |
void | SetFlip (bool flip) |
void | SetMinor (bool value) |
void | SetFonts (const wxFont &minorFont, const wxFont &majorFont, const wxFont &minorMinorFont) |
RulerStruct::Fonts | GetFonts () const |
void | SetNumberScale (const NumberScale &scale) |
void | SetTickLengths (const TickLengths &tLengths) |
void | OfflimitsPixels (int start, int end) |
void | GetMaxSize (wxCoord *width, wxCoord *height) |
void | Draw (wxDC &dc) const |
void | Draw (wxDC &dc, const Envelope *envelope) const |
void | DrawGrid (wxDC &dc, int length, bool minor=true, bool major=true, int xOffset=0, int yOffset=0) const |
void | SetTickColour (const wxColour &colour) |
void | Invalidate () |
Public Member Functions inherited from Observer::Publisher< RulerInvalidatedMessage > | |
Publisher (ExceptionPolicy *pPolicy=nullptr, Alloc a={}) | |
Constructor supporting type-erased custom allocation/deletion. More... | |
Publisher (Publisher &&)=default | |
Publisher & | operator= (Publisher &&)=default |
Subscription | Subscribe (Callback callback) |
Connect a callback to the Publisher; later-connected are called earlier. More... | |
Subscription | Subscribe (Object &obj, Return(Object::*callback)(Args...)) |
Overload of Subscribe takes an object and pointer-to-member-function. More... | |
Public Attributes | |
bool | mbTicksOnly |
bool | mbTicksAtExtremes |
Private Member Functions | |
void | ChooseFonts (wxDC &dc) const |
void | UpdateCache (wxDC &dc, const Envelope *envelope) const |
int | FindZero (const RulerUpdater::Labels &labels) const |
int | GetZeroPosition () const |
Private Attributes | |
RulerStruct | mRulerStruct |
TickLengths | mTickLengths |
wxColour | mTickColour |
wxPen | mPen |
std::unique_ptr< RulerStruct::Fonts > | mpUserFonts |
const RulerUpdater * | mpUpdater {} |
RulerUpdater::Bits | mUserBits |
std::unique_ptr< Cache > | mpCache |
bool | mbMinor |
bool | mTwoTone |
Additional Inherited Members | |
Public Types inherited from Observer::Publisher< RulerInvalidatedMessage > | |
using | message_type = RulerInvalidatedMessage |
using | CallbackReturn = std::conditional_t< true, void, bool > |
using | Callback = std::function< CallbackReturn(const RulerInvalidatedMessage &) > |
Type of functions that can be connected to the Publisher. More... | |
Static Public Attributes inherited from Observer::Publisher< RulerInvalidatedMessage > | |
static constexpr bool | notifies_all |
Protected Member Functions inherited from Observer::Publisher< RulerInvalidatedMessage > | |
CallbackReturn | Publish (const RulerInvalidatedMessage &message) |
Send a message to connected callbacks. More... | |
Used to display a Ruler.
This is a generic class which can be used to display just about any kind of ruler.
At a minimum, the user must specify the dimensions of the ruler, its orientation (horizontal or vertical), and the values displayed at the two ends of the ruler (min and max). By default, this class will display tick marks at reasonable round numbers and fractions, for example, 100, 50, 10, 5, 1, 0.5, 0.1, etc.
The class is designed to display a small handful of labeled Major ticks, and a few Minor ticks between each of these. Minor ticks are labeled if there is enough space. Labels will never run into each other.
In addition to Real numbers, the Ruler currently supports two other formats for its display:
Integer - never shows tick marks for fractions of an integer
Time - Assumes values represent seconds, and labels the tick marks in "HH:MM:SS" format, e.g. 4000 seconds becomes "1:06:40", for example. Will display fractions of a second, and tick marks are all reasonable round numbers for time (i.e. 15 seconds, 30 seconds, etc.)
Ruler::Ruler | ( | const RulerUpdater & | updater, |
const RulerFormat & | format | ||
) |
Definition at line 66 of file Ruler.cpp.
References ThemeBase::Colour(), anonymous_namespace{ExportPCM.cpp}::format, mbMinor, mbTicksAtExtremes, mbTicksOnly, mPen, mTickColour, mTickLengths, mTwoTone, SetFormat(), SetUpdater(), theTheme, and updater.
Ruler::~Ruler | ( | ) |
|
private |
Definition at line 354 of file Ruler.cpp.
References anonymous_namespace{Ruler.cpp}::FindFontHeights(), MaxPixelHeight, RulerStruct::mBottom, min(), MinPixelHeight, RulerStruct::mOrientation, RulerStruct::mpFonts, mpUserFonts, mRulerStruct, and RulerStruct::mTop.
Referenced by GetFonts().
void Ruler::Draw | ( | wxDC & | dc | ) | const |
Definition at line 441 of file Ruler.cpp.
References Draw().
Referenced by WaveChannelVRulerControls::DoDraw(), AdornedRulerPanel::DoDrawMarks(), Draw(), anonymous_namespace{TimeTrackView.cpp}::DrawHorzRulerAndCurve(), MeterPanel::OnPaint(), and RulerPanel::OnPaint().
void Ruler::Draw | ( | wxDC & | dc, |
const Envelope * | envelope | ||
) | const |
Definition at line 446 of file Ruler.cpp.
References label, AColor::Line(), Ruler::TickLengths::majorLength, mbMinor, RulerStruct::mBottom, mbTicksAtExtremes, mbTicksOnly, RulerStruct::mFlip, Ruler::TickLengths::minorLength, Ruler::TickLengths::minorMinorLength, RulerStruct::mLeft, RulerStruct::mLength, RulerStruct::mOrientation, mpCache, mPen, RulerStruct::mpFonts, RulerStruct::mRight, mRulerStruct, mTickColour, mTickLengths, RulerStruct::mTop, mTwoTone, and UpdateCache().
void Ruler::DrawGrid | ( | wxDC & | dc, |
int | length, | ||
bool | minor = true , |
||
bool | major = true , |
||
int | xOffset = 0 , |
||
int | yOffset = 0 |
||
) | const |
Definition at line 530 of file Ruler.cpp.
References GetZeroPosition(), label, AColor::Line(), mbMinor, RulerStruct::mOrientation, mpCache, mRulerStruct, and UpdateCache().
Referenced by FrequencyPlotDialog::DrawPlot(), EqualizationPanel::OnPaint(), and EffectScienFilterPanel::OnPaint().
|
private |
Definition at line 588 of file Ruler.cpp.
References details::begin(), details::end(), and label.
Referenced by GetZeroPosition().
auto Ruler::GetFonts | ( | ) | const |
Definition at line 431 of file Ruler.cpp.
References ChooseFonts(), RulerStruct::mpFonts, and mRulerStruct.
void Ruler::GetMaxSize | ( | wxCoord * | width, |
wxCoord * | height | ||
) |
Definition at line 612 of file Ruler.cpp.
References mpCache, and UpdateCache().
Referenced by FrequencyPlotDialog::DrawPlot(), AdornedRulerPanel::GetMaxSize(), MeterPanel::SetActiveStyle(), EffectScienFilter::TransferGraphLimitsFromWindow(), and EqualizationUI::UpdateRuler().
|
private |
Definition at line 601 of file Ruler.cpp.
References FindZero(), and mpCache.
Referenced by DrawGrid().
void Ruler::Invalidate | ( | ) |
Definition at line 317 of file Ruler.cpp.
References RulerStruct::mBottom, RulerStruct::mLeft, RulerStruct::mLength, RulerStruct::mOrientation, mpCache, RulerStruct::mRight, mRulerStruct, RulerStruct::mTop, and Observer::Publisher< RulerInvalidatedMessage >::Publish().
Referenced by anonymous_namespace{TimeTrackView.cpp}::DrawHorzRulerAndCurve(), ProjectTimeRuler::Impl::Impl(), AdornedRulerPanel::InvalidateRuler(), OfflimitsPixels(), SetBounds(), SetDbMirrorValue(), SetFlip(), SetFonts(), SetFormat(), SetLabelEdges(), AdornedRulerPanel::SetLeftOffset(), SetNumberScale(), SetOrientation(), SetRange(), SetTickLengths(), SetUnits(), and SetUpdater().
void Ruler::OfflimitsPixels | ( | int | start, |
int | end | ||
) |
Definition at line 274 of file Ruler.cpp.
References details::end(), Invalidate(), RulerStruct::mBottom, RulerStruct::mLeft, RulerStruct::mLength, RulerStruct::mOrientation, RulerStruct::mRight, mRulerStruct, RulerStruct::mTop, mUserBits, size, and anonymous_namespace{NoteTrack.cpp}::swap().
Referenced by MeterPanel::HandleLayout().
void Ruler::SetBounds | ( | int | left, |
int | top, | ||
int | right, | ||
int | bottom | ||
) |
Definition at line 304 of file Ruler.cpp.
References Invalidate(), RulerStruct::mBottom, RulerStruct::mLeft, RulerStruct::mRight, mRulerStruct, and RulerStruct::mTop.
Referenced by RulerPanel::DoSetSize(), anonymous_namespace{TimeTrackView.cpp}::DrawHorzRulerAndCurve(), MeterPanel::HandleLayout(), MeterPanel::SetActiveStyle(), AdornedRulerPanel::UpdateRects(), and NoteTrackVRulerControls::UpdateRuler().
void Ruler::SetDbMirrorValue | ( | const double | d | ) |
Definition at line 132 of file Ruler.cpp.
References Invalidate(), RulerStruct::mDbMirrorValue, and mRulerStruct.
void Ruler::SetFlip | ( | bool | flip | ) |
Definition at line 192 of file Ruler.cpp.
References Invalidate(), RulerStruct::mFlip, and mRulerStruct.
Referenced by anonymous_namespace{TimeTrackView.cpp}::DrawHorzRulerAndCurve().
void Ruler::SetFonts | ( | const wxFont & | minorFont, |
const wxFont & | majorFont, | ||
const wxFont & | minorMinorFont | ||
) |
Definition at line 231 of file Ruler.cpp.
References anonymous_namespace{Ruler.cpp}::FindFontHeights(), Invalidate(), RulerStruct::mpFonts, mpUserFonts, and mRulerStruct.
void Ruler::SetFormat | ( | const RulerFormat * | pFormat | ) |
Definition at line 104 of file Ruler.cpp.
References Invalidate(), RulerStruct::mpRulerFormat, and mRulerStruct.
Referenced by FrequencyPlotDialog::DrawPlot(), Ruler(), and MeterPanel::SetActiveStyle().
void Ruler::SetLabelEdges | ( | bool | labelEdges | ) |
Definition at line 179 of file Ruler.cpp.
References Invalidate(), RulerStruct::mLabelEdges, and mRulerStruct.
Referenced by AdornedRulerPanel::AdornedRulerPanel(), and TimeTrackView::Draw().
void Ruler::SetMinor | ( | bool | value | ) |
void Ruler::SetNumberScale | ( | const NumberScale & | scale | ) |
Definition at line 247 of file Ruler.cpp.
References Invalidate(), RulerStruct::mNumberScale, and mRulerStruct.
void Ruler::SetOrientation | ( | int | orient | ) |
Definition at line 141 of file Ruler.cpp.
References Invalidate(), RulerStruct::mOrientation, and mRulerStruct.
Referenced by MeterPanel::SetActiveStyle().
void Ruler::SetRange | ( | double | min, |
double | max | ||
) |
Definition at line 152 of file Ruler.cpp.
References min(), and SetRange().
Referenced by AdornedRulerPanel::DoDrawMarks(), anonymous_namespace{TimeTrackView.cpp}::DrawHorzRulerAndCurve(), FrequencyPlotDialog::DrawPlot(), EqualizationUI::OnLinFreq(), MeterPanel::SetActiveStyle(), SetRange(), EffectScienFilter::TransferGraphLimitsFromWindow(), EqualizationUI::UpdateDraw(), EqualizationUI::UpdateGraphic(), and EqualizationUI::UpdateRuler().
void Ruler::SetRange | ( | double | min, |
double | max, | ||
double | hiddenMin, | ||
double | hiddenMax | ||
) |
Definition at line 157 of file Ruler.cpp.
References Invalidate(), RulerStruct::mHiddenMax, RulerStruct::mHiddenMin, min(), RulerStruct::mMax, RulerStruct::mMin, and mRulerStruct.
|
inline |
Definition at line 135 of file Ruler.h.
Referenced by WaveChannelVRulerControls::DoDraw(), AdornedRulerPanel::DoDrawMarks(), anonymous_namespace{TimeTrackView.cpp}::DrawHorzRulerAndCurve(), MeterPanel::OnPaint(), and RulerPanel::SetTickColour().
void Ruler::SetTickLengths | ( | const TickLengths & | tLengths | ) |
Definition at line 255 of file Ruler.cpp.
References Invalidate(), Ruler::TickLengths::majorLength, Ruler::TickLengths::minorLength, Ruler::TickLengths::minorMinorLength, and mTickLengths.
Referenced by AdornedRulerPanel::DoDrawMarks().
void Ruler::SetTwoTone | ( | bool | twoTone | ) |
void Ruler::SetUnits | ( | const TranslatableString & | units | ) |
Definition at line 120 of file Ruler.cpp.
References Invalidate(), mRulerStruct, and RulerStruct::mUnits.
Referenced by FrequencyPlotDialog::DrawPlot().
void Ruler::SetUpdater | ( | const RulerUpdater * | pUpdater | ) |
Definition at line 112 of file Ruler.cpp.
References Invalidate(), mpUpdater, and anonymous_namespace{LogWindow.cpp}::pUpdater.
Referenced by FrequencyPlotDialog::DrawPlot(), EqualizationUI::OnLinFreq(), Ruler(), EqualizationUI::UpdateDraw(), and EqualizationUI::UpdateGraphic().
|
private |
Definition at line 393 of file Ruler.cpp.
Referenced by Draw(), DrawGrid(), and GetMaxSize().
|
private |
Definition at line 174 of file Ruler.h.
Referenced by Draw(), DrawGrid(), Ruler(), and SetMinor().
bool Ruler::mbTicksAtExtremes |
|
mutableprivate |
Definition at line 167 of file Ruler.h.
Referenced by Draw(), DrawGrid(), GetMaxSize(), GetZeroPosition(), and Invalidate().
|
private |
|
private |
Definition at line 162 of file Ruler.h.
Referenced by SetUpdater().
|
private |
Definition at line 160 of file Ruler.h.
Referenced by ChooseFonts(), and SetFonts().
|
private |
Definition at line 153 of file Ruler.h.
Referenced by ChooseFonts(), Draw(), DrawGrid(), GetFonts(), Invalidate(), OfflimitsPixels(), SetBounds(), SetDbMirrorValue(), SetFlip(), SetFonts(), SetFormat(), SetLabelEdges(), SetNumberScale(), SetOrientation(), SetRange(), and SetUnits().
|
private |
|
private |
Definition at line 154 of file Ruler.h.
Referenced by Draw(), Ruler(), and SetTickLengths().
|
private |
Definition at line 175 of file Ruler.h.
Referenced by Draw(), Ruler(), and SetTwoTone().
|
private |
Definition at line 164 of file Ruler.h.
Referenced by OfflimitsPixels().