Audacity 3.2.0
WaveformView.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3Audacity: A Digital Audio Editor
4
5WaveformView.cpp
6
7Paul Licameli split from WaveChannelView.cpp
8
9**********************************************************************/
10
11
12#include "WaveformView.h"
13
14#include "WaveformAppearance.h"
15#include "ClipParameters.h"
16#include "WaveChannelView.h"
19
20#include "SampleHandle.h"
21#include "../../../ui/EnvelopeHandle.h"
22#include "../../../ui/TimeShiftHandle.h"
23#include "AColor.h"
24#include "Envelope.h"
25#include "../../../../EnvelopeEditor.h"
26#include "PendingTracks.h"
27#include "../../../../ProjectSettings.h"
28#include "SelectedRegion.h"
29#include "SyncLock.h"
30#include "../../../../TrackArt.h"
31#include "../../../../TrackArtist.h"
32#include "../../../../TrackPanelDrawingContext.h"
33#include "../../../../TrackPanelMouseEvent.h"
34#include "ViewInfo.h"
36#include "WaveClip.h"
37#include "WaveTrack.h"
38#include "WaveTrackUtilities.h"
39#include "../../../../WaveTrackLocation.h"
40#include "../../../../prefs/WaveformSettings.h"
41
42#include "FrameStatistics.h"
43
44#include <wx/graphics.h>
45#include <wx/dc.h>
46
47#include <wx/dcmemory.h>
51
52
55 { wxT("Waveform"), XXO("Wa&veform") }
56};
57
59
61
62std::vector<UIHandlePtr> WaveformView::DetailedHitTest(
63 const TrackPanelMouseState &st,
64 const AudacityProject *pProject, int currentTool, bool bMultiTool )
65{
66 auto &view = *this;
67 const auto pChannel = view.FindChannel<WaveChannel>();
68
70 st, pProject, currentTool, bMultiTool, pChannel);
71 auto &results = pair.second;
72
73 if (!pair.first) {
74 UIHandlePtr result;
75
76 if (bMultiTool) {
77 // Conditional hit tests
78 // If Tools toolbar were eliminated, we would keep these
79 // The priority of these, in case more than one might apply at one
80 // point, seems arbitrary
81 if (nullptr != (result = EnvelopeHandle::WaveChannelHitTest(
82 view.mEnvelopeHandle, st.state, st.rect,
83 pProject, pChannel)))
84 results.push_back(result);
85 if (nullptr != (result = TimeShiftHandle::HitTest(
86 view.mTimeShiftHandle, st.state, st.rect,
87 pChannel->GetTrack().SharedPointer())))
88 // This is the hit test on the "grips" drawn left and
89 // right in Multi only
90 results.push_back(result);
91 if (nullptr != (result = SampleHandle::HitTest(
92 view.mSampleHandle, st.state, st.rect,
93 pProject, pChannel)))
94 results.push_back(result);
95 }
96 else {
97 switch ( currentTool ) {
98 // Unconditional hits appropriate to the tool
99 // If tools toolbar were eliminated, we would eliminate these
101 auto &viewInfo = ViewInfo::Get(*pProject);
102 auto time =
103 viewInfo.PositionToTime(st.state.m_x, st.rect.GetX());
104 const auto envelope =
107 view.mEnvelopeHandle, envelope,
108 std::dynamic_pointer_cast<const Channel>(pChannel),
109 false);
110 break;
111 }
114 view.mSampleHandle, st.state, pChannel);
115 break;
116 default:
117 result = {};
118 break;
119 }
120 if (result)
121 results.push_back(result);
122 }
123 }
124
125 return std::move( results );
126}
127
128void WaveformView::DoSetMinimized( bool minimized )
129{
130 auto wt = FindWaveChannel();
131
132 bool bHalfWave;
133 gPrefs->Read(wxT("/GUI/CollapseToHalfWave"), &bHalfWave, false);
134 if (wt && bHalfWave) {
135 auto &cache = WaveformScale::Get(*wt);
136 if (minimized)
137 // Zoom to show fractionally more than the top half of the wave.
138 cache.SetDisplayBounds( -0.01f, 1.0f );
139 else
140 // Zoom out full
141 cache.SetDisplayBounds( -1.0f, 1.0f );
142 }
143
145}
146
147auto WaveformView::SubViewType() const -> const Type &
148{
149 return sType;
150}
151
152std::shared_ptr<ChannelVRulerControls> WaveformView::DoGetVRulerControls()
153{
154 return std::make_shared<WaveformVRulerControls>(shared_from_this());
155}
156
157namespace
158{
159
160
162{
163 const auto c = pen.GetColour();
164 return graphics::Color(c.Red(), c.Green(), c.Blue());
165}
166
168{
169 const auto c = brush.GetColour();
170 return graphics::Color(c.Red(), c.Green(), c.Blue());
171}
172
173
175{
176 uint8_t* Allocate(size_t width, size_t height) override
177 {
178 mImage = wxImage(width, height, false);
179 mBitmap = wxBitmap();
180 return mImage.GetData();
181 }
182
183 wxBitmap& GetBitmap()
184 {
185 if(!mBitmap.IsOk() && mImage.IsOk())
186 mBitmap = wxBitmap(mImage);
187 return mBitmap;
188 }
189
190 size_t Width() const override
191 {
192 return mImage.GetWidth();
193 }
194
195 size_t Height() const override
196 {
197 return mImage.GetHeight();
198 }
199
200private:
201 wxBitmap mBitmap;
203};
204
205
207 : public WaveClipListener
208{
209public:
210
211 static WaveformPainter& Get(const WaveClip& clip);
212
214 {
215 }
216
218 {
219 if (&clip != mWaveClip)
220 mChannelCaches.clear();
221
222 const auto nChannels = clip.NChannels();
223
224 if (mChannelCaches.size() == nChannels)
225 return *this;
226
227 mWaveClip = &clip;
228
229 mChannelCaches.reserve(nChannels);
230
231 for (auto channelIndex = 0; channelIndex < nChannels; ++channelIndex)
232 {
233 auto dataCache = std::make_shared<WaveDataCache>(clip, channelIndex);
234
235 auto bitmapCache = std::make_unique<WaveBitmapCache>(
236 dataCache,
237 [] { return std::make_unique<WaveBitmapCacheElementWX>(); },
238 dataCache->GetSampleRate());
239
240 mChannelCaches.push_back(
241 { std::move(dataCache), std::move(bitmapCache) });
242 }
243
244 return *this;
245 }
246
247 void SetSelection(const ZoomInfo& zoomInfo, float t0, float t1, bool selected)
248 {
249 for (auto& channelCache : mChannelCaches)
250 channelCache.BitmapCache->SetSelection(zoomInfo, t0, t1, selected);
251 }
252
253 void Draw(
254 int channelIndex, wxDC& dc, const WavePaintParameters& params,
255 const ZoomInfo& zoomInfo, const wxRect& targetRect, int leftOffset,
256 double from, double to)
257 {
258 auto& channelCache = mChannelCaches[channelIndex];
259
260 channelCache.BitmapCache->SetPaintParameters(params);
261
262 auto range = channelCache.BitmapCache->PerformLookup(zoomInfo, from, to);
263
264 auto left = targetRect.x + leftOffset;
265 auto height = targetRect.height;
266
267 const auto top = targetRect.y;
268
269 wxMemoryDC memdc;
270 for (auto it = range.begin(); it != range.end(); ++it)
271 {
272 const auto elementLeftOffset = it.GetLeftOffset();
273 const auto elementRightOffset = it.GetRightOffset();
274
275 const auto width = WaveBitmapCache::CacheElementWidth -
276 elementLeftOffset - elementRightOffset;
277
278 auto& bitmap = static_cast<WaveBitmapCacheElementWX&>(*it).GetBitmap();
279 memdc.SelectObject(bitmap);
280 dc.Blit(
281 wxPoint(left, targetRect.y), wxSize(width, it->Height()), &memdc,
282 wxPoint(elementLeftOffset, 0));
283
284 left += width;
285 }
286 }
287
288 void MarkChanged() noexcept override { }
289
290 void Invalidate() override
291 {
292 for (auto& channelCache : mChannelCaches)
293 channelCache.DataCache->Invalidate();
294 }
295
296 std::unique_ptr<WaveClipListener> Clone() const override
297 {
298 return std::make_unique<WaveformPainter>();
299 }
300
301private:
302 const WaveClip* mWaveClip {};
303
304 struct ChannelCaches final
305 {
306 std::shared_ptr<WaveDataCache> DataCache;
307 std::unique_ptr<WaveBitmapCache> BitmapCache;
308 };
309
310 std::vector<ChannelCaches> mChannelCaches;
311};
312
314 TrackPanelDrawingContext& context, const WaveTrack& track, const WaveChannelInterval& channelInterval,
315 int leftOffset, double t0, double t1,
316 const wxRect & rect, float zoomMin, float zoomMax, bool dB, float dBRange,
317 bool muted)
318{
319 auto& clip = channelInterval.GetClip();
320 const auto channelIndex = channelInterval.GetChannelIndex();
321
322 const auto artist = TrackArtist::Get(context);
323 const ZoomInfo zoomInfo(0.0, artist->pZoomInfo->GetZoom());
324
325 auto& clipPainter = WaveformPainter::Get(clip);
326
327 const auto trimLeft = clip.GetTrimLeft();
328 const auto sequenceStartTime = clip.GetSequenceStartTime();
329
330 WavePaintParameters paintParameters;
331
332 paintParameters
334 rect.GetHeight(), zoomMin, zoomMax, artist->mShowClipping)
335 .SetDBParameters(dBRange, dB)
336 .SetBlankColor(ColorFromWXBrush(artist->blankBrush))
338 ColorFromWXPen(muted ? artist->muteSamplePen : artist->samplePen),
339 ColorFromWXPen(muted ? artist->muteSamplePen : artist->selsamplePen))
341 ColorFromWXPen(muted ? artist->muteRmsPen : artist->rmsPen),
342 ColorFromWXPen(muted ? artist->muteRmsPen : artist->rmsPen))
344 ColorFromWXBrush(artist->unselectedBrush),
345 ColorFromWXBrush(artist->selectedBrush))
347 ColorFromWXPen(muted ? artist->muteClippedPen : artist->clippedPen),
348 ColorFromWXPen(muted ? artist->muteClippedPen : artist->clippedPen))
349 .SetEnvelope(clip.GetEnvelope());
350
351 clipPainter.SetSelection(
352 zoomInfo, artist->pSelectedRegion->t0() - sequenceStartTime,
353 artist->pSelectedRegion->t1() - sequenceStartTime,
355
356 clipPainter.Draw(
357 channelIndex, context.dc, paintParameters, zoomInfo, rect, leftOffset,
358 t0 + trimLeft, t1 + trimLeft);
359}
360
361
362
364 int leftOffset, const wxRect &rect,
365 const double env[],
366 float zoomMin, float zoomMax,
367 int zeroLevelYCoordinate,
368 bool dB, float dBRange,
369 double t0, double t1,
370 bool bIsSyncLockSelected,
371 bool highlightEnvelope)
372{
373 auto &dc = context.dc;
374 const auto artist = TrackArtist::Get( context );
375 const auto &zoomInfo = *artist->pZoomInfo;
376
377 // Visually (one vertical slice of the waveform background, on its side;
378 // the "*" is the actual waveform background we're drawing
379 //
380 //1.0 0.0 -1.0
381 // |--------------------------------|--------------------------------|
382 // *************** ***************
383 // | | | |
384 // maxtop maxbot mintop minbot
385
386 int h = rect.height;
387 int halfHeight = wxMax(h / 2, 1);
388 int maxtop, lmaxtop = 0;
389 int mintop, lmintop = 0;
390 int maxbot, lmaxbot = 0;
391 int minbot, lminbot = 0;
392 bool sel, lsel = false;
393 int xx, lx = 0;
394 int l, w;
395
396 const auto &blankBrush = artist->blankBrush;
397 const auto &selectedBrush = artist->selectedBrush;
398 const auto &unselectedBrush = artist->unselectedBrush;
399
400 dc.SetPen(*wxTRANSPARENT_PEN);
401 dc.SetBrush(blankBrush);
402 dc.DrawRectangle(rect);
403
404 // Bug 2389 - always draw at least one pixel of selection.
405 int selectedX = zoomInfo.TimeToPosition(t0, -leftOffset);
406
407 double time = zoomInfo.PositionToTime(0, -leftOffset), nextTime;
408 for (xx = 0; xx < rect.width; ++xx, time = nextTime) {
409 nextTime = zoomInfo.PositionToTime(xx + 1, -leftOffset);
410 // First we compute the truncated shape of the waveform background.
411 // If drawEnvelope is true, then we compute the lower border of the
412 // envelope.
413
414 maxtop = GetWaveYPos(env[xx], zoomMin, zoomMax,
415 h, dB, true, dBRange, true);
416 maxbot = GetWaveYPos(env[xx], zoomMin, zoomMax,
417 h, dB, false, dBRange, true);
418
419 mintop = GetWaveYPos(-env[xx], zoomMin, zoomMax,
420 h, dB, false, dBRange, true);
421 minbot = GetWaveYPos(-env[xx], zoomMin, zoomMax,
422 h, dB, true, dBRange, true);
423
424 // Make sure it's odd so that a that max and min mirror each other
425 mintop +=1;
426 minbot +=1;
427
428 const auto drawEnvelope = artist->drawEnvelope;
429 if (!drawEnvelope || maxbot > mintop) {
430 maxbot = halfHeight;
431 mintop = halfHeight;
432 }
433
434 sel = (t0 <= time && nextTime < t1);
435 sel = sel || (xx == selectedX);
436 // We don't draw selection color for sync-lock selected tracks.
437 sel = sel && !bIsSyncLockSelected;
438
439 if (lmaxtop == maxtop &&
440 lmintop == mintop &&
441 lmaxbot == maxbot &&
442 lminbot == minbot &&
443 lsel == sel) {
444 continue;
445 }
446
447 dc.SetBrush(lsel ? selectedBrush : unselectedBrush);
448
449 l = rect.x + lx;
450 w = xx - lx;
451 if (lmaxbot < lmintop - 1) {
452 dc.DrawRectangle(l, rect.y + lmaxtop, w, lmaxbot - lmaxtop);
453 dc.DrawRectangle(l, rect.y + lmintop, w, lminbot - lmintop);
454 }
455 else {
456 dc.DrawRectangle(l, rect.y + lmaxtop, w, lminbot - lmaxtop);
457 }
458
459 if (highlightEnvelope && lmaxbot < lmintop - 1) {
460 dc.SetBrush( AColor::uglyBrush );
461 dc.DrawRectangle(l, rect.y + lmaxbot, w, lmintop - lmaxbot);
462 }
463
464 lmaxtop = maxtop;
465 lmintop = mintop;
466 lmaxbot = maxbot;
467 lminbot = minbot;
468 lsel = sel;
469 lx = xx;
470 }
471
472 dc.SetBrush(lsel ? selectedBrush : unselectedBrush);
473 l = rect.x + lx;
474 w = xx - lx;
475 if (lmaxbot < lmintop - 1) {
476 dc.DrawRectangle(l, rect.y + lmaxtop, w, lmaxbot - lmaxtop);
477 dc.DrawRectangle(l, rect.y + lmintop, w, lminbot - lmintop);
478 }
479 else {
480 dc.DrawRectangle(l, rect.y + lmaxtop, w, lminbot - lmaxtop);
481 }
482 if (highlightEnvelope && lmaxbot < lmintop - 1) {
483 dc.SetBrush( AColor::uglyBrush );
484 dc.DrawRectangle(l, rect.y + lmaxbot, w, lmintop - lmaxbot);
485 }
486
487 // If sync-lock selected, draw in linked graphics.
488 if (bIsSyncLockSelected && t0 < t1) {
489 const int begin = std::max(0, std::min(rect.width, (int)(zoomInfo.TimeToPosition(t0, -leftOffset))));
490 const int end = std::max(0, std::min(rect.width, (int)(zoomInfo.TimeToPosition(t1, -leftOffset))));
492 { rect.x + begin, rect.y, end - 1 - begin, rect.height } );
493 }
494
495 //OK, the display bounds are between min and max, which
496 //is spread across rect.height. Draw the line at the proper place.
497 if (zeroLevelYCoordinate >= rect.GetTop() &&
498 zeroLevelYCoordinate <= rect.GetBottom()) {
499 dc.SetPen(*wxBLACK_PEN);
500 AColor::Line(dc, rect.x, zeroLevelYCoordinate,
501 rect.x + rect.width - 1, zeroLevelYCoordinate);
502 }
503}
504
506 wxRect rect;
509 WavePortion(int x, int y, int w, int h, double zoom, bool i)
510 : rect(x, y, w, h), averageZoom(zoom), inFisheye(i)
511 {}
512};
513
515 (std::vector<WavePortion> &portions, const wxRect &rect, const ZoomInfo &zoomInfo,
516 const ClipParameters &params)
517{
518 // If there is no fisheye, then only one rectangle has nonzero width.
519 // If there is a fisheye, make rectangles for before and after
520 // (except when they are squeezed to zero width), and at least one for inside
521 // the fisheye.
522
523 const auto intervals = zoomInfo.FindIntervals(rect.width, rect.x);
524 ZoomInfo::Intervals::const_iterator it = intervals.begin(), end = intervals.end(), prev;
525 wxASSERT(it != end && it->position == rect.x);
526 const int rightmost = rect.x + rect.width;
527 for (int left = rect.x; left < rightmost;) {
528 while (it != end && it->position <= left)
529 prev = it++;
530 if (it == end)
531 break;
532 const int right = std::max(left, (int)(it->position));
533 const int width = right - left;
534 if (width > 0)
535 portions.push_back(
536 WavePortion(left, rect.y, width, rect.height,
537 prev->averageZoom, prev->inFisheye)
538 );
539 left = right;
540 }
541}
542
544 int leftOffset, const wxRect &rect,
545 float zoomMin, float zoomMax,
546 bool dB, float dBRange,
547 const WaveChannelInterval &clip,
548 bool showPoints, bool muted,
549 bool highlight)
550{
551 const Envelope &envelope = clip.GetEnvelope();
552 auto &dc = context.dc;
553 const auto artist = TrackArtist::Get(context);
554 const auto &zoomInfo = *artist->pZoomInfo;
555
556 const double toffset = clip.GetPlayStartTime();
557 const double rate = clip.GetRate() / clip.GetStretchRatio();
558 const double t0 = std::max(0.0, zoomInfo.PositionToTime(0, -leftOffset) - toffset);
559 const auto s0 = sampleCount(floor(t0 * rate));
560 const auto snSamples = clip.GetVisibleSampleCount();
561 if (s0 > snSamples)
562 return;
563
564 const double t1 = zoomInfo.PositionToTime(rect.width - 1, -leftOffset) - toffset;
565 const auto s1 = sampleCount(ceil(t1 * rate));
566
567 // Assume size_t will not overflow, else we wouldn't be here drawing the
568 // few individual samples
569 auto slen = std::min(snSamples - s0, s1 - s0 + 1).as_size_t();
570
571 if (slen <= 0)
572 return;
573
574 Floats buffer{ size_t(slen) };
575 clip.GetSamples((samplePtr)buffer.get(), floatSample, s0, slen,
576 // Suppress exceptions in this drawing operation:
577 false);
578
579 ArrayOf<int> xpos{ size_t(slen) };
580 ArrayOf<int> ypos{ size_t(slen) };
581 ArrayOf<int> clipped;
582 int clipcnt = 0;
583
584 const auto bShowClipping = artist->mShowClipping;
585 if (bShowClipping)
586 clipped.reinit( size_t(slen) );
587
588 const auto &muteSamplePen = artist->muteSamplePen;
589 const auto &samplePen = artist->samplePen;
590 auto &pen = highlight ? AColor::uglyPen : muted ? muteSamplePen : samplePen;
591 dc.SetPen( pen );
592
593 for (decltype(slen) s = 0; s < slen; s++) {
594 const double time = toffset + (s + s0).as_double() / rate;
595 const int xx = // An offset into the rectangle rect
596 std::max(-10000, std::min(10000,
597 (int)(zoomInfo.TimeToPosition(time, -leftOffset))));
598 xpos[s] = xx;
599
600 // Calculate sample as it would be rendered, so quantize time
601 double value = envelope.GetValue(time, 1.0 / clip.GetRate());
602 const double tt = buffer[s] * value;
603
604 if (clipped && bShowClipping && ((tt <= -MAX_AUDIO) || (tt >= MAX_AUDIO)))
605 clipped[clipcnt++] = xx;
606 ypos[s] =
607 std::max(-1,
608 std::min(rect.height,
609 GetWaveYPos(tt, zoomMin, zoomMax,
610 rect.height, dB, true, dBRange, false)));
611 }
612
613
614 if (showPoints) {
615 // Draw points where spacing is enough
616 const auto bigPoints = artist->bigPoints;
617 const int tickSize = bigPoints ? 4 : 3;// Bigger ellipses when draggable.
618 wxRect pr;
619 pr.width = tickSize;
620 pr.height = tickSize;
621 //different colour when draggable.
622 const auto &dragsampleBrush = artist->dragsampleBrush;
623 const auto &sampleBrush = artist->sampleBrush;
624 auto &brush = highlight
626 : bigPoints ? dragsampleBrush : sampleBrush;
627 dc.SetBrush( brush );
628 for (decltype(slen) s = 0; s < slen; s++) {
629 if (ypos[s] >= 0 && ypos[s] < rect.height) {
630 pr.x = rect.x + xpos[s] - tickSize/2;
631 pr.y = rect.y + ypos[s] - tickSize/2;
632 dc.DrawEllipse(pr);
633 }
634 }
635 }
636
637 const auto sampleDisplay = artist->mSampleDisplay;
638 if (showPoints &&
639 (sampleDisplay == (int) WaveChannelViewConstants::StemPlot)
640 ){
641 // Draw vertical lines
642 int yZero = GetWaveYPos(0.0, zoomMin, zoomMax, rect.height, dB, true, dBRange, false);
643 yZero = rect.y + std::max(-1, std::min(rect.height, yZero));
644 for (decltype(slen) s = 0; s < slen; s++) {
645 AColor::Line(dc,
646 rect.x + xpos[s], rect.y + ypos[s],
647 rect.x + xpos[s], yZero);
648 }
649 }
650 else {
651 // Connect samples with straight lines
652 for (decltype(slen) s = 0; s < slen - 1; s++) {
653 AColor::Line(dc,
654 rect.x + xpos[s], rect.y + ypos[s],
655 rect.x + xpos[s + 1], rect.y + ypos[s + 1]);
656 }
657 }
658
659 // Draw clipping
660 if (clipcnt) {
661 const auto &muteClippedPen = artist->muteClippedPen;
662 const auto &clippedPen = artist->clippedPen;
663 dc.SetPen(muted ? muteClippedPen : clippedPen);
664 while (--clipcnt >= 0) {
665 auto s = clipped[clipcnt];
666 AColor::Line(dc, rect.x + s, rect.y, rect.x + s, rect.y + rect.height);
667 }
668 }
669}
670
673 const wxRect &rect, int x0, int y0, int cy, bool top )
674{
675 auto &dc = context.dc;
676
677 int xx = rect.x + x0;
678 int yy = rect.y + cy;
679
680 if (y0 < 0) {
681 if (x0 % 4 != 3) {
682 AColor::Line(dc, xx, yy, xx, yy + 3);
683 }
684 }
685 else if (y0 > rect.height) {
686 if (x0 % 4 != 3) {
687 AColor::Line(dc, xx, yy - 3, xx, yy);
688 }
689 }
690 else {
691 if (top) {
692 AColor::Line(dc, xx, yy, xx, yy + 3);
693 }
694 else {
695 AColor::Line(dc, xx, yy - 3, xx, yy);
696 }
697 }
698}
699
701 const wxRect &rect, const double env[],
702 float zoomMin, float zoomMax,
703 bool dB, float dBRange, bool highlight)
704{
705 auto &dc = context.dc;
706
707 int h = rect.height;
708
709 auto &pen = highlight ? AColor::uglyPen : AColor::envelopePen;
710 dc.SetPen( pen );
711
712 for (int x0 = 0; x0 < rect.width; ++x0) {
713 int cenvTop = GetWaveYPos(env[x0], zoomMin, zoomMax,
714 h, dB, true, dBRange, true);
715
716 int cenvBot = GetWaveYPos(-env[x0], zoomMin, zoomMax,
717 h, dB, true, dBRange, true);
718
719 int envTop = GetWaveYPos(env[x0], zoomMin, zoomMax,
720 h, dB, true, dBRange, false);
721
722 int envBot = GetWaveYPos(-env[x0], zoomMin, zoomMax,
723 h, dB, true, dBRange, false);
724
725 // Make the collision at zero actually look solid
726 if (cenvBot - cenvTop < 9) {
727 int value = (int)((zoomMax / (zoomMax - zoomMin)) * h);
728 cenvTop = value - 4;
729 cenvBot = value + 4;
730 }
731
732 DrawEnvLine( context, rect, x0, envTop, cenvTop, true );
733 DrawEnvLine( context, rect, x0, envBot, cenvBot, false );
734 }
735}
736
737// Headers needed only for experimental drawing below
738//#include "tracks/playabletrack/wavetrack/ui/SampleHandle.h"
739//#include "tracks/ui/EnvelopeHandle.h"
741 const WaveChannel &channel, const WaveChannelInterval &clip,
742 const wxRect &rect, bool dB, bool muted, bool selected)
743{
744 const Envelope &envelope = clip.GetEnvelope();
745 auto &dc = context.dc;
746 const auto artist = TrackArtist::Get(context);
747 const auto &selectedRegion = *artist->pSelectedRegion;
748 const auto &zoomInfo = *artist->pZoomInfo;
749
751
752 bool highlightEnvelope = false;
753#ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING
754 auto target = dynamic_cast<EnvelopeHandle*>(context.target.get());
755 highlightEnvelope = target && target->GetEnvelope() == &envelope;
756#endif
757
758 //If clip is "too small" draw a placeholder instead of
759 //attempting to fit the contents into a few pixels
760 if (!WaveChannelView::ClipDetailsVisible(clip, zoomInfo, rect))
761 {
762 auto clipRect = ClipParameters::GetClipRect(clip, zoomInfo, rect);
763 TrackArt::DrawClipFolded(dc, clipRect);
764 return;
765 }
766
767 const ClipParameters params { clip, rect, zoomInfo };
768 const wxRect &hiddenMid = params.hiddenMid;
769 // The "hiddenMid" rect contains the part of the display actually
770 // containing the waveform, as it appears without the fisheye. If it's empty, we're done.
771 if (hiddenMid.width <= 0) {
772 return;
773 }
774
775 const double &t0 = params.t0;
776 const double &t1 = params.t1;
777 const double playStartTime = clip.GetPlayStartTime();
778 const double &trackRectT0 = params.trackRectT0;
779 const double &averagePixelsPerSecond = params.averagePixelsPerSecond;
780 const double sampleRate = clip.GetRate();
781 const double stretchRatio = clip.GetStretchRatio();
782 double leftOffset = params.leftOffset;
783 const wxRect &mid = params.mid;
784
785 auto &settings = WaveformSettings::Get(channel);
786 const float dBRange = settings.dBRange;
787
788 dc.SetPen(*wxTRANSPARENT_PEN);
789 int iColorIndex = WaveColorAttachment::Get(clip).GetColorIndex();
790 artist->SetColours( iColorIndex );
791
792 // The bounds (controlled by vertical zooming; -1.0...1.0
793 // by default)
794 float zoomMin, zoomMax;
795 auto &cache = WaveformScale::Get(channel);
796 cache.GetDisplayBounds(zoomMin, zoomMax);
797
798 std::vector<double> vEnv(mid.width);
799 double *const env = &vEnv[0];
800 CommonChannelView::GetEnvelopeValues(envelope, playStartTime,
801
802 // PRL: change back to make envelope evaluate only at sample times
803 // and then interpolate the display
804 0, // 1.0 / sampleRate,
805
806 env, mid.width, leftOffset, zoomInfo);
807
808 // Draw the background of the track, outlining the shape of
809 // the envelope and using a colored pen for the selected
810 // part of the waveform
811 {
812 double tt0, tt1;
813 const auto &track = channel.GetTrack();
815 tt0 = track.SnapToSample(selectedRegion.t0());
816 tt1 = track.SnapToSample(selectedRegion.t1());
817 }
818 else
819 tt0 = tt1 = 0.0;
820 DrawWaveformBackground(context, leftOffset, mid,
821 env,
822 zoomMin, zoomMax,
823 cache.ZeroLevelYCoordinate(mid),
824 dB, dBRange,
825 tt0, tt1,
826 !track.GetSelected(), highlightEnvelope);
827 }
828
829 // Require at least 1/2 pixel per sample for drawing individual samples.
830 const double threshold1 = 0.5 * sampleRate / stretchRatio;
831 // Require at least 3 pixels per sample for drawing the draggable points.
832 const double threshold2 = 3 * sampleRate / stretchRatio;
833
834 bool highlight = false;
835#ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING
836 auto target = dynamic_cast<SampleHandle*>(context.target.get());
837 highlight = target && target->FindChannel().get() == &track;
838#endif
839
840 const bool showIndividualSamples = zoomInfo.GetZoom() > threshold1;
841 const bool showPoints = zoomInfo.GetZoom() > threshold2;
842
843 if(!showIndividualSamples)
844 {
846 context, channel.GetTrack(), clip, leftOffset, t0, t1,
847 rect, zoomMin, zoomMax, dB, dBRange, muted);
848 }
849 else
850 {
852 context, leftOffset, rect, zoomMin, zoomMax, dB, dBRange, clip,
853 showPoints, muted, highlight);
854 }
855
856 const auto drawEnvelope = artist->drawEnvelope;
857 if (drawEnvelope) {
859 context, mid, env, zoomMin, zoomMax, dB, dBRange, highlightEnvelope);
861 context, mid, dB, dBRange, zoomMin, zoomMax, true, rect.x - mid.x);
862 }
863
864 // Draw arrows on the left side if the track extends to the left of the
865 // beginning of time. :)
866 if (trackRectT0 == 0.0 && playStartTime < 0.0)
867 {
869 }
870 {
871 auto clipRect = ClipParameters::GetClipRect(clip, zoomInfo, rect);
872 TrackArt::DrawClipEdges(dc, clipRect, selected);
873 }
874}
875
877 const wxRect & rect,
878 bool rightwards, bool highlight )
879{
880 auto &dc = context.dc;
881
882 const int border = 3; // 3 pixels all round.
883 const int width = 6; // width of the drag box.
884 const int taper = 6; // how much the box tapers by.
885 const int barSpacing = 4; // how far apart the bars are.
886 const int barWidth = 3;
887 const int xFlat = 3;
888
889 //Enough space to draw in?
890 if (rect.height <= ((taper+border + barSpacing) * 2)) {
891 return;
892 }
893 if (rect.width <= (width * 2 + border * 3)) {
894 return;
895 }
896
897 // The draggable box is tapered towards the direction you drag it.
898 int leftTaper = rightwards ? 0 : 6;
899 int rightTaper = rightwards ? 6 : 0;
900
901 int xLeft = rightwards ? (rect.x + border - 2)
902 : (rect.x + rect.width + 1 - (border + width));
903 int yTop = rect.y + border;
904 int yBot = rect.y + rect.height - border - 1;
905
906 AColor::Light(&dc, false, highlight);
907 AColor::Line(dc, xLeft, yBot - leftTaper, xLeft, yTop + leftTaper);
908 AColor::Line(dc, xLeft, yTop + leftTaper, xLeft + xFlat, yTop);
909 AColor::Line(dc, xLeft + xFlat, yTop, xLeft + width, yTop + rightTaper);
910
911 AColor::Dark(&dc, false, highlight);
912 AColor::Line(dc, xLeft + width, yTop + rightTaper, xLeft + width, yBot - rightTaper);
913 AColor::Line(dc, xLeft + width, yBot - rightTaper, xLeft + width-xFlat, yBot);
914 AColor::Line(dc, xLeft + width - xFlat, yBot, xLeft, yBot - leftTaper);
915
916 int firstBar = yTop + taper + taper / 2;
917 int nBars = (yBot - yTop - taper * 3) / barSpacing + 1;
918 xLeft += (width - barWidth + 1) / 2;
919 int yy;
920 int i;
921
922 AColor::Light(&dc, false, highlight);
923 for (i = 0;i < nBars; i++) {
924 yy = firstBar + barSpacing * i;
925 AColor::Line(dc, xLeft, yy, xLeft + barWidth, yy);
926 }
927 AColor::Dark(&dc, false, highlight);
928 for(i = 0;i < nBars; i++){
929 yy = firstBar + barSpacing * i + 1;
930 AColor::Line(dc, xLeft, yy, xLeft + barWidth, yy);
931 }
932}
933
934}
935
936// Header needed only for experimental drawing below
937//#include "tracks/ui/TimeShiftHandle.h"
939 const WaveChannel &channel,
940 const WaveTrack::Interval* selectedClip,
941 const wxRect& rect,
942 bool muted)
943{
944 auto &dc = context.dc;
945 const auto artist = TrackArtist::Get( context );
946
947 bool highlight = false;
948 bool gripHit = false;
949#ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING
950 auto target = dynamic_cast<TimeShiftHandle*>(context.target.get());
951 gripHit = target && target->IsGripHit();
952 highlight = target && target->FindTrack().get() ==
953 &static_cast<const Track &>(channel.GetChannelGroup());
954#endif
955
956 const bool dB = !WaveformSettings::Get(channel).isLinear();
957
958 const auto &blankSelectedBrush = artist->blankSelectedBrush;
959 const auto &blankBrush = artist->blankBrush;
961 context, rect, channel, blankSelectedBrush, blankBrush );
962
963 for (const auto &pInterval : channel.Intervals()) {
964 bool selected = selectedClip &&
965 selectedClip == &pInterval->GetClip();
966 DrawClipWaveform(context, channel, *pInterval, rect, dB, muted, selected);
967 }
968 DrawBoldBoundaries(context, channel, rect);
969
970 const auto drawSliders = artist->drawSliders;
971 if (drawSliders) {
972 DrawTimeSlider( context, rect, true, highlight && gripHit ); // directed right
973 DrawTimeSlider( context, rect, false, highlight && gripHit ); // directed left
974 }
975}
976
978 TrackPanelDrawingContext &context, const wxRect &rect, unsigned iPass )
979{
980 if ( iPass == TrackArtist::PassTracks ) {
981 const auto artist = TrackArtist::Get(context);
982 const auto &pendingTracks = *artist->pPendingTracks;
983 auto &dc = context.dc;
984
985 const auto pChannel = FindChannel();
986 if (!pChannel)
987 return;
988 const auto &wc = static_cast<const WaveChannel&>(
989 pendingTracks.SubstitutePendingChangedChannel(*pChannel));
990
991 const auto hasSolo = artist->hasSolo;
992 bool muted = (hasSolo || wc.GetTrack().GetMute()) &&
993 !wc.GetTrack().GetSolo();
994
995#if defined(__WXMAC__)
996 wxAntialiasMode aamode = dc.GetGraphicsContext()->GetAntialiasMode();
997 dc.GetGraphicsContext()->SetAntialiasMode(wxANTIALIAS_NONE);
998#endif
999
1000 auto waveChannelView = GetWaveChannelView().lock();
1001 wxASSERT(waveChannelView.use_count());
1002
1003 auto selectedClip = waveChannelView->GetSelectedClip();
1004 DoDraw(context, wc, selectedClip.get(), rect, muted);
1005
1006#if defined(__WXMAC__)
1007 dc.GetGraphicsContext()->SetAntialiasMode(aamode);
1008#endif
1009 }
1010 WaveChannelSubView::Draw(context, rect, iPass);
1011}
1012
1014 [](WaveChannelView &view) {
1015 return std::make_shared<WaveformView>( view );
1016 }
1017};
1018
1019// The following attaches the wave color sub-menu to the wave track popup
1020// menu. It is appropriate only to waveform view and so is kept in this
1021// source file with the rest of the waveform view implementation.
1022
1023#include <mutex> // for std::call_once
1024#include "WaveTrackControls.h"
1025#include "../../../../widgets/PopupMenuTable.h"
1026#include "ProjectAudioIO.h"
1027#include "ProjectHistory.h"
1028#include "../../../../RefreshCode.h"
1029
1030//=============================================================================
1031// Table class for a sub-menu
1033{
1034 WaveColorMenuTable() : PopupMenuTable{ "WaveColor", XO("&Wave Color") } {}
1036
1037 static WaveColorMenuTable &Instance();
1038
1039 void InitUserData(void *pUserData) override;
1040
1042
1043 int IdOfWaveColor(int WaveColor);
1044 void OnWaveColorChange(wxCommandEvent & event);
1045
1047};
1048
1050{
1051 static WaveColorMenuTable instance;
1052 return instance;
1053}
1054
1056{
1057 mpData = static_cast<PlayableTrackControls::InitMenuData*>(pUserData);
1058}
1059
1060namespace {
1061using ValueFinder = std::function< int( WaveTrack& ) >;
1062
1064{
1065 return XXO("Instrument %i").Format( colorIndex+1 );
1066}
1067}
1068
1070 static const auto fn = []( PopupMenuHandler &handler, wxMenu &menu, int id ){
1071 auto &me = static_cast<WaveColorMenuTable&>( handler );
1072 auto pData = me.mpData;
1073 const auto &track = static_cast<WaveTrack&>(pData->track);
1074 auto &project = pData->project;
1075 bool unsafe = ProjectAudioIO::Get( project ).IsAudioActive();
1076
1077 menu.Check(id, id == me.IdOfWaveColor(
1079 menu.Enable( id, !unsafe );
1080 };
1081
1082 static std::once_flag flag;
1083 std::call_once( flag, [this]{
1084 auto &hostTable = GetWaveTrackMenuTable();
1085 OnInstrument1ID = hostTable.ReserveId();
1086 OnInstrument2ID = hostTable.ReserveId();
1087 OnInstrument3ID = hostTable.ReserveId();
1088 OnInstrument4ID = hostTable.ReserveId();
1089 } );
1090
1091 AppendRadioItem( "Instrument1", OnInstrument1ID,
1092 GetWaveColorStr(0), POPUP_MENU_FN( OnWaveColorChange ), fn );
1093 AppendRadioItem( "Instrument2", OnInstrument2ID,
1094 GetWaveColorStr(1), POPUP_MENU_FN( OnWaveColorChange ), fn );
1095 AppendRadioItem( "Instrument3", OnInstrument3ID,
1096 GetWaveColorStr(2), POPUP_MENU_FN( OnWaveColorChange ), fn );
1097 AppendRadioItem( "Instrument4", OnInstrument4ID,
1098 GetWaveColorStr(3), POPUP_MENU_FN( OnWaveColorChange ), fn );
1099
1101
1102
1103int WaveColorMenuTable::IdOfWaveColor(int WaveColor)
1104{ return OnInstrument1ID + WaveColor;}
1105
1108void WaveColorMenuTable::OnWaveColorChange(wxCommandEvent & event)
1109{
1110 int id = event.GetId();
1111 wxASSERT(id >= OnInstrument1ID && id <= OnInstrument4ID);
1112 auto &track = static_cast<WaveTrack&>(mpData->track);
1113
1114 int newWaveColor = id - OnInstrument1ID;
1115
1117
1118 WaveformAppearance::Get(track).SetColorIndex(newWaveColor);
1119
1121 .PushState(XO("Changed '%s' to %s")
1122 .Format(track.GetName(), GetWaveColorStr(newWaveColor)),
1123 XO("WaveColor Change"));
1124
1125 using namespace RefreshCode;
1127}
1128
1129namespace {
1132 { "SubViews/Extra" },
1133 std::make_unique<PopupMenuSection>( "WaveColor",
1134 // Conditionally add sub-menu for wave color, if showing waveform
1135 PopupMenuTable::Adapt<WaveTrackPopupMenuTable>(
1136 [](WaveTrackPopupMenuTable &table) {
1137 const auto pTrack = &table.FindWaveTrack();
1138 const auto &view = WaveChannelView::GetFirst(*pTrack);
1139 const auto displays = view.GetDisplays();
1140 bool hasWaveform = (displays.end() != std::find(
1141 displays.begin(), displays.end(),
1143 WaveChannelViewConstants::Waveform, {} }
1144 ) );
1145 return hasWaveform
1147 .Get(table.mpData))
1148 : nullptr;
1149 } ) )
1150};
1151
1152}
1153
1154static WaveClip::Attachments::RegisteredFactory sKeyW{ [](WaveClip&) {
1155 return std::make_unique<WaveformPainter>();
1156} };
1157
1159{
1160 return const_cast< WaveClip& >( clip ) // Consider it mutable data
1161 .Attachments::Get<WaveformPainter>(sKeyW).EnsureClip(clip);
1162}
wxImage(22, 22)
wxT("CloseDown"))
std::shared_ptr< UIHandle > UIHandlePtr
Definition: CellularPanel.h:28
int min(int a, int b)
EffectDistortionSettings params
Definition: Distortion.cpp:77
XO("Cut/Copy/Paste")
XXO("&Cut/Copy/Paste Toolbar")
#define MAX_AUDIO
Definition: MemoryX.h:341
#define END_POPUP_MENU()
#define BEGIN_POPUP_MENU(HandlerClass)
#define POPUP_MENU_FN(memFn)
audacity::BasicSettings * gPrefs
Definition: Prefs.cpp:68
constexpr sampleFormat floatSample
Definition: SampleFormat.h:45
char * samplePtr
Definition: SampleFormat.h:57
const auto project
int GetWaveYPos(float value, float min, float max, int height, bool dB, bool outer, float dBr, bool clip)
Definition: TrackArt.cpp:66
static Settings & settings()
Definition: TrackInfo.cpp:47
WaveTrackPopupMenuTable & GetWaveTrackMenuTable()
static WaveChannelSubViewType::RegisteredType reg
static const auto fn
AppendRadioItem("Instrument1", OnInstrument1ID, GetWaveColorStr(0), POPUP_MENU_FN(OnWaveColorChange), fn)
static WaveClip::Attachments::RegisteredFactory sKeyW
static const WaveChannelSubViews::RegisteredFactory key
static WaveChannelSubView::Type sType
static std::once_flag flag
static void Line(wxDC &dc, wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
Definition: AColor.cpp:185
static wxBrush uglyBrush
Definition: AColor.h:140
static void Light(wxDC *dc, bool selected, bool highlight=false)
Definition: AColor.cpp:407
static wxPen uglyPen
Definition: AColor.h:139
static void Dark(wxDC *dc, bool selected, bool highlight=false)
Definition: AColor.cpp:433
static wxPen envelopePen
Definition: AColor.h:115
void reinit(Integral count, bool initialize=false)
Definition: MemoryX.h:59
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
ChannelGroup & GetChannelGroup()
Channel object's lifetime is assumed to be nested in its Track's.
Definition: Channel.cpp:43
virtual void DoSetMinimized(bool isMinimized)
Client code makes static instance from a factory of attachments; passes it to Get or Find as a retrie...
Definition: ClientData.h:275
auto FindChannel() -> std::shared_ptr< Subtype >
May return null.
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.
static void DrawPoints(const Envelope &env, TrackPanelDrawingContext &context, const wxRect &r, bool dB, double dBRange, float zoomMin, float zoomMax, bool mirrored, int origin=0)
static UIHandlePtr WaveChannelHitTest(std::weak_ptr< EnvelopeHandle > &holder, const wxMouseState &state, const wxRect &rect, const AudacityProject *pProject, const std::shared_ptr< WaveChannel > &wt)
Envelope * GetEnvelope() const
static UIHandlePtr HitAnywhere(std::weak_ptr< EnvelopeHandle > &holder, Envelope *envelope, std::weak_ptr< const Channel > wChannel, bool timeTrack)
Piecewise linear or piecewise exponential function from double to double.
Definition: Envelope.h:72
double GetValue(double t, double sampleDur=0) const
Get envelope value at time t.
Definition: Envelope.cpp:880
Abstract base class used in importing a file.
@ WaveformView
Time required to draw a single clip.
static Stopwatch CreateStopwatch(SectionID section) noexcept
Create a Stopwatch for the section specified.
static constexpr uint32_t CacheElementWidth
bool IsAudioActive() const
static ProjectAudioIO & Get(AudacityProject &project)
void PushState(const TranslatableString &desc, const TranslatableString &shortDesc)
static ProjectHistory & Get(AudacityProject &project)
static UIHandlePtr HitAnywhere(std::weak_ptr< SampleHandle > &holder, const wxMouseState &state, const std::shared_ptr< WaveChannel > &pChannel)
static UIHandlePtr HitTest(std::weak_ptr< SampleHandle > &holder, const wxMouseState &state, const wxRect &rect, const AudacityProject *pProject, const std::shared_ptr< WaveChannel > &pChannel)
static bool IsSelectedOrSyncLockSelected(const Track &track)
Definition: SyncLock.cpp:104
static UIHandlePtr HitTest(std::weak_ptr< TimeShiftHandle > &holder, const wxMouseState &state, const wxRect &rect, const std::shared_ptr< Track > &pTrack)
bool IsGripHit() const
static TrackArtist * Get(TrackPanelDrawingContext &)
Definition: TrackArtist.cpp:69
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:110
virtual void Draw(TrackPanelDrawingContext &context, const wxRect &rect, unsigned iPass)
Holds a msgid for the translation catalog; may also bind format arguments.
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:235
An element, that contains a rasterized bitmap matching the WaveDataCacheElement.
WaveTrack & GetTrack()
Definition: WaveTrack.h:840
IteratorRange< IntervalIterator< WaveClipChannel > > Intervals()
Definition: WaveTrack.cpp:745
std::shared_ptr< WaveChannel > FindWaveChannel()
static void DrawBoldBoundaries(TrackPanelDrawingContext &context, const WaveChannel &channel, const wxRect &rect)
std::pair< bool, std::vector< UIHandlePtr > > DoDetailedHitTest(const TrackPanelMouseState &state, const AudacityProject *pProject, int currentTool, bool bMultiTool, const std::shared_ptr< WaveChannel > &wt)
std::weak_ptr< WaveChannelView > GetWaveChannelView() const
static bool ClipDetailsVisible(const ClipTimes &clip, const ZoomInfo &zoomInfo, const wxRect &viewRect)
static WaveChannelView & GetFirst(WaveTrack &wt)
Get the view of the first channel.
WaveClip & GetClip()
Definition: WaveClip.h:96
sampleCount GetVisibleSampleCount() const override
Definition: WaveClip.cpp:188
size_t GetChannelIndex() const
Definition: WaveClip.h:99
Envelope & GetEnvelope()
Definition: WaveClip.cpp:64
int GetRate() const override
Definition: WaveClip.cpp:193
double GetPlayStartTime() const override
Definition: WaveClip.cpp:198
double GetStretchRatio() const override
Definition: WaveClip.cpp:218
bool GetSamples(samplePtr buffer, sampleFormat format, sampleCount start, size_t len, bool mayThrow=true) const
Definition: WaveClip.cpp:115
This allows multiple clips to be a part of one WaveTrack.
Definition: WaveClip.h:238
size_t NChannels() const override
How many Sequences the clip contains.
Definition: WaveClip.cpp:373
A Track that contains audio waveform data.
Definition: WaveTrack.h:203
bool GetSolo() const override
May vary asynchronously.
Definition: WaveTrack.cpp:2323
static WaveformAppearance & Get(WaveTrack &track)
void SetColorIndex(int colorIndex)
static WaveformScale & Get(const WaveTrack &track)
Mutative access to attachment even if the track argument is const.
bool isLinear() const
static WaveformSettings & Get(const WaveTrack &track)
void Draw(TrackPanelDrawingContext &context, const wxRect &rect, unsigned iPass) override
~WaveformView() override
std::shared_ptr< ChannelVRulerControls > DoGetVRulerControls() override
static void DoDraw(TrackPanelDrawingContext &context, const WaveChannel &channel, const WaveTrack::Interval *selectedClip, const wxRect &rect, bool muted)
void DoSetMinimized(bool minimized) override
const Type & SubViewType() const override
std::vector< UIHandlePtr > DetailedHitTest(const TrackPanelMouseState &state, const AudacityProject *pProject, int currentTool, bool bMultiTool) override
double SnapToSample(double t) const
Intervals FindIntervals(int64 width, int64 origin=0) const
Definition: ZoomInfo.cpp:99
void SetSelection(const ZoomInfo &zoomInfo, float t0, float t1, bool selected)
std::unique_ptr< WaveClipListener > Clone() const override
void Draw(int channelIndex, wxDC &dc, const WavePaintParameters &params, const ZoomInfo &zoomInfo, const wxRect &targetRect, int leftOffset, double from, double to)
WaveformPainter & EnsureClip(const WaveClip &clip)
virtual bool Read(const wxString &key, bool *value) const =0
Positions or offsets within audio files need a wide type.
Definition: SampleCount.h:19
Services * Get()
Fetch the global instance, or nullptr if none is yet installed.
Definition: BasicUI.cpp:201
Namespace containing an enum 'what to do on a refresh?'.
Definition: RefreshCode.h:16
std::unique_ptr< detail::IndirectItem< Item > > Indirect(const std::shared_ptr< Item > &ptr)
A convenience function.
Definition: Registry.h:175
AUDACITY_DLL_API void DrawSyncLockTiles(TrackPanelDrawingContext &context, const wxRect &rect)
Definition: TrackArt.cpp:365
AUDACITY_DLL_API void DrawClipFolded(wxDC &dc, const wxRect &rect)
Definition: TrackArt.cpp:346
AUDACITY_DLL_API void DrawClipEdges(wxDC &dc, const wxRect &clipRect, bool selected=false)
Definition: TrackArt.cpp:309
AUDACITY_DLL_API void DrawNegativeOffsetTrackArrows(TrackPanelDrawingContext &context, const wxRect &rect)
Definition: TrackArt.cpp:143
AUDACITY_DLL_API void DrawBackgroundWithSelection(TrackPanelDrawingContext &context, const wxRect &rect, const Channel &channel, const wxBrush &selBrush, const wxBrush &unselBrush, bool useSelection=true)
Definition: TrackArt.cpp:651
WAVE_TRACK_API Envelope * GetEnvelopeAtTime(WaveChannel &channel, double time)
void DrawClipWaveform(TrackPanelDrawingContext &context, const WaveChannel &channel, const WaveChannelInterval &clip, const wxRect &rect, bool dB, bool muted, bool selected)
std::function< int(WaveTrack &) > ValueFinder
const TranslatableString GetWaveColorStr(int colorIndex)
void DrawEnvLine(TrackPanelDrawingContext &context, const wxRect &rect, int x0, int y0, int cy, bool top)
void DrawIndividualSamples(TrackPanelDrawingContext &context, int leftOffset, const wxRect &rect, float zoomMin, float zoomMax, bool dB, float dBRange, const WaveChannelInterval &clip, bool showPoints, bool muted, bool highlight)
void DrawEnvelope(TrackPanelDrawingContext &context, const wxRect &rect, const double env[], float zoomMin, float zoomMax, bool dB, float dBRange, bool highlight)
void DrawTimeSlider(TrackPanelDrawingContext &context, const wxRect &rect, bool rightwards, bool highlight)
PopupMenuTable::AttachedItem sAttachment
void DrawWaveform(TrackPanelDrawingContext &context, const WaveTrack &track, const WaveChannelInterval &channelInterval, int leftOffset, double t0, double t1, const wxRect &rect, float zoomMin, float zoomMax, bool dB, float dBRange, bool muted)
void FindWavePortions(std::vector< WavePortion > &portions, const wxRect &rect, const ZoomInfo &zoomInfo, const ClipParameters &params)
graphics::Color ColorFromWXPen(const wxPen &pen)
graphics::Color ColorFromWXBrush(const wxBrush &brush)
void DrawWaveformBackground(TrackPanelDrawingContext &context, int leftOffset, const wxRect &rect, const double env[], float zoomMin, float zoomMax, int zeroLevelYCoordinate, bool dB, float dBRange, double t0, double t1, bool bIsSyncLockSelected, bool highlightEnvelope)
const char * end(const char *str) noexcept
Definition: StringUtils.h:106
const char * begin(const char *str) noexcept
Definition: StringUtils.h:101
static wxRect GetClipRect(const ClipTimes &clip, const ZoomInfo &zoomInfo, const wxRect &viewRect, bool *outShowSamples=nullptr)
static WaveColorAttachment & Get(WaveClip &clip)
PlayableTrackControls::InitMenuData * mpData
DECLARE_POPUP_MENU(WaveColorMenuTable)
void InitUserData(void *pUserData) override
Called before the menu items are appended.
int IdOfWaveColor(int WaveColor)
Converts a WaveColor enumeration to a wxWidgets menu item Id.
void OnWaveColorChange(wxCommandEvent &event)
static WaveColorMenuTable & Instance()
Parameters for the waveform painting.
WavePaintParameters & SetBlankColor(graphics::Color color) noexcept
Sets the blank color.
WavePaintParameters & SetBackgroundColors(graphics::Color normal, graphics::Color selected) noexcept
Sets the background colors.
WavePaintParameters & SetDBParameters(double dbRange, bool dbScale) noexcept
Sets the dB scale parameters.
WavePaintParameters & SetClippingColors(graphics::Color normal, graphics::Color selected) noexcept
Sets the clipping colors.
WavePaintParameters & SetSampleColors(graphics::Color normal, graphics::Color selected) noexcept
Sets the sample colors.
WavePaintParameters & SetDisplayParameters(int height, double zoomMin, double zoomMax, bool showClipping) noexcept
Sets the basic painting parameters.
WavePaintParameters & SetEnvelope(const Envelope &envelope) noexcept
Sets volume envelope.
WavePaintParameters & SetRMSColors(graphics::Color normal, graphics::Color selected) noexcept
Sets the RMS colors.
WaveTrack & FindWaveTrack() const
PlayableTrackControls::InitMenuData * mpData
uint8_t * Allocate(size_t width, size_t height) override
WavePortion(int x, int y, int w, int h, double zoom, bool i)
Class for storing color in 32-bit format.
Definition: Color.h:29