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< ChannelVRulerControlsDoGetVRulerControls () override
 
 WaveChannelSubView (WaveChannelView &waveChannelView)
 
- Public Member Functions inherited from WaveChannelSubView
 WaveChannelSubView (WaveChannelView &waveChannelView)
 
virtual const TypeSubViewType () const =0
 
virtual void CopyToSubView (WaveChannelSubView *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 CommonChannelView
std::shared_ptr< TrackPanelCellContextMenuDelegate () override
 
std::vector< UIHandlePtrHitTest (const TrackPanelMouseState &, const AudacityProject *pProject) final
 
void TimeShiftHitTest ()
 
virtual int GetMinimizedHeight () const override
 
 ChannelView (const std::shared_ptr< Track > &pTrack, size_t iChannel)
 Construct from a track and a channel index. More...
 
- Public Member Functions inherited from ChannelView
 ChannelView (const std::shared_ptr< Track > &pTrack, size_t iChannel)
 Construct from a track and a channel index. More...
 
virtual ~ChannelView ()=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< ChannelVRulerControlsGetVRulerControls ()
 
std::shared_ptr< const ChannelVRulerControlsGetVRulerControls () 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, size_t iChannel)
 Construct from a track and a channel index. More...
 
 CommonTrackCell (ChannelGroup &group, size_t iChannel)
 Construct from a channel group and a channel index. More...
 
 ~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...
 
size_t GetChannelIndex () const
 
std::shared_ptr< ChannelFindChannel ()
 May return null. More...
 
std::shared_ptr< const ChannelFindChannel () const
 May return null. 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 &)=delete
 
TrackPanelCelloperator= (const TrackPanelCell &)=delete
 
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 WaveChannelSubView
std::weak_ptr< WaveChannelViewGetWaveChannelView () 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< ChannelVRulerControlsDoGetVRulerControls ()=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 CommonChannelView
std::weak_ptr< SelectHandlemSelectHandle
 
- Protected Attributes inherited from ChannelView
std::shared_ptr< ChannelVRulerControlsmpVRulerControls
 

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, size_t channel, const WaveTrack &track, const WaveTrack::Interval *selectedClip, const wxRect &rect, bool muted)
 

Additional Inherited Members

- Public Types inherited from WaveChannelSubView
using Display = WaveChannelViewConstants::Display
 
using Type = WaveChannelSubViewType
 
- Public Types inherited from ChannelView
enum  : unsigned { DefaultHeight = 150 }
 
using Refinement = std::vector< std::pair< wxCoord, std::shared_ptr< ChannelView > > >
 
- Static Public Member Functions inherited from CommonChannelView
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 ChannelView
static ChannelViewGet (Channel &channel)
 
static const ChannelViewGet (const Channel &channel)
 
static ChannelViewFind (Channel *pChannel)
 
static const ChannelViewFind (const Channel *pChannel)
 
static int GetChannelGroupHeight (const Track *pTrack)
 
static int GetCumulativeHeight (const Channel *pChannel)
 
static int GetCumulativeHeight (const Track *pTrack)
 
static int GetTotalHeight (const TrackList &list)
 
- 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 CommonChannelView
std::weak_ptr< TimeShiftHandlemTimeShiftHandle
 
- Public Attributes inherited from ChannelView
std::pair< int, int > vrulerSize
 
- Static Protected Member Functions inherited from WaveChannelSubView
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 CommonChannelView.

Definition at line 53 of file WaveformView.cpp.

56{
57 auto &view = *this;
58 const auto pTrack =
59 std::static_pointer_cast< WaveTrack >( view.FindTrack() );
60
62 st, pProject, currentTool, bMultiTool, pTrack);
63 auto &results = pair.second;
64
65 if (!pair.first) {
66 UIHandlePtr result;
67
68 if (bMultiTool) {
69 // Conditional hit tests
70 // If Tools toolbar were eliminated, we would keep these
71 // The priority of these, in case more than one might apply at one
72 // point, seems arbitrary
73 if (NULL != (result = EnvelopeHandle::WaveTrackHitTest(
74 view.mEnvelopeHandle, st.state, st.rect,
75 pProject, pTrack )))
76 results.push_back(result);
77 if (NULL != (result = TimeShiftHandle::HitTest(
78 view.mTimeShiftHandle, st.state, st.rect, pTrack )))
79 // This is the hit test on the "grips" drawn left and
80 // right in Multi only
81 results.push_back(result);
82 if (NULL != (result = SampleHandle::HitTest(
83 view.mSampleHandle, st.state, st.rect,
84 pProject, pTrack )))
85 results.push_back(result);
86 }
87 else {
88 switch ( currentTool ) {
89 // Unconditional hits appropriate to the tool
90 // If tools toolbar were eliminated, we would eliminate these
92 auto &viewInfo = ViewInfo::Get(*pProject);
93 auto time =
94 viewInfo.PositionToTime(st.state.m_x, st.rect.GetX());
95 auto envelope = pTrack->GetEnvelopeAtTime(time);
97 view.mEnvelopeHandle, envelope,
98 std::dynamic_pointer_cast<const Channel>(pTrack),
99 false);
100 break;
101 }
104 view.mSampleHandle, st.state, pTrack );
105 break;
106 default:
107 result = {};
108 break;
109 }
110 if (result)
111 results.push_back(result);
112 }
113 }
114
115 return std::move( results );
116}
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, std::weak_ptr< const Channel > wChannel, 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 WaveChannelSubView::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,
size_t  channel,
const WaveTrack track,
const WaveTrack::Interval selectedClip,
const wxRect &  rect,
bool  muted 
)
staticprivate

Definition at line 947 of file WaveformView.cpp.

952{
953 auto &dc = context.dc;
954 const auto artist = TrackArtist::Get( context );
955
956 bool highlight = false;
957 bool gripHit = false;
958#ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING
959 auto target = dynamic_cast<TimeShiftHandle*>(context.target.get());
960 gripHit = target && target->IsGripHit();
961 highlight = target && target->GetTrack().get() == &track;
962#endif
963
964 const bool dB = !WaveformSettings::Get(track).isLinear();
965
966 const auto &blankSelectedBrush = artist->blankSelectedBrush;
967 const auto &blankBrush = artist->blankBrush;
969 context, rect, &track, blankSelectedBrush, blankBrush );
970
971 // Really useful channel numbers are not yet passed in
972 // TODO wide wave tracks -- really use channel
973 assert(channel == 0);
974 channel = (track.IsLeader() ? 0 : 1);
975
976 // TODO wide wave tracks -- remove this workaround
977 auto pLeader = *track.GetHolder()->Find(&track);
978 assert(pLeader->IsLeader());
979
980 if(&track != pLeader && track.NIntervals() != pLeader->NIntervals())
981 //We don't have a guarantee that left and right channels have same number
982 //of intervals. Sometimes pasting a large amount of data may trigger
983 //UI event loop updates. When that happens it can well be that one
984 //channel has finished pasting while the other hasn't.
985 //TODO: The check would become unnecessary once wave-clip-refactoring is complete.
986 return;
987
988 for (const auto pInterval :
989 static_cast<const WaveTrack*>(pLeader)->GetChannel(channel)->Intervals()
990 ) {
991 bool selected = selectedClip &&
992 WaveChannelView::WideClipContains(*selectedClip, pInterval->GetClip());
993 DrawClipWaveform(context, track, *pInterval, rect, dB, muted, selected);
994 }
995 DrawBoldBoundaries(context, track, rect);
996
997 const auto drawSliders = artist->drawSliders;
998 if (drawSliders) {
999 DrawTimeSlider( context, rect, true, highlight && gripHit ); // directed right
1000 DrawTimeSlider( context, rect, false, highlight && gripHit ); // directed left
1001 }
1002}
bool IsGripHit() const
static TrackArtist * Get(TrackPanelDrawingContext &)
Definition: TrackArtist.cpp:69
TrackList * GetHolder() const
Definition: Track.h:1480
TrackIter< Track > Find(Track *pTrack)
Definition: Track.cpp:519
static void DrawBoldBoundaries(TrackPanelDrawingContext &context, const WaveTrack &track, const wxRect &rect)
static bool WideClipContains(const WaveTrack::Interval &wideClip, const WaveClip &clip)
A Track that contains audio waveform data.
Definition: WaveTrack.h:227
size_t NIntervals() const override
used only during deserialization
Definition: WaveTrack.cpp:1038
bool IsLeader() const override
Definition: WaveTrack.cpp:2833
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:651
void DrawClipWaveform(TrackPanelDrawingContext &context, const WaveTrack &track, const WaveChannelInterval &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(), WaveChannelSubView::DrawBoldBoundaries(), anonymous_namespace{WaveformView.cpp}::DrawClipWaveform(), anonymous_namespace{WaveformView.cpp}::DrawTimeSlider(), TrackList::Find(), WaveformSettings::Get(), TrackArtist::Get(), WaveTrack::Interval::GetClip(), Track::GetHolder(), TimeShiftHandle::IsGripHit(), WaveTrack::IsLeader(), WaveformSettings::isLinear(), WaveTrack::NIntervals(), TrackPanelDrawingContext::target, and WaveChannelView::WideClipContains().

Referenced by Draw().

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

◆ DoGetVRulerControls()

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

Implements ChannelView.

Definition at line 145 of file WaveformView.cpp.

146{
147 return std::make_shared<WaveformVRulerControls>(shared_from_this());
148}

◆ DoSetMinimized()

void WaveformView::DoSetMinimized ( bool  minimized)
overrideprotectedvirtual

Reimplemented from ChannelView.

Definition at line 118 of file WaveformView.cpp.

119{
120 auto wt = static_cast<WaveTrack*>( FindTrack().get() );
121
122#ifdef EXPERIMENTAL_HALF_WAVE
123 bool bHalfWave;
124 gPrefs->Read(wxT("/GUI/CollapseToHalfWave"), &bHalfWave, false);
125 if( bHalfWave )
126 {
127 auto &cache = WaveformScale::Get(*wt);
128 if (minimized)
129 // Zoom to show fractionally more than the top half of the wave.
130 cache.SetDisplayBounds( -0.01f, 1.0f );
131 else
132 // Zoom out full
133 cache.SetDisplayBounds( -1.0f, 1.0f );
134 }
135#endif
136
138}
wxT("CloseDown"))
audacity::BasicSettings * gPrefs
Definition: Prefs.cpp:68
virtual void DoSetMinimized(bool isMinimized)
std::shared_ptr< Track > FindTrack()
static WaveformScale & Get(const WaveTrack &track)
Mutative access to attachment even if the track argument is const.
virtual bool Read(const wxString &key, bool *value) const =0

References ChannelView::DoSetMinimized(), CommonTrackPanelCell::FindTrack(), WaveformScale::Get(), gPrefs, audacity::BasicSettings::Read(), 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 1004 of file WaveformView.cpp.

1006{
1007 if ( iPass == TrackArtist::PassTracks ) {
1008 auto &dc = context.dc;
1009
1010 const auto wt = std::static_pointer_cast<const WaveTrack>(
1011 FindTrack()->SubstitutePendingChangedTrack());
1012
1013 const auto artist = TrackArtist::Get( context );
1014 const auto hasSolo = artist->hasSolo;
1015 bool muted = (hasSolo || wt->GetMute()) &&
1016 !wt->GetSolo();
1017
1018#if defined(__WXMAC__)
1019 wxAntialiasMode aamode = dc.GetGraphicsContext()->GetAntialiasMode();
1020 dc.GetGraphicsContext()->SetAntialiasMode(wxANTIALIAS_NONE);
1021#endif
1022
1023 auto waveChannelView = GetWaveChannelView().lock();
1024 wxASSERT(waveChannelView.use_count());
1025
1026 auto selectedClip = waveChannelView->GetSelectedClip();
1027 DoDraw(context, GetChannelIndex(), *wt, selectedClip.get(), rect, muted);
1028
1029#if defined(__WXMAC__)
1030 dc.GetGraphicsContext()->SetAntialiasMode(aamode);
1031#endif
1032 }
1033 WaveChannelSubView::Draw(context, rect, iPass);
1034}
size_t GetChannelIndex() const
virtual void Draw(TrackPanelDrawingContext &context, const wxRect &rect, unsigned iPass)
std::weak_ptr< WaveChannelView > GetWaveChannelView() const
static void DoDraw(TrackPanelDrawingContext &context, size_t channel, const WaveTrack &track, const WaveTrack::Interval *selectedClip, const wxRect &rect, bool muted)

References TrackPanelDrawingContext::dc, DoDraw(), TrackPanelDrawable::Draw(), CommonTrackPanelCell::FindTrack(), TrackArtist::Get(), CommonTrackCell::GetChannelIndex(), WaveChannelSubView::GetWaveChannelView(), 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 WaveChannelSubView.

Definition at line 140 of file WaveformView.cpp.

141{
142 return sType;
143}
static WaveChannelSubView::Type sType

References sType.

◆ WaveChannelSubView()

WaveChannelSubView::WaveChannelSubView ( WaveChannelView waveChannelView)
explicit

Definition at line 47 of file WaveChannelView.cpp.

936 waveChannelView.FindTrack(), waveChannelView.GetChannelIndex() }
937{
938 mwWaveChannelView = std::static_pointer_cast<WaveChannelView>(
939 waveChannelView.shared_from_this() );
940}
Implements some hit-testing shared by many ChannelView subtypes.
std::weak_ptr< WaveChannelView > mwWaveChannelView

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: