Audacity 3.2.0
Functions
anonymous_namespace{TimeTrackView.cpp} Namespace Reference

Functions

void DrawHorzRulerAndCurve (TrackPanelDrawingContext &context, const wxRect &r, const TimeTrack &track, Ruler &ruler)
 
void DrawTimeTrack (TrackPanelDrawingContext &context, const TimeTrack &track, Ruler &ruler, const wxRect &rect)
 

Function Documentation

◆ DrawHorzRulerAndCurve()

void anonymous_namespace{TimeTrackView.cpp}::DrawHorzRulerAndCurve ( TrackPanelDrawingContext context,
const wxRect &  r,
const TimeTrack track,
Ruler ruler 
)

Definition at line 73 of file TimeTrackView.cpp.

76{
77 auto &dc = context.dc;
78 const auto artist = TrackArtist::Get( context );
79 const auto &zoomInfo = *artist->pZoomInfo;
80
81 bool highlight = false;
82#ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING
83 auto target = dynamic_cast<EnvelopeHandle*>(context.target.get());
84 highlight = target && target->GetEnvelope() == this->GetEnvelope();
85#endif
86
87 double min = zoomInfo.PositionToTime(0);
88 double max = zoomInfo.PositionToTime(r.width);
89 if (min > max)
90 {
91 wxASSERT(false);
92 min = max;
93 }
94
95 AColor::UseThemeColour( &dc, clrUnselected );
96 dc.DrawRectangle(r);
97
98 //copy this rectangle away for future use.
99 wxRect mid = r;
100
101 // Draw the Ruler
102 ruler.SetBounds(r.x, r.y, r.x + r.width - 1, r.y + r.height - 1);
103 ruler.SetRange(min, max);
104 ruler.SetFlip(true); // tick marks at top of track.
105 ruler.Invalidate(); // otherwise does not redraw.
106 ruler.SetTickColour( theTheme.Colour( clrTrackPanelText ));
107 ruler.Draw(dc, track.GetEnvelope());
108
109 Doubles envValues{ size_t(mid.width) };
111 0, 0, envValues.get(), mid.width, 0, zoomInfo );
112
113 wxPen &pen = highlight ? AColor::uglyPen : AColor::envelopePen;
114 dc.SetPen( pen );
115
116 auto rangeLower = track.GetRangeLower(), rangeUpper = track.GetRangeUpper();
117 double logLower = log(std::max(1.0e-7, rangeLower)),
118 logUpper = log(std::max(1.0e-7, rangeUpper));
119
120 for (int x = 0; x < mid.width; x++)
121 {
122 double y;
123 if ( track.GetDisplayLog() )
124 y = (double)mid.height * (logUpper - log(envValues[x])) / (logUpper - logLower);
125 else
126 y = (double)mid.height * (rangeUpper - envValues[x]) / (rangeUpper - rangeLower);
127 int thisy = r.y + (int)y;
128 AColor::Line(dc, mid.x + x, thisy - 1, mid.x + x, thisy+2);
129 }
130}
int min(int a, int b)
THEME_API Theme theTheme
Definition: Theme.cpp:82
static void Line(wxDC &dc, wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
Definition: AColor.cpp:187
static wxPen uglyPen
Definition: AColor.h:141
static wxPen envelopePen
Definition: AColor.h:115
static void UseThemeColour(wxDC *dc, int iBrush, int iPen=-1, int alpha=255)
Definition: AColor.cpp:372
static void GetEnvelopeValues(const Envelope &env, double aligned_time, double sampleDur, double *buffer, int bufferLen, int leftOffset, const ZoomInfo &zoomInfo)
Get many envelope points for pixel columns at once, but don't assume uniform time per pixel.
Envelope * GetEnvelope() const
void SetTickColour(const wxColour &colour)
Definition: Ruler.h:129
void SetFlip(bool flip)
Definition: Ruler.cpp:191
void Draw(wxDC &dc) const
Definition: Ruler.cpp:438
void SetBounds(int left, int top, int right, int bottom)
Definition: Ruler.cpp:303
void SetRange(double min, double max)
Definition: Ruler.cpp:151
void Invalidate()
Definition: Ruler.cpp:316
wxColour & Colour(int iIndex)
BoundedEnvelope * GetEnvelope()
Definition: TimeTrack.h:83
bool GetDisplayLog() const
Definition: TimeTrack.h:94
double GetRangeLower() const
Definition: TimeTrack.cpp:102
double GetRangeUpper() const
Definition: TimeTrack.cpp:107
static TrackArtist * Get(TrackPanelDrawingContext &)
Definition: TrackArtist.cpp:69

References ThemeBase::Colour(), TrackPanelDrawingContext::dc, Ruler::Draw(), AColor::envelopePen, TrackArtist::Get(), TimeTrack::GetDisplayLog(), TimeTrack::GetEnvelope(), EnvelopeHandle::GetEnvelope(), CommonTrackView::GetEnvelopeValues(), TimeTrack::GetRangeLower(), TimeTrack::GetRangeUpper(), Ruler::Invalidate(), AColor::Line(), min(), anonymous_namespace{TimeTrackVRulerControls.cpp}::ruler(), Ruler::SetBounds(), Ruler::SetFlip(), Ruler::SetRange(), Ruler::SetTickColour(), TrackPanelDrawingContext::target, theTheme, AColor::uglyPen, and AColor::UseThemeColour().

Referenced by DrawTimeTrack().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DrawTimeTrack()

void anonymous_namespace{TimeTrackView.cpp}::DrawTimeTrack ( TrackPanelDrawingContext context,
const TimeTrack track,
Ruler ruler,
const wxRect &  rect 
)

Definition at line 132 of file TimeTrackView.cpp.

135{
136 // Ruler and curve...
137 DrawHorzRulerAndCurve( context, rect, track, ruler );
138
139 // ... then the control points
140 wxRect envRect = rect;
141 envRect.height -= 2;
142 double lower = track.GetRangeLower(), upper = track.GetRangeUpper();
143 const auto artist = TrackArtist::Get( context );
144 const auto dbRange = artist->mdBrange;
145 if(track.GetDisplayLog()) {
146 // MB: silly way to undo the work of GetWaveYPos while still getting a logarithmic scale
147 lower = LINEAR_TO_DB(std::max(1.0e-7, lower)) / dbRange + 1.0;
148 upper = LINEAR_TO_DB(std::max(1.0e-7, upper)) / dbRange + 1.0;
149 }
151 context, envRect,
152 track.GetDisplayLog(), dbRange, lower, upper, false );
153}
#define LINEAR_TO_DB(x)
Definition: MemoryX.h:561
static void DrawPoints(const Envelope &env, TrackPanelDrawingContext &context, const wxRect &r, bool dB, double dBRange, float zoomMin, float zoomMax, bool mirrored, int origin=0)
void DrawHorzRulerAndCurve(TrackPanelDrawingContext &context, const wxRect &r, const TimeTrack &track, Ruler &ruler)

References DrawHorzRulerAndCurve(), EnvelopeEditor::DrawPoints(), TrackArtist::Get(), TimeTrack::GetDisplayLog(), TimeTrack::GetEnvelope(), TimeTrack::GetRangeLower(), TimeTrack::GetRangeUpper(), LINEAR_TO_DB, and anonymous_namespace{TimeTrackVRulerControls.cpp}::ruler().

Referenced by TimeTrackView::Draw().

Here is the call graph for this function:
Here is the caller graph for this function: