Audacity 3.2.0
Classes | Typedefs | Functions | Variables
anonymous_namespace{WaveformView.cpp} Namespace Reference

Classes

struct  WaveBitmapCacheElementWX
 
class  WaveformPainter
 
struct  WavePortion
 

Typedefs

using ValueFinder = std::function< int(WaveTrack &) >
 

Functions

graphics::Color ColorFromWXPen (const wxPen &pen)
 
graphics::Color ColorFromWXBrush (const wxBrush &brush)
 
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 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)
 
void FindWavePortions (std::vector< WavePortion > &portions, const wxRect &rect, const ZoomInfo &zoomInfo, const ClipParameters &params)
 
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 DrawEnvLine (TrackPanelDrawingContext &context, const wxRect &rect, int x0, int y0, int cy, bool top)
 
void DrawEnvelope (TrackPanelDrawingContext &context, const wxRect &rect, const double env[], float zoomMin, float zoomMax, bool dB, float dBRange, bool highlight)
 
void DrawClipWaveform (TrackPanelDrawingContext &context, const WaveChannel &channel, const WaveChannelInterval &clip, const wxRect &rect, bool dB, bool muted, bool selected)
 
void DrawTimeSlider (TrackPanelDrawingContext &context, const wxRect &rect, bool rightwards, bool highlight)
 
const TranslatableString GetWaveColorStr (int colorIndex)
 

Variables

PopupMenuTable::AttachedItem sAttachment
 

Typedef Documentation

◆ ValueFinder

using anonymous_namespace{WaveformView.cpp}::ValueFinder = typedef std::function< int( WaveTrack& ) >

Definition at line 1063 of file WaveformView.cpp.

Function Documentation

◆ ColorFromWXBrush()

graphics::Color anonymous_namespace{WaveformView.cpp}::ColorFromWXBrush ( const wxBrush &  brush)

Definition at line 167 of file WaveformView.cpp.

168{
169 const auto c = brush.GetColour();
170 return graphics::Color(c.Red(), c.Green(), c.Blue());
171}
Class for storing color in 32-bit format.
Definition: Color.h:29

Referenced by DrawWaveform().

Here is the caller graph for this function:

◆ ColorFromWXPen()

graphics::Color anonymous_namespace{WaveformView.cpp}::ColorFromWXPen ( const wxPen &  pen)

Definition at line 161 of file WaveformView.cpp.

162{
163 const auto c = pen.GetColour();
164 return graphics::Color(c.Red(), c.Green(), c.Blue());
165}

Referenced by DrawWaveform().

Here is the caller graph for this function:

◆ DrawClipWaveform()

void anonymous_namespace{WaveformView.cpp}::DrawClipWaveform ( TrackPanelDrawingContext context,
const WaveChannel channel,
const WaveChannelInterval clip,
const wxRect &  rect,
bool  dB,
bool  muted,
bool  selected 
)

Definition at line 742 of file WaveformView.cpp.

745{
746 const Envelope &envelope = clip.GetEnvelope();
747 auto &dc = context.dc;
748 const auto artist = TrackArtist::Get(context);
749 const auto &selectedRegion = *artist->pSelectedRegion;
750 const auto &zoomInfo = *artist->pZoomInfo;
751
753
754 bool highlightEnvelope = false;
755#ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING
756 auto target = dynamic_cast<EnvelopeHandle*>(context.target.get());
757 highlightEnvelope = target && target->GetEnvelope() == &envelope;
758#endif
759
760 //If clip is "too small" draw a placeholder instead of
761 //attempting to fit the contents into a few pixels
762 if (!WaveChannelView::ClipDetailsVisible(clip, zoomInfo, rect))
763 {
764 auto clipRect = ClipParameters::GetClipRect(clip, zoomInfo, rect);
765 TrackArt::DrawClipFolded(dc, clipRect);
766 return;
767 }
768
769 const ClipParameters params { clip, rect, zoomInfo };
770 const wxRect &hiddenMid = params.hiddenMid;
771 // The "hiddenMid" rect contains the part of the display actually
772 // containing the waveform, as it appears without the fisheye. If it's empty, we're done.
773 if (hiddenMid.width <= 0) {
774 return;
775 }
776
777 const double &t0 = params.t0;
778 const double &t1 = params.t1;
779 const double playStartTime = clip.GetPlayStartTime();
780 const double &trackRectT0 = params.trackRectT0;
781 const double &averagePixelsPerSecond = params.averagePixelsPerSecond;
782 const double sampleRate = clip.GetRate();
783 const double stretchRatio = clip.GetStretchRatio();
784 double leftOffset = params.leftOffset;
785 const wxRect &mid = params.mid;
786
787 auto &settings = WaveformSettings::Get(channel);
788 const float dBRange = settings.dBRange;
789
790 dc.SetPen(*wxTRANSPARENT_PEN);
791 int iColorIndex = WaveColorAttachment::Get(clip).GetColorIndex();
792 artist->SetColours( iColorIndex );
793
794 // The bounds (controlled by vertical zooming; -1.0...1.0
795 // by default)
796 float zoomMin, zoomMax;
797 auto &cache = WaveformScale::Get(channel);
798 cache.GetDisplayBounds(zoomMin, zoomMax);
799
800 std::vector<double> vEnv(mid.width);
801 double *const env = &vEnv[0];
802 CommonChannelView::GetEnvelopeValues(envelope, playStartTime,
803
804 // PRL: change back to make envelope evaluate only at sample times
805 // and then interpolate the display
806 0, // 1.0 / sampleRate,
807
808 env, mid.width, leftOffset, zoomInfo);
809
810 // Draw the background of the track, outlining the shape of
811 // the envelope and using a colored pen for the selected
812 // part of the waveform
813 {
814 double tt0, tt1;
815 const auto &track = channel.GetTrack();
817 tt0 = track.SnapToSample(selectedRegion.t0());
818 tt1 = track.SnapToSample(selectedRegion.t1());
819 }
820 else
821 tt0 = tt1 = 0.0;
822 DrawWaveformBackground(context, leftOffset, mid,
823 env,
824 zoomMin, zoomMax,
825 cache.ZeroLevelYCoordinate(mid),
826 dB, dBRange,
827 tt0, tt1,
828 !track.GetSelected(), highlightEnvelope);
829 }
830
831 // Require at least 1/2 pixel per sample for drawing individual samples.
832 const double threshold1 = 0.5 * sampleRate / stretchRatio;
833 // Require at least 3 pixels per sample for drawing the draggable points.
834 const double threshold2 = 3 * sampleRate / stretchRatio;
835
836 bool highlight = false;
837#ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING
838 auto target = dynamic_cast<SampleHandle*>(context.target.get());
839 highlight = target && target->FindChannel().get() == &track;
840#endif
841
842 const bool showIndividualSamples = zoomInfo.GetZoom() > threshold1;
843 const bool showPoints = zoomInfo.GetZoom() > threshold2;
844
845 if(!showIndividualSamples)
846 {
848 context, channel.GetTrack(), clip, leftOffset, t0, t1,
849 rect, zoomMin, zoomMax, dB, dBRange, muted);
850 }
851 else
852 {
854 context, leftOffset, rect, zoomMin, zoomMax, dB, dBRange, clip,
855 showPoints, muted, highlight);
856 }
857
858 const auto drawEnvelope = artist->drawEnvelope;
859 if (drawEnvelope) {
861 context, mid, env, zoomMin, zoomMax, dB, dBRange, highlightEnvelope);
863 context, mid, dB, dBRange, zoomMin, zoomMax, true, rect.x - mid.x);
864 }
865
866 // Draw arrows on the left side if the track extends to the left of the
867 // beginning of time. :)
868 if (trackRectT0 == 0.0 && playStartTime < 0.0)
869 {
871 }
872 {
873 auto clipRect = ClipParameters::GetClipRect(clip, zoomInfo, rect);
874 TrackArt::DrawClipEdges(dc, clipRect, selected);
875 }
876}
EffectDistortionSettings params
Definition: Distortion.cpp:77
static Settings & settings()
Definition: TrackInfo.cpp:47
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)
Envelope * GetEnvelope() const
Piecewise linear or piecewise exponential function from double to double.
Definition: Envelope.h:72
@ WaveformView
Time required to draw a single clip.
static Stopwatch CreateStopwatch(SectionID section) noexcept
Create a Stopwatch for the section specified.
static bool IsSelectedOrSyncLockSelected(const Track &track)
Definition: SyncLock.cpp:104
static TrackArtist * Get(TrackPanelDrawingContext &)
Definition: TrackArtist.cpp:69
WaveTrack & GetTrack()
Definition: WaveTrack.h:840
static bool ClipDetailsVisible(const ClipTimes &clip, const ZoomInfo &zoomInfo, const wxRect &viewRect)
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
static WaveformScale & Get(const WaveTrack &track)
Mutative access to attachment even if the track argument is const.
static WaveformSettings & Get(const WaveTrack &track)
double SnapToSample(double t) const
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
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 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 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)
static wxRect GetClipRect(const ClipTimes &clip, const ZoomInfo &zoomInfo, const wxRect &viewRect, bool *outShowSamples=nullptr)
static WaveColorAttachment & Get(WaveClip &clip)

References WaveChannelView::ClipDetailsVisible(), FrameStatistics::CreateStopwatch(), TrackPanelDrawingContext::dc, TrackArt::DrawClipEdges(), TrackArt::DrawClipFolded(), DrawEnvelope(), DrawIndividualSamples(), TrackArt::DrawNegativeOffsetTrackArrows(), EnvelopeEditor::DrawPoints(), DrawWaveform(), DrawWaveformBackground(), WaveformSettings::Get(), WaveformScale::Get(), TrackArtist::Get(), WaveColorAttachment::Get(), ClipParameters::GetClipRect(), WaveColorAttachment::GetColorIndex(), WaveClipChannel::GetEnvelope(), EnvelopeHandle::GetEnvelope(), CommonChannelView::GetEnvelopeValues(), WaveClipChannel::GetPlayStartTime(), WaveClipChannel::GetRate(), WaveClipChannel::GetStretchRatio(), WaveChannel::GetTrack(), SyncLock::IsSelectedOrSyncLockSelected(), params, anonymous_namespace{ClipSegmentTest.cpp}::sampleRate, settings(), WideSampleSequence::SnapToSample(), TrackPanelDrawingContext::target, and FrameStatistics::WaveformView.

Referenced by WaveformView::DoDraw().

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

◆ DrawEnvelope()

void anonymous_namespace{WaveformView.cpp}::DrawEnvelope ( TrackPanelDrawingContext context,
const wxRect &  rect,
const double  env[],
float  zoomMin,
float  zoomMax,
bool  dB,
float  dBRange,
bool  highlight 
)

Definition at line 702 of file WaveformView.cpp.

706{
707 auto &dc = context.dc;
708
709 int h = rect.height;
710
711 auto &pen = highlight ? AColor::uglyPen : AColor::envelopePen;
712 dc.SetPen( pen );
713
714 for (int x0 = 0; x0 < rect.width; ++x0) {
715 int cenvTop = GetWaveYPos(env[x0], zoomMin, zoomMax,
716 h, dB, true, dBRange, true);
717
718 int cenvBot = GetWaveYPos(-env[x0], zoomMin, zoomMax,
719 h, dB, true, dBRange, true);
720
721 int envTop = GetWaveYPos(env[x0], zoomMin, zoomMax,
722 h, dB, true, dBRange, false);
723
724 int envBot = GetWaveYPos(-env[x0], zoomMin, zoomMax,
725 h, dB, true, dBRange, false);
726
727 // Make the collision at zero actually look solid
728 if (cenvBot - cenvTop < 9) {
729 int value = (int)((zoomMax / (zoomMax - zoomMin)) * h);
730 cenvTop = value - 4;
731 cenvBot = value + 4;
732 }
733
734 DrawEnvLine( context, rect, x0, envTop, cenvTop, true );
735 DrawEnvLine( context, rect, x0, envBot, cenvBot, false );
736 }
737}
int GetWaveYPos(float value, float min, float max, int height, bool dB, bool outer, float dBr, bool clip)
Definition: TrackArt.cpp:66
static wxPen uglyPen
Definition: AColor.h:139
static wxPen envelopePen
Definition: AColor.h:115
void DrawEnvLine(TrackPanelDrawingContext &context, const wxRect &rect, int x0, int y0, int cy, bool top)

References TrackPanelDrawingContext::dc, DrawEnvLine(), AColor::envelopePen, GetWaveYPos(), and AColor::uglyPen.

Referenced by DrawClipWaveform().

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

◆ DrawEnvLine()

void anonymous_namespace{WaveformView.cpp}::DrawEnvLine ( TrackPanelDrawingContext context,
const wxRect &  rect,
int  x0,
int  y0,
int  cy,
bool  top 
)

Definition at line 673 of file WaveformView.cpp.

676{
677 auto &dc = context.dc;
678
679 int xx = rect.x + x0;
680 int yy = rect.y + cy;
681
682 if (y0 < 0) {
683 if (x0 % 4 != 3) {
684 AColor::Line(dc, xx, yy, xx, yy + 3);
685 }
686 }
687 else if (y0 > rect.height) {
688 if (x0 % 4 != 3) {
689 AColor::Line(dc, xx, yy - 3, xx, yy);
690 }
691 }
692 else {
693 if (top) {
694 AColor::Line(dc, xx, yy, xx, yy + 3);
695 }
696 else {
697 AColor::Line(dc, xx, yy - 3, xx, yy);
698 }
699 }
700}
static void Line(wxDC &dc, wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
Definition: AColor.cpp:185

References TrackPanelDrawingContext::dc, and AColor::Line().

Referenced by DrawEnvelope().

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

◆ DrawIndividualSamples()

void anonymous_namespace{WaveformView.cpp}::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 
)

Definition at line 545 of file WaveformView.cpp.

552{
553 const Envelope &envelope = clip.GetEnvelope();
554 auto &dc = context.dc;
555 const auto artist = TrackArtist::Get(context);
556 const auto &zoomInfo = *artist->pZoomInfo;
557
558 const double toffset = clip.GetPlayStartTime();
559 const double rate = clip.GetRate() / clip.GetStretchRatio();
560 const double t0 = std::max(0.0, zoomInfo.PositionToTime(0, -leftOffset) - toffset);
561 const auto s0 = sampleCount(floor(t0 * rate));
562 const auto snSamples = clip.GetVisibleSampleCount();
563 if (s0 > snSamples)
564 return;
565
566 const double t1 = zoomInfo.PositionToTime(rect.width - 1, -leftOffset) - toffset;
567 const auto s1 = sampleCount(ceil(t1 * rate));
568
569 // Assume size_t will not overflow, else we wouldn't be here drawing the
570 // few individual samples
571 auto slen = std::min(snSamples - s0, s1 - s0 + 1).as_size_t();
572
573 if (slen <= 0)
574 return;
575
576 Floats buffer{ size_t(slen) };
577 clip.GetSamples((samplePtr)buffer.get(), floatSample, s0, slen,
578 // Suppress exceptions in this drawing operation:
579 false);
580
581 ArrayOf<int> xpos{ size_t(slen) };
582 ArrayOf<int> ypos{ size_t(slen) };
583 ArrayOf<int> clipped;
584 int clipcnt = 0;
585
586 const auto bShowClipping = artist->mShowClipping;
587 if (bShowClipping)
588 clipped.reinit( size_t(slen) );
589
590 const auto &muteSamplePen = artist->muteSamplePen;
591 const auto &samplePen = artist->samplePen;
592 auto &pen = highlight ? AColor::uglyPen : muted ? muteSamplePen : samplePen;
593 dc.SetPen( pen );
594
595 for (decltype(slen) s = 0; s < slen; s++) {
596 const double time = toffset + (s + s0).as_double() / rate;
597 const int xx = // An offset into the rectangle rect
598 std::max(-10000, std::min(10000,
599 (int)(zoomInfo.TimeToPosition(time, -leftOffset))));
600 xpos[s] = xx;
601
602 // Calculate sample as it would be rendered, so quantize time
603 double value = envelope.GetValue(time, 1.0 / clip.GetRate());
604 const double tt = buffer[s] * value;
605
606 if (clipped && bShowClipping && ((tt <= -MAX_AUDIO) || (tt >= MAX_AUDIO)))
607 clipped[clipcnt++] = xx;
608 ypos[s] =
609 std::max(-1,
610 std::min(rect.height,
611 GetWaveYPos(tt, zoomMin, zoomMax,
612 rect.height, dB, true, dBRange, false)));
613 }
614
615
616 if (showPoints) {
617 // Draw points where spacing is enough
618 const auto bigPoints = artist->bigPoints;
619 const int tickSize = bigPoints ? 4 : 3;// Bigger ellipses when draggable.
620 wxRect pr;
621 pr.width = tickSize;
622 pr.height = tickSize;
623 //different colour when draggable.
624 const auto &dragsampleBrush = artist->dragsampleBrush;
625 const auto &sampleBrush = artist->sampleBrush;
626 auto &brush = highlight
628 : bigPoints ? dragsampleBrush : sampleBrush;
629 dc.SetBrush( brush );
630 for (decltype(slen) s = 0; s < slen; s++) {
631 if (ypos[s] >= 0 && ypos[s] < rect.height) {
632 pr.x = rect.x + xpos[s] - tickSize/2;
633 pr.y = rect.y + ypos[s] - tickSize/2;
634 dc.DrawEllipse(pr);
635 }
636 }
637 }
638
639 const auto sampleDisplay = artist->mSampleDisplay;
640 if (showPoints &&
641 (sampleDisplay == (int) WaveChannelViewConstants::StemPlot)
642 ){
643 // Draw vertical lines
644 int yZero = GetWaveYPos(0.0, zoomMin, zoomMax, rect.height, dB, true, dBRange, false);
645 yZero = rect.y + std::max(-1, std::min(rect.height, yZero));
646 for (decltype(slen) s = 0; s < slen; s++) {
647 AColor::Line(dc,
648 rect.x + xpos[s], rect.y + ypos[s],
649 rect.x + xpos[s], yZero);
650 }
651 }
652 else {
653 // Connect samples with straight lines
654 for (decltype(slen) s = 0; s < slen - 1; s++) {
655 AColor::Line(dc,
656 rect.x + xpos[s], rect.y + ypos[s],
657 rect.x + xpos[s + 1], rect.y + ypos[s + 1]);
658 }
659 }
660
661 // Draw clipping
662 if (clipcnt) {
663 const auto &muteClippedPen = artist->muteClippedPen;
664 const auto &clippedPen = artist->clippedPen;
665 dc.SetPen(muted ? muteClippedPen : clippedPen);
666 while (--clipcnt >= 0) {
667 auto s = clipped[clipcnt];
668 AColor::Line(dc, rect.x + s, rect.y, rect.x + s, rect.y + rect.height);
669 }
670 }
671}
int min(int a, int b)
#define MAX_AUDIO
Definition: MemoryX.h:341
constexpr sampleFormat floatSample
Definition: SampleFormat.h:45
char * samplePtr
Definition: SampleFormat.h:57
static wxBrush uglyBrush
Definition: AColor.h:140
void reinit(Integral count, bool initialize=false)
Definition: MemoryX.h:59
double GetValue(double t, double sampleDur=0) const
Get envelope value at time t.
Definition: Envelope.cpp:880
sampleCount GetVisibleSampleCount() const override
Definition: WaveClip.cpp:188
bool GetSamples(samplePtr buffer, sampleFormat format, sampleCount start, size_t len, bool mayThrow=true) const
Definition: WaveClip.cpp:115
Positions or offsets within audio files need a wide type.
Definition: SampleCount.h:19

References TrackPanelDrawingContext::dc, floatSample, TrackArtist::Get(), WaveClipChannel::GetEnvelope(), WaveClipChannel::GetPlayStartTime(), WaveClipChannel::GetRate(), WaveClipChannel::GetSamples(), WaveClipChannel::GetStretchRatio(), Envelope::GetValue(), WaveClipChannel::GetVisibleSampleCount(), GetWaveYPos(), AColor::Line(), MAX_AUDIO, min(), ArrayOf< X >::reinit(), WaveChannelViewConstants::StemPlot, AColor::uglyBrush, and AColor::uglyPen.

Referenced by DrawClipWaveform().

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

◆ DrawTimeSlider()

void anonymous_namespace{WaveformView.cpp}::DrawTimeSlider ( TrackPanelDrawingContext context,
const wxRect &  rect,
bool  rightwards,
bool  highlight 
)

Definition at line 878 of file WaveformView.cpp.

881{
882 auto &dc = context.dc;
883
884 const int border = 3; // 3 pixels all round.
885 const int width = 6; // width of the drag box.
886 const int taper = 6; // how much the box tapers by.
887 const int barSpacing = 4; // how far apart the bars are.
888 const int barWidth = 3;
889 const int xFlat = 3;
890
891 //Enough space to draw in?
892 if (rect.height <= ((taper+border + barSpacing) * 2)) {
893 return;
894 }
895 if (rect.width <= (width * 2 + border * 3)) {
896 return;
897 }
898
899 // The draggable box is tapered towards the direction you drag it.
900 int leftTaper = rightwards ? 0 : 6;
901 int rightTaper = rightwards ? 6 : 0;
902
903 int xLeft = rightwards ? (rect.x + border - 2)
904 : (rect.x + rect.width + 1 - (border + width));
905 int yTop = rect.y + border;
906 int yBot = rect.y + rect.height - border - 1;
907
908 AColor::Light(&dc, false, highlight);
909 AColor::Line(dc, xLeft, yBot - leftTaper, xLeft, yTop + leftTaper);
910 AColor::Line(dc, xLeft, yTop + leftTaper, xLeft + xFlat, yTop);
911 AColor::Line(dc, xLeft + xFlat, yTop, xLeft + width, yTop + rightTaper);
912
913 AColor::Dark(&dc, false, highlight);
914 AColor::Line(dc, xLeft + width, yTop + rightTaper, xLeft + width, yBot - rightTaper);
915 AColor::Line(dc, xLeft + width, yBot - rightTaper, xLeft + width-xFlat, yBot);
916 AColor::Line(dc, xLeft + width - xFlat, yBot, xLeft, yBot - leftTaper);
917
918 int firstBar = yTop + taper + taper / 2;
919 int nBars = (yBot - yTop - taper * 3) / barSpacing + 1;
920 xLeft += (width - barWidth + 1) / 2;
921 int yy;
922 int i;
923
924 AColor::Light(&dc, false, highlight);
925 for (i = 0;i < nBars; i++) {
926 yy = firstBar + barSpacing * i;
927 AColor::Line(dc, xLeft, yy, xLeft + barWidth, yy);
928 }
929 AColor::Dark(&dc, false, highlight);
930 for(i = 0;i < nBars; i++){
931 yy = firstBar + barSpacing * i + 1;
932 AColor::Line(dc, xLeft, yy, xLeft + barWidth, yy);
933 }
934}
static void Light(wxDC *dc, bool selected, bool highlight=false)
Definition: AColor.cpp:407
static void Dark(wxDC *dc, bool selected, bool highlight=false)
Definition: AColor.cpp:433

References AColor::Dark(), TrackPanelDrawingContext::dc, AColor::Light(), and AColor::Line().

Referenced by WaveformView::DoDraw().

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

◆ DrawWaveform()

void anonymous_namespace{WaveformView.cpp}::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 
)

Definition at line 315 of file WaveformView.cpp.

320{
321 auto& clip = channelInterval.GetClip();
322 const auto channelIndex = channelInterval.GetChannelIndex();
323
324 const auto artist = TrackArtist::Get(context);
325 const ZoomInfo zoomInfo(0.0, artist->pZoomInfo->GetZoom());
326
327 auto& clipPainter = WaveformPainter::Get(clip);
328
329 const auto trimLeft = clip.GetTrimLeft();
330 const auto sequenceStartTime = clip.GetSequenceStartTime();
331
332 WavePaintParameters paintParameters;
333
334 paintParameters
336 rect.GetHeight(), zoomMin, zoomMax, artist->mShowClipping)
337 .SetDBParameters(dBRange, dB)
338 .SetBlankColor(ColorFromWXBrush(artist->blankBrush))
340 ColorFromWXPen(muted ? artist->muteSamplePen : artist->samplePen),
341 ColorFromWXPen(muted ? artist->muteSamplePen : artist->selsamplePen))
343 ColorFromWXPen(muted ? artist->muteRmsPen : artist->rmsPen),
344 ColorFromWXPen(muted ? artist->muteRmsPen : artist->rmsPen))
346 ColorFromWXBrush(artist->unselectedBrush),
347 ColorFromWXBrush(artist->selectedBrush))
349 ColorFromWXPen(muted ? artist->muteClippedPen : artist->clippedPen),
350 ColorFromWXPen(muted ? artist->muteClippedPen : artist->clippedPen))
351 .SetEnvelope(clip.GetEnvelope());
352
353 clipPainter.SetSelection(
354 zoomInfo, artist->pSelectedRegion->t0() - sequenceStartTime,
355 artist->pSelectedRegion->t1() - sequenceStartTime,
357
358 clipPainter.Draw(
359 channelIndex, context.dc, paintParameters, zoomInfo, rect, leftOffset,
360 t0 + trimLeft, t1 + trimLeft);
361}
WaveClip & GetClip()
Definition: WaveClip.h:96
size_t GetChannelIndex() const
Definition: WaveClip.h:99
Services * Get()
Fetch the global instance, or nullptr if none is yet installed.
Definition: BasicUI.cpp:200
graphics::Color ColorFromWXPen(const wxPen &pen)
graphics::Color ColorFromWXBrush(const wxBrush &brush)
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.

References ColorFromWXBrush(), ColorFromWXPen(), TrackPanelDrawingContext::dc, BasicUI::Get(), TrackArtist::Get(), WaveClipChannel::GetChannelIndex(), WaveClipChannel::GetClip(), SyncLock::IsSelectedOrSyncLockSelected(), WavePaintParameters::SetBackgroundColors(), WavePaintParameters::SetBlankColor(), WavePaintParameters::SetClippingColors(), WavePaintParameters::SetDBParameters(), WavePaintParameters::SetDisplayParameters(), WavePaintParameters::SetEnvelope(), WavePaintParameters::SetRMSColors(), and WavePaintParameters::SetSampleColors().

Referenced by DrawClipWaveform().

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

◆ DrawWaveformBackground()

void anonymous_namespace{WaveformView.cpp}::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 
)

Definition at line 365 of file WaveformView.cpp.

374{
375 auto &dc = context.dc;
376 const auto artist = TrackArtist::Get( context );
377 const auto &zoomInfo = *artist->pZoomInfo;
378
379 // Visually (one vertical slice of the waveform background, on its side;
380 // the "*" is the actual waveform background we're drawing
381 //
382 //1.0 0.0 -1.0
383 // |--------------------------------|--------------------------------|
384 // *************** ***************
385 // | | | |
386 // maxtop maxbot mintop minbot
387
388 int h = rect.height;
389 int halfHeight = wxMax(h / 2, 1);
390 int maxtop, lmaxtop = 0;
391 int mintop, lmintop = 0;
392 int maxbot, lmaxbot = 0;
393 int minbot, lminbot = 0;
394 bool sel, lsel = false;
395 int xx, lx = 0;
396 int l, w;
397
398 const auto &blankBrush = artist->blankBrush;
399 const auto &selectedBrush = artist->selectedBrush;
400 const auto &unselectedBrush = artist->unselectedBrush;
401
402 dc.SetPen(*wxTRANSPARENT_PEN);
403 dc.SetBrush(blankBrush);
404 dc.DrawRectangle(rect);
405
406 // Bug 2389 - always draw at least one pixel of selection.
407 int selectedX = zoomInfo.TimeToPosition(t0, -leftOffset);
408
409 double time = zoomInfo.PositionToTime(0, -leftOffset), nextTime;
410 for (xx = 0; xx < rect.width; ++xx, time = nextTime) {
411 nextTime = zoomInfo.PositionToTime(xx + 1, -leftOffset);
412 // First we compute the truncated shape of the waveform background.
413 // If drawEnvelope is true, then we compute the lower border of the
414 // envelope.
415
416 maxtop = GetWaveYPos(env[xx], zoomMin, zoomMax,
417 h, dB, true, dBRange, true);
418 maxbot = GetWaveYPos(env[xx], zoomMin, zoomMax,
419 h, dB, false, dBRange, true);
420
421 mintop = GetWaveYPos(-env[xx], zoomMin, zoomMax,
422 h, dB, false, dBRange, true);
423 minbot = GetWaveYPos(-env[xx], zoomMin, zoomMax,
424 h, dB, true, dBRange, true);
425
426 // Make sure it's odd so that a that max and min mirror each other
427 mintop +=1;
428 minbot +=1;
429
430 const auto drawEnvelope = artist->drawEnvelope;
431 if (!drawEnvelope || maxbot > mintop) {
432 maxbot = halfHeight;
433 mintop = halfHeight;
434 }
435
436 sel = (t0 <= time && nextTime < t1);
437 sel = sel || (xx == selectedX);
438 // We don't draw selection color for sync-lock selected tracks.
439 sel = sel && !bIsSyncLockSelected;
440
441 if (lmaxtop == maxtop &&
442 lmintop == mintop &&
443 lmaxbot == maxbot &&
444 lminbot == minbot &&
445 lsel == sel) {
446 continue;
447 }
448
449 dc.SetBrush(lsel ? selectedBrush : unselectedBrush);
450
451 l = rect.x + lx;
452 w = xx - lx;
453 if (lmaxbot < lmintop - 1) {
454 dc.DrawRectangle(l, rect.y + lmaxtop, w, lmaxbot - lmaxtop);
455 dc.DrawRectangle(l, rect.y + lmintop, w, lminbot - lmintop);
456 }
457 else {
458 dc.DrawRectangle(l, rect.y + lmaxtop, w, lminbot - lmaxtop);
459 }
460
461 if (highlightEnvelope && lmaxbot < lmintop - 1) {
462 dc.SetBrush( AColor::uglyBrush );
463 dc.DrawRectangle(l, rect.y + lmaxbot, w, lmintop - lmaxbot);
464 }
465
466 lmaxtop = maxtop;
467 lmintop = mintop;
468 lmaxbot = maxbot;
469 lminbot = minbot;
470 lsel = sel;
471 lx = xx;
472 }
473
474 dc.SetBrush(lsel ? selectedBrush : unselectedBrush);
475 l = rect.x + lx;
476 w = xx - lx;
477 if (lmaxbot < lmintop - 1) {
478 dc.DrawRectangle(l, rect.y + lmaxtop, w, lmaxbot - lmaxtop);
479 dc.DrawRectangle(l, rect.y + lmintop, w, lminbot - lmintop);
480 }
481 else {
482 dc.DrawRectangle(l, rect.y + lmaxtop, w, lminbot - lmaxtop);
483 }
484 if (highlightEnvelope && lmaxbot < lmintop - 1) {
485 dc.SetBrush( AColor::uglyBrush );
486 dc.DrawRectangle(l, rect.y + lmaxbot, w, lmintop - lmaxbot);
487 }
488
489 // If sync-lock selected, draw in linked graphics.
490 if (bIsSyncLockSelected && t0 < t1) {
491 const int begin = std::max(0, std::min(rect.width, (int)(zoomInfo.TimeToPosition(t0, -leftOffset))));
492 const int end = std::max(0, std::min(rect.width, (int)(zoomInfo.TimeToPosition(t1, -leftOffset))));
494 { rect.x + begin, rect.y, end - 1 - begin, rect.height } );
495 }
496
497 //OK, the display bounds are between min and max, which
498 //is spread across rect.height. Draw the line at the proper place.
499 if (zeroLevelYCoordinate >= rect.GetTop() &&
500 zeroLevelYCoordinate <= rect.GetBottom()) {
501 dc.SetPen(*wxBLACK_PEN);
502 AColor::Line(dc, rect.x, zeroLevelYCoordinate,
503 rect.x + rect.width - 1, zeroLevelYCoordinate);
504 }
505}
AUDACITY_DLL_API void DrawSyncLockTiles(TrackPanelDrawingContext &context, const wxRect &rect)
Definition: TrackArt.cpp:365
const char * end(const char *str) noexcept
Definition: StringUtils.h:106
const char * begin(const char *str) noexcept
Definition: StringUtils.h:101

References details::begin(), TrackPanelDrawingContext::dc, TrackArt::DrawSyncLockTiles(), details::end(), TrackArtist::Get(), GetWaveYPos(), AColor::Line(), min(), and AColor::uglyBrush.

Referenced by DrawClipWaveform().

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

◆ FindWavePortions()

void anonymous_namespace{WaveformView.cpp}::FindWavePortions ( std::vector< WavePortion > &  portions,
const wxRect &  rect,
const ZoomInfo zoomInfo,
const ClipParameters params 
)

Definition at line 516 of file WaveformView.cpp.

519{
520 // If there is no fisheye, then only one rectangle has nonzero width.
521 // If there is a fisheye, make rectangles for before and after
522 // (except when they are squeezed to zero width), and at least one for inside
523 // the fisheye.
524
525 const auto intervals = zoomInfo.FindIntervals(rect.width, rect.x);
526 ZoomInfo::Intervals::const_iterator it = intervals.begin(), end = intervals.end(), prev;
527 wxASSERT(it != end && it->position == rect.x);
528 const int rightmost = rect.x + rect.width;
529 for (int left = rect.x; left < rightmost;) {
530 while (it != end && it->position <= left)
531 prev = it++;
532 if (it == end)
533 break;
534 const int right = std::max(left, (int)(it->position));
535 const int width = right - left;
536 if (width > 0)
537 portions.push_back(
538 WavePortion(left, rect.y, width, rect.height,
539 prev->averageZoom, prev->inFisheye)
540 );
541 left = right;
542 }
543}
Intervals FindIntervals(int64 width, int64 origin=0) const
Definition: ZoomInfo.cpp:99

References details::end(), and ZoomInfo::FindIntervals().

Here is the call graph for this function:

◆ GetWaveColorStr()

const TranslatableString anonymous_namespace{WaveformView.cpp}::GetWaveColorStr ( int  colorIndex)

Definition at line 1065 of file WaveformView.cpp.

1066{
1067 return XXO("Instrument %i").Format( colorIndex+1 );
1068}
XXO("&Cut/Copy/Paste Toolbar")

References XXO().

Referenced by WaveColorMenuTable::OnWaveColorChange().

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

Variable Documentation

◆ sAttachment

PopupMenuTable::AttachedItem anonymous_namespace{WaveformView.cpp}::sAttachment
Initial value:
{
{ "SubViews/Extra" },
std::make_unique<PopupMenuSection>( "WaveColor",
PopupMenuTable::Adapt<WaveTrackPopupMenuTable>(
const auto pTrack = &table.FindWaveTrack();
const auto &view = WaveChannelView::GetFirst(*pTrack);
const auto displays = view.GetDisplays();
bool hasWaveform = (displays.end() != std::find(
displays.begin(), displays.end(),
WaveChannelViewConstants::Waveform, {} }
) );
return hasWaveform
.Get(table.mpData))
: nullptr;
} ) )
}
WaveTrackPopupMenuTable & GetWaveTrackMenuTable()
static WaveChannelView & GetFirst(WaveTrack &wt)
Get the view of the first channel.
std::unique_ptr< detail::IndirectItem< Item > > Indirect(const std::shared_ptr< Item > &ptr)
A convenience function.
Definition: Registry.h:175
static WaveColorMenuTable & Instance()
WaveTrack & FindWaveTrack() const
PlayableTrackControls::InitMenuData * mpData

Definition at line 1132 of file WaveformView.cpp.