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 74 of file TimeTrackView.cpp.

77{
78 auto &dc = context.dc;
79 const auto artist = TrackArtist::Get( context );
80 const auto &zoomInfo = *artist->pZoomInfo;
81
82 bool highlight = false;
83#ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING
84 auto target = dynamic_cast<EnvelopeHandle*>(context.target.get());
85 highlight = target && target->GetEnvelope() == track.GetEnvelope();
86#endif
87
88 double min = zoomInfo.PositionToTime(0);
89 double max = zoomInfo.PositionToTime(r.width);
90 if (min > max)
91 {
92 wxASSERT(false);
93 min = max;
94 }
95
96 AColor::UseThemeColour( &dc, clrUnselected );
97 dc.DrawRectangle(r);
98
99 //copy this rectangle away for future use.
100 wxRect mid = r;
101
102 // Draw the Ruler
103 ruler.SetBounds(r.x, r.y, r.x + r.width - 1, r.y + r.height - 1);
104 ruler.SetRange(min, max);
105 ruler.SetFlip(true); // tick marks at top of track.
106 ruler.Invalidate(); // otherwise does not redraw.
107 ruler.SetTickColour( theTheme.Colour( clrTrackPanelText ));
108 ruler.Draw(dc, track.GetEnvelope());
109
110 Doubles envValues{ size_t(mid.width) };
112 0, 0, envValues.get(), mid.width, 0, zoomInfo);
113
114 wxPen &pen = highlight ? AColor::uglyPen : AColor::envelopePen;
115 dc.SetPen( pen );
116
117 auto rangeLower = track.GetRangeLower(), rangeUpper = track.GetRangeUpper();
118 double logLower = log(std::max(1.0e-7, rangeLower)),
119 logUpper = log(std::max(1.0e-7, rangeUpper));
120
121 for (int x = 0; x < mid.width; x++)
122 {
123 double y;
124 if ( track.GetDisplayLog() )
125 y = (double)mid.height * (logUpper - log(envValues[x])) / (logUpper - logLower);
126 else
127 y = (double)mid.height * (rangeUpper - envValues[x]) / (rangeUpper - rangeLower);
128 int thisy = r.y + (int)y;
129 AColor::Line(dc, mid.x + x, thisy - 1, mid.x + x, thisy+2);
130 }
131}
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:194
static wxPen uglyPen
Definition: AColor.h:140
static wxPen envelopePen
Definition: AColor.h:116
static void UseThemeColour(wxDC *dc, int iBrush, int iPen=-1, int alpha=255)
Definition: AColor.cpp:354
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:135
void SetFlip(bool flip)
Definition: Ruler.cpp:192
void Draw(wxDC &dc) const
Definition: Ruler.cpp:441
void SetBounds(int left, int top, int right, int bottom)
Definition: Ruler.cpp:304
void SetRange(double min, double max)
Definition: Ruler.cpp:152
void Invalidate()
Definition: Ruler.cpp:317
wxColour & Colour(int iIndex)
BoundedEnvelope * GetEnvelope()
Definition: TimeTrack.h:84
bool GetDisplayLog() const
Definition: TimeTrack.h:95
double GetRangeLower() const
Definition: TimeTrack.cpp:100
double GetRangeUpper() const
Definition: TimeTrack.cpp:105
static TrackArtist * Get(TrackPanelDrawingContext &)
Definition: TrackArtist.cpp:81

References ThemeBase::Colour(), TrackPanelDrawingContext::dc, Ruler::Draw(), AColor::envelopePen, TrackArtist::Get(), TimeTrack::GetDisplayLog(), TimeTrack::GetEnvelope(), EnvelopeHandle::GetEnvelope(), CommonChannelView::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 133 of file TimeTrackView.cpp.

136{
137 // Ruler and curve...
138 DrawHorzRulerAndCurve( context, rect, track, ruler );
139
140 // ... then the control points
141 wxRect envRect = rect;
142 envRect.height -= 2;
143 double lower = track.GetRangeLower(), upper = track.GetRangeUpper();
144 const auto artist = TrackArtist::Get( context );
145 const auto dbRange = artist->mdBrange;
146 if(track.GetDisplayLog()) {
147 // MB: silly way to undo the work of GetWaveYPos while still getting a logarithmic scale
148 lower = LINEAR_TO_DB(std::max(1.0e-7, lower)) / dbRange + 1.0;
149 upper = LINEAR_TO_DB(std::max(1.0e-7, upper)) / dbRange + 1.0;
150 }
152 context, envRect,
153 track.GetDisplayLog(), dbRange, lower, upper, false );
154}
#define LINEAR_TO_DB(x)
Definition: MemoryX.h:339
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: