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)
 
std::shared_ptr< WaveChannelFindWaveChannel ()
 
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< WaveChannel > &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< Channel > &pChannel)
 
- Public Member Functions inherited from ChannelView
 ChannelView (const std::shared_ptr< Channel > &pChannel)
 
virtual ~ChannelView ()=0
 
void Reparent (const std::shared_ptr< Track > &parent, size_t iChannel) override
 Object may be shared among tracks but hold a special back-pointer to one of them; reassign it. More...
 
void CopyTo (Track &track, size_t iChannel) 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 &writer, size_t iChannel) const override
 Serialize persistent attributes. More...
 
bool HandleXMLAttribute (const std::string_view &attr, const XMLAttributeValueView &valueView, size_t iChannel) 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 CommonChannelCell
 CommonChannelCell (const std::shared_ptr< Channel > &pChannel)
 Construct from a channel. More...
 
 ~CommonChannelCell ()
 
std::shared_ptr< TrackDoFindTrack () override
 
void Reparent (const std::shared_ptr< Track > &parent, size_t iChannel) override
 Object may be shared among tracks but hold a special back-pointer to one of them; reassign it. More...
 
template<typename Subtype = Channel>
auto FindChannel () -> std::shared_ptr< Subtype >
 May return null. More...
 
template<typename Subtype = const Channel>
auto FindChannel () const -> std::enable_if_t< std::is_const_v< Subtype >, std::shared_ptr< Subtype > >
 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 ChannelAttachment
virtual ~ChannelAttachment ()
 
virtual void CopyTo (Track &track, size_t iChannel) const
 Copy state, for undo/redo purposes. More...
 
virtual void Reparent (const std::shared_ptr< Track > &parent, size_t iChannel)
 Object may be shared among tracks but hold a special back-pointer to one of them; reassign it. More...
 
virtual void WriteXMLAttributes (XMLWriter &writer, size_t iChannel) const
 Serialize persistent attributes. More...
 
virtual bool HandleXMLAttribute (const std::string_view &attr, const XMLAttributeValueView &valueView, size_t iChannel)
 Deserialize an attribute, returning true if recognized. More...
 

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, const WaveChannel &channel, 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 WaveChannel &channel, 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 66 of file WaveformView.cpp.

69{
70 auto &view = *this;
71 const auto pChannel = view.FindChannel<WaveChannel>();
72
74 st, pProject, currentTool, bMultiTool, pChannel);
75 auto &results = pair.second;
76
77 if (!pair.first) {
78 UIHandlePtr result;
79
80 if (bMultiTool) {
81 // Conditional hit tests
82 // If Tools toolbar were eliminated, we would keep these
83 // The priority of these, in case more than one might apply at one
84 // point, seems arbitrary
85 if (nullptr != (result = EnvelopeHandle::WaveChannelHitTest(
86 view.mEnvelopeHandle, st.state, st.rect,
87 pProject, pChannel)))
88 results.push_back(result);
89 if (nullptr != (result = TimeShiftHandle::HitTest(
90 view.mTimeShiftHandle, st.state, st.rect,
91 pChannel->GetTrack().SharedPointer())))
92 // This is the hit test on the "grips" drawn left and
93 // right in Multi only
94 results.push_back(result);
95 if (nullptr != (result = SampleHandle::HitTest(
96 view.mSampleHandle, st.state, st.rect,
97 pProject, pChannel)))
98 results.push_back(result);
99 }
100 else {
101 switch ( currentTool ) {
102 // Unconditional hits appropriate to the tool
103 // If tools toolbar were eliminated, we would eliminate these
105 auto &viewInfo = ViewInfo::Get(*pProject);
106 auto time =
107 viewInfo.PositionToTime(st.state.m_x, st.rect.GetX());
108 const auto envelope =
111 view.mEnvelopeHandle, envelope,
112 std::dynamic_pointer_cast<const Channel>(pChannel),
113 false);
114 break;
115 }
118 view.mSampleHandle, st.state, pChannel);
119 break;
120 default:
121 result = {};
122 break;
123 }
124 if (result)
125 results.push_back(result);
126 }
127 }
128
129 return std::move( results );
130}
std::shared_ptr< UIHandle > UIHandlePtr
Definition: CellularPanel.h:28
static UIHandlePtr WaveChannelHitTest(std::weak_ptr< EnvelopeHandle > &holder, const wxMouseState &state, const wxRect &rect, const AudacityProject *pProject, const std::shared_ptr< WaveChannel > &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< 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 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< WaveChannel > &wt)
WAVE_TRACK_API Envelope * GetEnvelopeAtTime(WaveChannel &channel, double time)

References WaveChannelSubView::DoDetailedHitTest(), ToolCodes::drawTool, ToolCodes::envelopeTool, ViewInfo::Get(), WaveChannelUtilities::GetEnvelopeAtTime(), EnvelopeHandle::HitAnywhere(), SampleHandle::HitAnywhere(), SampleHandle::HitTest(), TimeShiftHandle::HitTest(), TrackPanelMouseState::rect, TrackPanelMouseState::state, and EnvelopeHandle::WaveChannelHitTest().

Here is the call graph for this function:

◆ DoDraw()

void WaveformView::DoDraw ( TrackPanelDrawingContext context,
const WaveChannel channel,
const WaveTrack::Interval selectedClip,
const wxRect &  rect,
bool  muted 
)
staticprivate

Definition at line 974 of file WaveformView.cpp.

979{
980 auto &dc = context.dc;
981 const auto artist = TrackArtist::Get( context );
982
983 bool highlight = false;
984 bool gripHit = false;
985#ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING
986 auto target = dynamic_cast<TimeShiftHandle*>(context.target.get());
987 gripHit = target && target->IsGripHit();
988 highlight = target && target->FindTrack().get() ==
989 &static_cast<const Track &>(channel.GetChannelGroup());
990#endif
991
992 const bool dB = !WaveformSettings::Get(channel).isLinear();
993
994 const auto &blankSelectedBrush = artist->blankSelectedBrush;
995 const auto &blankBrush = artist->blankBrush;
997 context, rect, channel, blankSelectedBrush, blankBrush );
998
999 for (const auto &pInterval : channel.Intervals()) {
1000 bool selected = selectedClip &&
1001 selectedClip == &pInterval->GetClip();
1002 DrawClipWaveform(context, channel, *pInterval, rect, dB, muted, selected);
1003 }
1004 DrawBoldBoundaries(context, channel, rect);
1005
1006 const auto drawSliders = artist->drawSliders;
1007 if (drawSliders) {
1008 DrawTimeSlider( context, rect, true, highlight && gripHit ); // directed right
1009 DrawTimeSlider( context, rect, false, highlight && gripHit ); // directed left
1010 }
1011}
ChannelGroup & GetChannelGroup()
Channel object's lifetime is assumed to be nested in its Track's.
Definition: Channel.cpp:43
bool IsGripHit() const
static TrackArtist * Get(TrackPanelDrawingContext &)
Definition: TrackArtist.cpp:82
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:110
IteratorRange< IntervalIterator< WaveClipChannel > > Intervals()
Definition: WaveTrack.cpp:745
static void DrawBoldBoundaries(TrackPanelDrawingContext &context, const WaveChannel &channel, const wxRect &rect)
bool isLinear() const
static WaveformSettings & Get(const WaveTrack &track)
AUDACITY_DLL_API void DrawBackgroundWithSelection(TrackPanelDrawingContext &context, const wxRect &rect, const Channel &channel, const wxBrush &selBrush, const wxBrush &unselBrush, bool useSelection=true, bool useBeatsAlternateColor=false)
Helper: draws background with selection rect.
Definition: TrackArt.cpp:648
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)

References TrackPanelDrawingContext::dc, TrackArt::DrawBackgroundWithSelection(), WaveChannelSubView::DrawBoldBoundaries(), anonymous_namespace{WaveformView.cpp}::DrawClipWaveform(), anonymous_namespace{WaveformView.cpp}::DrawTimeSlider(), WaveformSettings::Get(), TrackArtist::Get(), Channel::GetChannelGroup(), WaveChannel::Intervals(), 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< ChannelVRulerControls > WaveformView::DoGetVRulerControls ( )
overridevirtual

Implements ChannelView.

Definition at line 156 of file WaveformView.cpp.

157{
158 return std::make_shared<WaveformVRulerControls>(shared_from_this());
159}

◆ DoSetMinimized()

void WaveformView::DoSetMinimized ( bool  minimized)
overrideprotectedvirtual

Reimplemented from ChannelView.

Definition at line 132 of file WaveformView.cpp.

133{
134 auto wt = FindWaveChannel();
135
136 bool bHalfWave;
137 gPrefs->Read(wxT("/GUI/CollapseToHalfWave"), &bHalfWave, false);
138 if (wt && bHalfWave) {
139 auto &cache = WaveformScale::Get(*wt);
140 if (minimized)
141 // Zoom to show fractionally more than the top half of the wave.
142 cache.SetDisplayBounds( -0.01f, 1.0f );
143 else
144 // Zoom out full
145 cache.SetDisplayBounds( -1.0f, 1.0f );
146 }
147
149}
wxT("CloseDown"))
audacity::BasicSettings * gPrefs
Definition: Prefs.cpp:68
virtual void DoSetMinimized(bool isMinimized)
std::shared_ptr< WaveChannel > FindWaveChannel()
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(), WaveChannelSubView::FindWaveChannel(), 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 1013 of file WaveformView.cpp.

1015{
1016 if ( iPass == TrackArtist::PassTracks ) {
1017 const auto artist = TrackArtist::Get(context);
1018 const auto &pendingTracks = *artist->pPendingTracks;
1019 auto &dc = context.dc;
1020
1021 const auto pChannel = FindChannel();
1022 if (!pChannel)
1023 return;
1024 const auto &wc = static_cast<const WaveChannel&>(
1025 pendingTracks.SubstitutePendingChangedChannel(*pChannel));
1026
1027 const auto hasSolo = artist->hasSolo;
1028 bool muted = (hasSolo || wc.GetTrack().GetMute()) &&
1029 !wc.GetTrack().GetSolo();
1030
1031#if defined(__WXMAC__)
1032 wxAntialiasMode aamode = dc.GetGraphicsContext()->GetAntialiasMode();
1033 dc.GetGraphicsContext()->SetAntialiasMode(wxANTIALIAS_NONE);
1034#endif
1035
1036 auto waveChannelView = GetWaveChannelView().lock();
1037 wxASSERT(waveChannelView.use_count());
1038
1039 auto selectedClip = waveChannelView->GetSelectedClip();
1040 DoDraw(context, wc, selectedClip.get(), rect, muted);
1041
1042#if defined(__WXMAC__)
1043 dc.GetGraphicsContext()->SetAntialiasMode(aamode);
1044#endif
1045 }
1046 WaveChannelSubView::Draw(context, rect, iPass);
1047}
auto FindChannel() -> std::shared_ptr< Subtype >
May return null.
virtual void Draw(TrackPanelDrawingContext &context, const wxRect &rect, unsigned iPass)
WaveTrack & GetTrack()
Definition: WaveTrack.h:840
std::weak_ptr< WaveChannelView > GetWaveChannelView() const
bool GetSolo() const override
May vary asynchronously.
Definition: WaveTrack.cpp:2330
static void DoDraw(TrackPanelDrawingContext &context, const WaveChannel &channel, const WaveTrack::Interval *selectedClip, const wxRect &rect, bool muted)

References TrackPanelDrawingContext::dc, DoDraw(), TrackPanelDrawable::Draw(), CommonChannelCell::FindChannel(), TrackArtist::Get(), WaveTrack::GetSolo(), WaveChannel::GetTrack(), 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 151 of file WaveformView.cpp.

152{
153 return sType;
154}
static WaveChannelSubView::Type sType

References sType.

◆ WaveChannelSubView()

WaveChannelSubView::WaveChannelSubView ( WaveChannelView waveChannelView)
explicit

Definition at line 47 of file WaveChannelView.cpp.

955 : CommonChannelView{ waveChannelView.FindChannel() }
956{
957 mwWaveChannelView = std::static_pointer_cast<WaveChannelView>(
958 waveChannelView.shared_from_this() );
959}
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: