Audacity 3.2.0
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Static Private Member Functions | List of all members
WaveformView Class Referencefinal

#include <WaveformView.h>

Inheritance diagram for WaveformView:
[legend]
Collaboration diagram for WaveformView:
[legend]

Public Member Functions

 ~WaveformView () override
 
const TypeSubViewType () const override
 
std::shared_ptr< TrackVRulerControlsDoGetVRulerControls () override
 
 WaveTrackSubView (WaveTrackView &waveTrackView)
 
- Public Member Functions inherited from WaveTrackSubView
 WaveTrackSubView (WaveTrackView &waveTrackView)
 
virtual const TypeSubViewType () const =0
 
virtual void CopyToSubView (WaveTrackSubView *destSubView) const
 
std::pair< bool, std::vector< UIHandlePtr > > DoDetailedHitTest (const TrackPanelMouseState &state, const AudacityProject *pProject, int currentTool, bool bMultiTool, const std::shared_ptr< WaveTrack > &wt)
 
- Public Member Functions inherited from CommonTrackView
std::shared_ptr< TrackPanelCellContextMenuDelegate () override
 
std::vector< UIHandlePtrHitTest (const TrackPanelMouseState &, const AudacityProject *pProject) final override
 
void TimeShiftHitTest ()
 
virtual int GetMinimizedHeight () const override
 
 TrackView (const std::shared_ptr< Track > &pTrack)
 
- Public Member Functions inherited from TrackView
 TrackView (const std::shared_ptr< Track > &pTrack)
 
virtual ~TrackView ()=0
 
void CopyTo (Track &track) const override
 Copy state, for undo/redo purposes. More...
 
bool GetMinimized () const
 
void SetMinimized (bool minimized)
 
int GetCumulativeHeightBefore () const
 
int GetExpandedHeight () const
 
virtual int GetMinimizedHeight () const =0
 
int GetHeight () const
 
void SetCumulativeHeightBefore (int y)
 Set cached value dependent on position within the track list. More...
 
void SetExpandedHeight (int height)
 
std::shared_ptr< TrackVRulerControlsGetVRulerControls ()
 
std::shared_ptr< const TrackVRulerControlsGetVRulerControls () const
 
virtual std::shared_ptr< CommonTrackCellGetAffordanceControls ()
 
void WriteXMLAttributes (XMLWriter &) const override
 Serialize persistent attributes. More...
 
bool HandleXMLAttribute (const std::string_view &attr, const XMLAttributeValueView &valueView) override
 Deserialize an attribute, returning true if recognized. More...
 
virtual Refinement GetSubViews (const wxRect &rect)
 
virtual bool IsSpectral () const
 
virtual void DoSetMinimized (bool isMinimized)
 
- Public Member Functions inherited from CommonTrackCell
 CommonTrackCell (const std::shared_ptr< Track > &pTrack)
 
 ~CommonTrackCell ()
 
std::shared_ptr< TrackDoFindTrack () override
 
void Reparent (const std::shared_ptr< Track > &parent) override
 Object may be shared among tracks but hold a special back-pointer to one of them; reassign it. More...
 
- Public Member Functions inherited from CommonTrackPanelCell
 CommonTrackPanelCell ()
 
virtual ~CommonTrackPanelCell ()=0
 
HitTestPreview DefaultPreview (const TrackPanelMouseState &, const AudacityProject *) override
 
std::shared_ptr< TrackFindTrack ()
 
std::shared_ptr< const TrackFindTrack () const
 
virtual std::vector< MenuItemGetMenuItems (const wxRect &rect, const wxPoint *pPosition, AudacityProject *pProject)
 Return a list of items for DoContextMenu() (empties for separators) More...
 
- Public Member Functions inherited from TrackPanelCell
 TrackPanelCell ()=default
 
 TrackPanelCell (const TrackPanelCell &) PROHIBITED
 
TrackPanelCelloperator= (const TrackPanelCell &) PROHIBITED
 
virtual ~TrackPanelCell ()=0
 
virtual HitTestPreview DefaultPreview (const TrackPanelMouseState &state, const AudacityProject *pProject)
 
virtual std::vector< UIHandlePtrHitTest (const TrackPanelMouseState &state, const AudacityProject *pProject)=0
 
virtual unsigned HandleWheelRotation (const TrackPanelMouseEvent &event, AudacityProject *pProject)
 
virtual std::shared_ptr< TrackPanelCellContextMenuDelegate ()
 
virtual unsigned DoContextMenu (const wxRect &rect, wxWindow *pParent, const wxPoint *pPosition, AudacityProject *pProject)
 
virtual unsigned CaptureKey (wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent, AudacityProject *project)
 
virtual unsigned KeyDown (wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent, AudacityProject *project)
 
virtual unsigned KeyUp (wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent, AudacityProject *project)
 
virtual unsigned Char (wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent, AudacityProject *project)
 
virtual unsigned LoseFocus (AudacityProject *project)
 
- Public Member Functions inherited from TrackPanelNode
 TrackPanelNode ()
 
virtual ~TrackPanelNode ()=0
 
- Public Member Functions inherited from TrackPanelDrawable
virtual ~TrackPanelDrawable ()=0
 
virtual void Draw (TrackPanelDrawingContext &context, const wxRect &rect, unsigned iPass)
 
virtual wxRect DrawingArea (TrackPanelDrawingContext &context, const wxRect &rect, const wxRect &panelRect, unsigned iPass)
 
- Public Member Functions inherited from TrackAttachment
virtual ~TrackAttachment ()
 
virtual void CopyTo (Track &track) const
 Copy state, for undo/redo purposes. More...
 
virtual void Reparent (const std::shared_ptr< Track > &parent)
 Object may be shared among tracks but hold a special back-pointer to one of them; reassign it. More...
 
virtual void WriteXMLAttributes (XMLWriter &) const
 Serialize persistent attributes. More...
 
virtual bool HandleXMLAttribute (const std::string_view &attr, const XMLAttributeValueView &valueView)
 Deserialize an attribute, returning true if recognized. More...
 
- Public Member Functions inherited from ClientData::Base
virtual ~Base ()
 

Protected Member Functions

void DoSetMinimized (bool minimized) override
 
- Protected Member Functions inherited from WaveTrackSubView
std::weak_ptr< WaveTrackViewGetWaveTrackView () const
 
std::vector< MenuItemGetMenuItems (const wxRect &rect, const wxPoint *pPosition, AudacityProject *pProject) override
 Return a list of items for DoContextMenu() (empties for separators) More...
 
virtual std::vector< UIHandlePtrDetailedHitTest (const TrackPanelMouseState &, const AudacityProject *pProject, int currentTool, bool bMultiTool)=0
 
virtual std::shared_ptr< TrackVRulerControlsDoGetVRulerControls ()=0
 
- Protected Member Functions inherited from CommonTrackPanelCell
virtual std::shared_ptr< TrackDoFindTrack ()=0
 
unsigned DoContextMenu (const wxRect &rect, wxWindow *pParent, const wxPoint *pPosition, AudacityProject *pProject) override
 
unsigned HandleWheelRotation (const TrackPanelMouseEvent &event, AudacityProject *pProject) override
 

Protected Attributes

std::weak_ptr< SampleHandlemSampleHandle
 
std::weak_ptr< EnvelopeHandlemEnvelopeHandle
 
- Protected Attributes inherited from CommonTrackView
std::weak_ptr< SelectHandlemSelectHandle
 
- Protected Attributes inherited from TrackView
std::shared_ptr< TrackVRulerControlsmpVRulerControls
 

Private Member Functions

 WaveformView (const WaveformView &)=delete
 
WaveformViewoperator= (const WaveformView &)=delete
 
void Draw (TrackPanelDrawingContext &context, const wxRect &rect, unsigned iPass) override
 
std::vector< UIHandlePtrDetailedHitTest (const TrackPanelMouseState &state, const AudacityProject *pProject, int currentTool, bool bMultiTool) override
 

Static Private Member Functions

static void DoDraw (TrackPanelDrawingContext &context, const WaveTrack *track, const WaveClip *selectedClip, const wxRect &rect, bool muted)
 

Additional Inherited Members

- Public Types inherited from WaveTrackSubView
using Display = WaveTrackViewConstants::Display
 
using Type = WaveTrackSubViewType
 
- Public Types inherited from TrackView
enum  : unsigned { DefaultHeight = 150 }
 
using Refinement = std::vector< std::pair< wxCoord, std::shared_ptr< TrackView > > >
 
- Static Public Member Functions inherited from CommonTrackView
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. More...
 
- Static Public Member Functions inherited from TrackView
static int GetTrackHeight (const Track *pTrack)
 
static int GetChannelGroupHeight (const Track *pTrack)
 
static int GetCumulativeHeight (const Track *pTrack)
 
static int GetTotalHeight (const TrackList &list)
 
static TrackViewGet (Track &)
 
static const TrackViewGet (const Track &)
 
static TrackViewFind (Track *)
 
static const TrackViewFind (const Track *)
 
- Static Public Member Functions inherited from TrackPanelDrawable
static wxRect MaximizeWidth (const wxRect &rect, const wxRect &panelRect)
 
static wxRect MaximizeHeight (const wxRect &rect, const wxRect &panelRect)
 
- Public Attributes inherited from CommonTrackView
std::weak_ptr< TimeShiftHandlemTimeShiftHandle
 
- Static Protected Member Functions inherited from WaveTrackSubView
static void DrawBoldBoundaries (TrackPanelDrawingContext &context, const WaveTrack *track, const wxRect &rect)
 

Detailed Description

Definition at line 20 of file WaveformView.h.

Constructor & Destructor Documentation

◆ WaveformView()

WaveformView::WaveformView ( const WaveformView )
privatedelete

◆ ~WaveformView()

WaveformView::~WaveformView ( )
overridedefault

Member Function Documentation

◆ DetailedHitTest()

std::vector< UIHandlePtr > WaveformView::DetailedHitTest ( const TrackPanelMouseState state,
const AudacityProject pProject,
int  currentTool,
bool  bMultiTool 
)
overrideprivatevirtual

Implements CommonTrackView.

Definition at line 52 of file WaveformView.cpp.

55{
56 auto &view = *this;
57 const auto pTrack =
58 std::static_pointer_cast< WaveTrack >( view.FindTrack() );
59
61 st, pProject, currentTool, bMultiTool, pTrack);
62 auto &results = pair.second;
63
64 if (!pair.first) {
65 UIHandlePtr result;
66
67 if (bMultiTool) {
68 // Conditional hit tests
69 // If Tools toolbar were eliminated, we would keep these
70 // The priority of these, in case more than one might apply at one
71 // point, seems arbitrary
72 if (NULL != (result = EnvelopeHandle::WaveTrackHitTest(
73 view.mEnvelopeHandle, st.state, st.rect,
74 pProject, pTrack )))
75 results.push_back(result);
76 if (NULL != (result = TimeShiftHandle::HitTest(
77 view.mTimeShiftHandle, st.state, st.rect, pTrack )))
78 // This is the hit test on the "grips" drawn left and
79 // right in Multi only
80 results.push_back(result);
81 if (NULL != (result = SampleHandle::HitTest(
82 view.mSampleHandle, st.state, st.rect,
83 pProject, pTrack )))
84 results.push_back(result);
85 }
86 else {
87 switch ( currentTool ) {
88 // Unconditional hits appropriate to the tool
89 // If tools toolbar were eliminated, we would eliminate these
91 auto &viewInfo = ViewInfo::Get(*pProject);
92 auto time =
93 viewInfo.PositionToTime(st.state.m_x, st.rect.GetX());
94 auto envelope = pTrack->GetEnvelopeAtTime(time);
96 view.mEnvelopeHandle, envelope, false);
97 break;
98 }
101 view.mSampleHandle, st.state, pTrack );
102 break;
103 default:
104 result = {};
105 break;
106 }
107 if (result)
108 results.push_back(result);
109 }
110 }
111
112 return std::move( results );
113}
std::shared_ptr< UIHandle > UIHandlePtr
Definition: CellularPanel.h:28
static UIHandlePtr WaveTrackHitTest(std::weak_ptr< EnvelopeHandle > &holder, const wxMouseState &state, const wxRect &rect, const AudacityProject *pProject, const std::shared_ptr< WaveTrack > &wt)
static UIHandlePtr HitAnywhere(std::weak_ptr< EnvelopeHandle > &holder, Envelope *envelope, bool timeTrack)
static UIHandlePtr HitAnywhere(std::weak_ptr< SampleHandle > &holder, const wxMouseState &state, const std::shared_ptr< WaveTrack > &pTrack)
static UIHandlePtr HitTest(std::weak_ptr< SampleHandle > &holder, const wxMouseState &state, const wxRect &rect, const AudacityProject *pProject, const std::shared_ptr< WaveTrack > &pTrack)
static UIHandlePtr HitTest(std::weak_ptr< TimeShiftHandle > &holder, const wxMouseState &state, const wxRect &rect, const std::shared_ptr< Track > &pTrack)
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:235
std::pair< bool, std::vector< UIHandlePtr > > DoDetailedHitTest(const TrackPanelMouseState &state, const AudacityProject *pProject, int currentTool, bool bMultiTool, const std::shared_ptr< WaveTrack > &wt)

References WaveTrackSubView::DoDetailedHitTest(), ToolCodes::drawTool, ToolCodes::envelopeTool, ViewInfo::Get(), EnvelopeHandle::HitAnywhere(), SampleHandle::HitAnywhere(), SampleHandle::HitTest(), TimeShiftHandle::HitTest(), TrackPanelMouseState::rect, TrackPanelMouseState::state, and EnvelopeHandle::WaveTrackHitTest().

Here is the call graph for this function:

◆ DoDraw()

void WaveformView::DoDraw ( TrackPanelDrawingContext context,
const WaveTrack track,
const WaveClip selectedClip,
const wxRect &  rect,
bool  muted 
)
staticprivate

Definition at line 995 of file WaveformView.cpp.

1000{
1001 auto &dc = context.dc;
1002 const auto artist = TrackArtist::Get( context );
1003
1004 bool highlight = false;
1005 bool gripHit = false;
1006#ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING
1007 auto target = dynamic_cast<TimeShiftHandle*>(context.target.get());
1008 gripHit = target && target->IsGripHit();
1009 highlight = target && target->GetTrack().get() == track;
1010#endif
1011
1012 const bool dB = !WaveformSettings::Get(*track).isLinear();
1013
1014 const auto &blankSelectedBrush = artist->blankSelectedBrush;
1015 const auto &blankBrush = artist->blankBrush;
1017 context, rect, track, blankSelectedBrush, blankBrush );
1018
1019 for (const auto& clip : track->GetClips())
1020 {
1021 DrawClipWaveform(context, track, clip.get(), rect,
1022 dB, muted, clip.get() == selectedClip);
1023 }
1024 DrawBoldBoundaries( context, track, rect );
1025
1026 const auto drawSliders = artist->drawSliders;
1027 if (drawSliders) {
1028 DrawTimeSlider( context, rect, true, highlight && gripHit ); // directed right
1029 DrawTimeSlider( context, rect, false, highlight && gripHit ); // directed left
1030 }
1031}
bool IsGripHit() const
static TrackArtist * Get(TrackPanelDrawingContext &)
Definition: TrackArtist.cpp:69
WaveClipHolders & GetClips()
Definition: WaveTrack.h:322
static void DrawBoldBoundaries(TrackPanelDrawingContext &context, const WaveTrack *track, const wxRect &rect)
bool isLinear() const
static WaveformSettings & Get(const WaveTrack &track)
AUDACITY_DLL_API void DrawBackgroundWithSelection(TrackPanelDrawingContext &context, const wxRect &rect, const Track *track, const wxBrush &selBrush, const wxBrush &unselBrush, bool useSelection=true)
Definition: TrackArt.cpp:422
void DrawClipWaveform(TrackPanelDrawingContext &context, const WaveTrack *track, const WaveClip *clip, const wxRect &rect, bool dB, bool muted, bool selected)
void DrawTimeSlider(TrackPanelDrawingContext &context, const wxRect &rect, bool rightwards, bool highlight)

References TrackPanelDrawingContext::dc, TrackArt::DrawBackgroundWithSelection(), WaveTrackSubView::DrawBoldBoundaries(), anonymous_namespace{WaveformView.cpp}::DrawClipWaveform(), anonymous_namespace{WaveformView.cpp}::DrawTimeSlider(), WaveformSettings::Get(), TrackArtist::Get(), WaveTrack::GetClips(), TimeShiftHandle::IsGripHit(), WaveformSettings::isLinear(), and TrackPanelDrawingContext::target.

Referenced by Draw().

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

◆ DoGetVRulerControls()

std::shared_ptr< TrackVRulerControls > WaveformView::DoGetVRulerControls ( )
overridevirtual

Implements TrackView.

Definition at line 142 of file WaveformView.cpp.

143{
144 return std::make_shared<WaveformVRulerControls>( shared_from_this() );
145}

◆ DoSetMinimized()

void WaveformView::DoSetMinimized ( bool  minimized)
overrideprotectedvirtual

Reimplemented from TrackView.

Definition at line 115 of file WaveformView.cpp.

116{
117 auto wt = static_cast<WaveTrack*>( FindTrack().get() );
118
119#ifdef EXPERIMENTAL_HALF_WAVE
120 bool bHalfWave;
121 gPrefs->Read(wxT("/GUI/CollapseToHalfWave"), &bHalfWave, false);
122 if( bHalfWave )
123 {
124 auto &cache = WaveformScale::Get(*wt);
125 if (minimized)
126 // Zoom to show fractionally more than the top half of the wave.
127 cache.SetDisplayBounds( -0.01f, 1.0f );
128 else
129 // Zoom out full
130 cache.SetDisplayBounds( -1.0f, 1.0f );
131 }
132#endif
133
134 TrackView::DoSetMinimized( minimized );
135}
wxT("CloseDown"))
FileConfig * gPrefs
Definition: Prefs.cpp:70
std::shared_ptr< Track > FindTrack()
virtual void DoSetMinimized(bool isMinimized)
Definition: TrackView.cpp:141
A Track that contains audio waveform data.
Definition: WaveTrack.h:51
static WaveformScale & Get(const WaveTrack &track)
Mutative access to attachment even if the track argument is const.

References TrackView::DoSetMinimized(), CommonTrackPanelCell::FindTrack(), WaveformScale::Get(), gPrefs, and wxT().

Here is the call graph for this function:

◆ Draw()

void WaveformView::Draw ( TrackPanelDrawingContext context,
const wxRect &  rect,
unsigned  iPass 
)
overrideprivatevirtual

Reimplemented from TrackPanelDrawable.

Definition at line 1033 of file WaveformView.cpp.

1035{
1036 if ( iPass == TrackArtist::PassTracks ) {
1037 auto &dc = context.dc;
1038 // Update cache for locations, e.g. cutlines and merge points
1039 // Bug2588: do this for both channels, even if one is not drawn, so that
1040 // cut-line editing (which depends on the locations cache) works properly.
1041 // If both channels are visible, we will duplicate this effort, but that
1042 // matters little.
1043 for( auto channel:
1044 TrackList::Channels(static_cast<WaveTrack*>(FindTrack().get())) ) {
1045 auto &locationsCache = WaveTrackLocations::Get( *channel );
1046 locationsCache.Update( *channel );
1047 }
1048
1049 const auto wt = std::static_pointer_cast<const WaveTrack>(
1050 FindTrack()->SubstitutePendingChangedTrack());
1051
1052 const auto artist = TrackArtist::Get( context );
1053 const auto hasSolo = artist->hasSolo;
1054 bool muted = (hasSolo || wt->GetMute()) &&
1055 !wt->GetSolo();
1056
1057#if defined(__WXMAC__)
1058 wxAntialiasMode aamode = dc.GetGraphicsContext()->GetAntialiasMode();
1059 dc.GetGraphicsContext()->SetAntialiasMode(wxANTIALIAS_NONE);
1060#endif
1061
1062 auto waveTrackView = GetWaveTrackView().lock();
1063 wxASSERT(waveTrackView.use_count());
1064
1065 auto selectedClip = waveTrackView->GetSelectedClip().lock();
1066 DoDraw(context, wt.get(), selectedClip.get(), rect, muted);
1067
1068#if defined(__WXMAC__)
1069 dc.GetGraphicsContext()->SetAntialiasMode(aamode);
1070#endif
1071 }
1072 WaveTrackSubView::Draw( context, rect, iPass );
1073}
static auto Channels(TrackType *pTrack) -> TrackIterRange< TrackType >
Definition: Track.h:1544
virtual void Draw(TrackPanelDrawingContext &context, const wxRect &rect, unsigned iPass)
const std::vector< Location > & Get() const
std::weak_ptr< WaveTrackView > GetWaveTrackView() const
static void DoDraw(TrackPanelDrawingContext &context, const WaveTrack *track, const WaveClip *selectedClip, const wxRect &rect, bool muted)

References TrackList::Channels(), TrackPanelDrawingContext::dc, DoDraw(), TrackPanelDrawable::Draw(), CommonTrackPanelCell::FindTrack(), WaveTrackLocations::Get(), TrackArtist::Get(), WaveTrackSubView::GetWaveTrackView(), and TrackArtist::PassTracks.

Here is the call graph for this function:

◆ operator=()

WaveformView & WaveformView::operator= ( const WaveformView )
privatedelete

◆ SubViewType()

auto WaveformView::SubViewType ( ) const
overridevirtual

Implements WaveTrackSubView.

Definition at line 137 of file WaveformView.cpp.

138{
139 return sType;
140}
static WaveTrackSubView::Type sType

References sType.

◆ WaveTrackSubView()

WaveTrackSubView::WaveTrackSubView ( WaveTrackView waveTrackView)
explicit

Definition at line 47 of file WaveTrackView.cpp.

881 : CommonTrackView( waveTrackView.FindTrack() )
882{
883 mwWaveTrackView = std::static_pointer_cast<WaveTrackView>(
884 waveTrackView.shared_from_this() );
885}
std::weak_ptr< WaveTrackView > mwWaveTrackView
Definition: WaveTrackView.h:81

Member Data Documentation

◆ mEnvelopeHandle

std::weak_ptr<EnvelopeHandle> WaveformView::mEnvelopeHandle
protected

Definition at line 54 of file WaveformView.h.

◆ mSampleHandle

std::weak_ptr<SampleHandle> WaveformView::mSampleHandle
protected

Definition at line 53 of file WaveformView.h.


The documentation for this class was generated from the following files: