![]() |
Audacity 3.2.0
|
Used to display a Ruler. More...
#include <Ruler.h>
Classes | |
struct | Cache |
struct | Fonts |
class | Label |
An array of these created by the Ruler is used to determine what and where text annotations to the numbers on the Ruler get drawn. More... | |
struct | TickSizes |
struct | Updater |
Public Types | |
enum | RulerFormat { IntFormat , RealFormat , RealLogFormat , TimeFormat , LinearDBFormat } |
Public Member Functions | |
Ruler () | |
~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 | SetTwoTone (bool twoTone) |
void | SetFormat (RulerFormat format) |
void | SetUnits (const TranslatableString &units) |
void | SetDbMirrorValue (const double d) |
void | SetLog (bool log) |
void | SetSpacing (int spacing) |
void | SetLabelEdges (bool labelEdges) |
void | SetFlip (bool flip) |
void | SetMinor (bool value) |
void | SetFonts (const wxFont &minorFont, const wxFont &majorFont, const wxFont &minorMinorFont) |
Fonts | GetFonts () const |
void | SetNumberScale (const NumberScale &scale) |
void | OfflimitsPixels (int start, int end) |
void | GetMaxSize (wxCoord *width, wxCoord *height) |
void | SetCustomMode (bool value) |
void | SetCustomMajorLabels (const TranslatableStrings &labels, int start, int step) |
void | SetCustomMinorLabels (const TranslatableStrings &labels, int start, int step) |
void | SetUseZoomInfo (int leftOffset, const ZoomInfo *zoomInfo) |
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 Attributes | |
bool | mbTicksOnly |
bool | mbTicksAtExtremes |
Private Types | |
using | Labels = std::vector< Label > |
using | Bits = std::vector< bool > |
Private Member Functions | |
void | ChooseFonts (wxDC &dc) const |
void | UpdateCache (wxDC &dc, const Envelope *envelope) const |
int | FindZero (const Labels &labels) const |
int | GetZeroPosition () const |
Static Private Member Functions | |
static std::pair< wxRect, Label > | MakeTick (Label lab, wxDC &dc, wxFont font, std::vector< bool > &bits, int left, int top, int spacing, int lead, bool flip, int orientation) |
Private Attributes | |
wxColour | mTickColour |
wxPen | mPen |
int | mLeft |
int | mTop |
int | mRight |
int | mBottom |
int | mLength |
std::unique_ptr< Fonts > | mpUserFonts |
std::unique_ptr< Fonts > | mpFonts |
double | mMin |
double | mMax |
double | mHiddenMin |
double | mHiddenMax |
Bits | mUserBits |
std::unique_ptr< Cache > | mpCache |
int | mOrientation |
int | mSpacing |
double | mDbMirrorValue |
bool | mHasSetSpacing |
bool | mLabelEdges |
RulerFormat | mFormat |
bool | mLog |
bool | mFlip |
bool | mCustom |
bool | mbMinor |
TranslatableString | mUnits |
bool | mTwoTone |
const ZoomInfo * | mUseZoomInfo |
int | mLeftOffset |
NumberScale | mNumberScale |
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.)
|
private |
|
private |
enum Ruler::RulerFormat |
Enumerator | |
---|---|
IntFormat | |
RealFormat | |
RealLogFormat | |
TimeFormat | |
LinearDBFormat |
Ruler::Ruler | ( | ) |
Definition at line 79 of file Ruler.cpp.
References ThemeBase::Colour(), mbMinor, mBottom, mbTicksAtExtremes, mbTicksOnly, mCustom, mDbMirrorValue, mFlip, mFormat, mHasSetSpacing, mHiddenMax, mHiddenMin, mLabelEdges, mLeft, mLength, mLog, mMax, mMin, mOrientation, mPen, mRight, mSpacing, mTickColour, mTop, mTwoTone, mUseZoomInfo, RealFormat, and theTheme.
Ruler::~Ruler | ( | ) |
Definition at line 121 of file Ruler.cpp.
References Invalidate().
|
private |
Definition at line 1355 of file Ruler.cpp.
References Ruler::Updater::ChooseFonts(), MaxPixelHeight, mBottom, mOrientation, mpFonts, mpUserFonts, and mTop.
Referenced by GetFonts(), and UpdateCache().
void Ruler::Draw | ( | wxDC & | dc | ) | const |
Definition at line 1428 of file Ruler.cpp.
References Draw().
Referenced by WaveTrackVRulerControls::DoDraw(), AdornedRulerPanel::DoDrawMarks(), Draw(), anonymous_namespace{TimeTrackView.cpp}::DrawHorzRulerAndCurve(), EffectCompressorPanel::OnPaint(), MeterPanel::OnPaint(), RulerPanel::OnPaint(), and anonymous_namespace{Printing.cpp}::AudacityPrintout::OnPrintPage().
void Ruler::Draw | ( | wxDC & | dc, |
const Envelope * | envelope | ||
) | const |
Definition at line 1433 of file Ruler.cpp.
References TranslatableString::empty(), label, AColor::Line(), mbMinor, mBottom, mbTicksAtExtremes, mbTicksOnly, mFlip, mLeft, mLength, mOrientation, mpCache, mPen, mpFonts, mRight, mTickColour, 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 1521 of file Ruler.cpp.
References GetZeroPosition(), label, AColor::Line(), mbMinor, mOrientation, mpCache, and UpdateCache().
Referenced by FrequencyPlotDialog::DrawPlot(), EqualizationPanel::OnPaint(), and EffectScienFilterPanel::OnPaint().
|
private |
Definition at line 1579 of file Ruler.cpp.
References PackedArray::begin(), PackedArray::end(), and label.
Referenced by GetZeroPosition().
auto Ruler::GetFonts | ( | ) | const |
Definition at line 1418 of file Ruler.cpp.
References ChooseFonts(), and mpFonts.
void Ruler::GetMaxSize | ( | wxCoord * | width, |
wxCoord * | height | ||
) |
Definition at line 1603 of file Ruler.cpp.
References mpCache, and UpdateCache().
Referenced by FrequencyPlotDialog::DrawPlot(), AdornedRulerPanel::GetMaxSize(), EffectCompressorPanel::OnPaint(), RulerPanel::RulerPanel(), MeterPanel::SetActiveStyle(), EffectScienFilter::TransferGraphLimitsFromWindow(), and EqualizationUI::UpdateRuler().
|
private |
Definition at line 1592 of file Ruler.cpp.
References FindZero(), and mpCache.
Referenced by DrawGrid().
void Ruler::Invalidate | ( | ) |
Definition at line 345 of file Ruler.cpp.
References mBottom, mLeft, mLength, mOrientation, mpCache, mRight, and mTop.
Referenced by anonymous_namespace{TimeTrackView.cpp}::DrawHorzRulerAndCurve(), AdornedRulerPanel::InvalidateRuler(), OfflimitsPixels(), SetBounds(), SetCustomMode(), SetDbMirrorValue(), SetFlip(), SetFonts(), SetFormat(), SetLabelEdges(), SetLog(), SetNumberScale(), SetOrientation(), SetRange(), SetSpacing(), SetUnits(), SetUseZoomInfo(), and ~Ruler().
|
staticprivate |
Definition at line 758 of file Ruler.cpp.
References str.
Referenced by Ruler::Updater::Tick(), and Ruler::Updater::TickCustom().
void Ruler::OfflimitsPixels | ( | int | start, |
int | end | ||
) |
Definition at line 302 of file Ruler.cpp.
References PackedArray::end(), Invalidate(), mBottom, mLeft, mLength, mOrientation, mRight, 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 332 of file Ruler.cpp.
References Invalidate(), mBottom, mLeft, mRight, and mTop.
Referenced by RulerPanel::DoSetSize(), anonymous_namespace{TimeTrackView.cpp}::DrawHorzRulerAndCurve(), MeterPanel::HandleLayout(), EffectCompressorPanel::OnPaint(), anonymous_namespace{Printing.cpp}::AudacityPrintout::OnPrintPage(), RulerPanel::RulerPanel(), MeterPanel::SetActiveStyle(), AdornedRulerPanel::UpdateRects(), and NoteTrackVRulerControls::UpdateRuler().
void Ruler::SetCustomMajorLabels | ( | const TranslatableStrings & | labels, |
int | start, | ||
int | step | ||
) |
void Ruler::SetCustomMinorLabels | ( | const TranslatableStrings & | labels, |
int | start, | ||
int | step | ||
) |
void Ruler::SetCustomMode | ( | bool | value | ) |
Definition at line 1619 of file Ruler.cpp.
References Invalidate(), and mCustom.
void Ruler::SetDbMirrorValue | ( | const double | d | ) |
Definition at line 165 of file Ruler.cpp.
References Invalidate(), and mDbMirrorValue.
void Ruler::SetFlip | ( | bool | flip | ) |
Definition at line 239 of file Ruler.cpp.
References Invalidate(), and mFlip.
Referenced by anonymous_namespace{TimeTrackView.cpp}::DrawHorzRulerAndCurve(), EffectCompressorPanel::OnPaint(), and RulerPanel::RulerPanel().
void Ruler::SetFonts | ( | const wxFont & | minorFont, |
const wxFont & | majorFont, | ||
const wxFont & | minorMinorFont | ||
) |
Definition at line 278 of file Ruler.cpp.
References anonymous_namespace{Ruler.cpp}::FindFontHeights(), Invalidate(), mpFonts, and mpUserFonts.
void Ruler::SetFormat | ( | RulerFormat | format | ) |
Definition at line 131 of file Ruler.cpp.
References format, Invalidate(), and mFormat.
Referenced by AdornedRulerPanel::AdornedRulerPanel(), FrequencyPlotDialog::DrawPlot(), EffectCompressorPanel::OnPaint(), anonymous_namespace{Printing.cpp}::AudacityPrintout::OnPrintPage(), RulerPanel::RulerPanel(), and MeterPanel::SetActiveStyle().
void Ruler::SetLabelEdges | ( | bool | labelEdges | ) |
Definition at line 226 of file Ruler.cpp.
References Invalidate(), and mLabelEdges.
Referenced by AdornedRulerPanel::AdornedRulerPanel(), anonymous_namespace{Printing.cpp}::AudacityPrintout::OnPrintPage(), and RulerPanel::RulerPanel().
void Ruler::SetLog | ( | bool | log | ) |
Definition at line 142 of file Ruler.cpp.
References Invalidate(), and mLog.
Referenced by FrequencyPlotDialog::DrawPlot(), EqualizationUI::OnLinFreq(), RulerPanel::RulerPanel(), EqualizationUI::UpdateDraw(), and EqualizationUI::UpdateGraphic().
void Ruler::SetMinor | ( | bool | value | ) |
void Ruler::SetNumberScale | ( | const NumberScale & | scale | ) |
Definition at line 294 of file Ruler.cpp.
References Invalidate(), and mNumberScale.
void Ruler::SetOrientation | ( | int | orient | ) |
Definition at line 174 of file Ruler.cpp.
References Invalidate(), mHasSetSpacing, mOrientation, and mSpacing.
Referenced by EffectCompressorPanel::OnPaint(), anonymous_namespace{Printing.cpp}::AudacityPrintout::OnPrintPage(), RulerPanel::RulerPanel(), and MeterPanel::SetActiveStyle().
void Ruler::SetRange | ( | double | min, |
double | max | ||
) |
Definition at line 188 of file Ruler.cpp.
References min(), and SetRange().
Referenced by AdornedRulerPanel::DoDrawMarks(), anonymous_namespace{TimeTrackView.cpp}::DrawHorzRulerAndCurve(), FrequencyPlotDialog::DrawPlot(), EqualizationUI::OnLinFreq(), EffectCompressorPanel::OnPaint(), anonymous_namespace{Printing.cpp}::AudacityPrintout::OnPrintPage(), RulerPanel::RulerPanel(), 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 193 of file Ruler.cpp.
References Invalidate(), mHiddenMax, mHiddenMin, min(), mMax, and mMin.
void Ruler::SetSpacing | ( | int | spacing | ) |
Definition at line 215 of file Ruler.cpp.
References Invalidate(), mHasSetSpacing, and mSpacing.
|
inline |
Definition at line 148 of file Ruler.h.
Referenced by WaveTrackVRulerControls::DoDraw(), AdornedRulerPanel::DoDrawMarks(), anonymous_namespace{TimeTrackView.cpp}::DrawHorzRulerAndCurve(), EffectCompressorPanel::OnPaint(), MeterPanel::OnPaint(), RulerPanel::RulerPanel(), and RulerPanel::SetTickColour().
void Ruler::SetTwoTone | ( | bool | twoTone | ) |
Definition at line 126 of file Ruler.cpp.
References mTwoTone.
Referenced by AdornedRulerPanel::UpdatePrefs().
void Ruler::SetUnits | ( | const TranslatableString & | units | ) |
Definition at line 153 of file Ruler.cpp.
References Invalidate(), and mUnits.
Referenced by FrequencyPlotDialog::DrawPlot(), EffectCompressorPanel::OnPaint(), and RulerPanel::RulerPanel().
void Ruler::SetUseZoomInfo | ( | int | leftOffset, |
const ZoomInfo * | zoomInfo | ||
) |
Definition at line 1680 of file Ruler.cpp.
References Invalidate(), mLeftOffset, and mUseZoomInfo.
Referenced by AdornedRulerPanel::AdornedRulerPanel(), and AdornedRulerPanel::SetLeftOffset().
|
private |
Definition at line 1364 of file Ruler.cpp.
References ChooseFonts(), mCustom, mLength, mLog, mOrientation, mpCache, mUserBits, and mUseZoomInfo.
Referenced by Draw(), DrawGrid(), and GetMaxSize().
|
private |
Definition at line 219 of file Ruler.h.
Referenced by Draw(), DrawGrid(), Ruler(), and SetMinor().
|
private |
Definition at line 184 of file Ruler.h.
Referenced by ChooseFonts(), Draw(), Invalidate(), OfflimitsPixels(), Ruler(), SetBounds(), and Ruler::Updater::UpdateLinear().
bool Ruler::mbTicksAtExtremes |
Definition at line 178 of file Ruler.h.
Referenced by Draw(), Ruler(), and RulerPanel::RulerPanel().
|
private |
Definition at line 218 of file Ruler.h.
Referenced by Ruler(), SetCustomMode(), Ruler::Updater::Update(), and UpdateCache().
|
private |
Definition at line 212 of file Ruler.h.
Referenced by Ruler(), SetDbMirrorValue(), and Ruler::Updater::UpdateLinear().
|
private |
Definition at line 217 of file Ruler.h.
Referenced by Draw(), Ruler(), SetFlip(), Ruler::Updater::TickCustom(), and Ruler::Updater::Update().
|
private |
Definition at line 215 of file Ruler.h.
Referenced by Ruler(), SetFormat(), Ruler::Updater::UpdateLinear(), and Ruler::Updater::UpdateNonlinear().
|
private |
Definition at line 213 of file Ruler.h.
Referenced by Ruler(), SetOrientation(), and SetSpacing().
|
private |
Definition at line 191 of file Ruler.h.
Referenced by Ruler(), SetRange(), Ruler::Updater::UpdateLinear(), and Ruler::Updater::UpdateNonlinear().
|
private |
Definition at line 191 of file Ruler.h.
Referenced by Ruler(), SetRange(), Ruler::Updater::UpdateLinear(), and Ruler::Updater::UpdateNonlinear().
|
private |
Definition at line 214 of file Ruler.h.
Referenced by Ruler(), SetLabelEdges(), and Ruler::Updater::UpdateLinear().
|
private |
Definition at line 184 of file Ruler.h.
Referenced by Draw(), Invalidate(), OfflimitsPixels(), Ruler(), SetBounds(), Ruler::Updater::TickCustom(), and Ruler::Updater::Update().
|
private |
Definition at line 223 of file Ruler.h.
Referenced by SetUseZoomInfo(), and Ruler::Updater::UpdateLinear().
|
private |
Definition at line 185 of file Ruler.h.
Referenced by Draw(), Invalidate(), OfflimitsPixels(), Ruler(), UpdateCache(), Ruler::Updater::UpdateCustom(), Ruler::Updater::UpdateLinear(), and Ruler::Updater::UpdateNonlinear().
|
private |
Definition at line 216 of file Ruler.h.
Referenced by Ruler(), SetLog(), Ruler::Updater::Update(), and UpdateCache().
|
private |
Definition at line 190 of file Ruler.h.
Referenced by Ruler(), SetRange(), Ruler::Updater::UpdateLinear(), and Ruler::Updater::UpdateNonlinear().
|
private |
Definition at line 190 of file Ruler.h.
Referenced by Ruler(), SetRange(), Ruler::Updater::UpdateLinear(), and Ruler::Updater::UpdateNonlinear().
|
private |
Definition at line 225 of file Ruler.h.
Referenced by SetNumberScale(), and Ruler::Updater::UpdateNonlinear().
|
private |
Definition at line 210 of file Ruler.h.
Referenced by ChooseFonts(), Draw(), DrawGrid(), Invalidate(), OfflimitsPixels(), Ruler(), SetOrientation(), Ruler::Updater::TickCustom(), Ruler::Updater::Update(), UpdateCache(), Ruler::Updater::UpdateLinear(), and Ruler::Updater::UpdateNonlinear().
|
mutableprivate |
Definition at line 203 of file Ruler.h.
Referenced by Draw(), DrawGrid(), GetMaxSize(), GetZeroPosition(), Invalidate(), and UpdateCache().
|
private |
|
mutableprivate |
Definition at line 188 of file Ruler.h.
Referenced by ChooseFonts(), Draw(), GetFonts(), and SetFonts().
|
private |
Definition at line 187 of file Ruler.h.
Referenced by ChooseFonts(), and SetFonts().
|
private |
Definition at line 184 of file Ruler.h.
Referenced by Draw(), Invalidate(), OfflimitsPixels(), Ruler(), SetBounds(), and Ruler::Updater::UpdateLinear().
|
private |
Definition at line 211 of file Ruler.h.
Referenced by Ruler(), SetOrientation(), SetSpacing(), and Ruler::Updater::TickCustom().
|
private |
|
private |
Definition at line 184 of file Ruler.h.
Referenced by ChooseFonts(), Draw(), Invalidate(), OfflimitsPixels(), Ruler(), SetBounds(), Ruler::Updater::TickCustom(), and Ruler::Updater::Update().
|
private |
Definition at line 221 of file Ruler.h.
Referenced by Draw(), Ruler(), and SetTwoTone().
|
private |
Definition at line 220 of file Ruler.h.
Referenced by SetUnits().
|
private |
Definition at line 193 of file Ruler.h.
Referenced by OfflimitsPixels(), and UpdateCache().
|
private |
Definition at line 222 of file Ruler.h.
Referenced by Ruler(), SetUseZoomInfo(), and UpdateCache().