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 68 of file WaveformView.cpp.

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

982{
983 auto &dc = context.dc;
984 const auto artist = TrackArtist::Get( context );
985
986 bool highlight = false;
987 bool gripHit = false;
988#ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING
989 auto target = dynamic_cast<TimeShiftHandle*>(context.target.get());
990 gripHit = target && target->IsGripHit();
991 highlight = target && target->FindTrack().get() ==
992 &static_cast<const Track &>(channel.GetChannelGroup());
993#endif
994
995 const bool dB = !WaveformSettings::Get(channel).isLinear();
996
997 const auto &blankSelectedBrush = artist->blankSelectedBrush;
998 const auto &blankBrush = artist->blankBrush;
1000 context, rect, channel, blankSelectedBrush, blankBrush );
1001
1002 for (const auto &pInterval : channel.Intervals()) {
1003 bool selected = selectedClip &&
1004 selectedClip == &pInterval->GetClip();
1005 DrawClipWaveform(context, channel, *pInterval, rect, dB, muted, selected);
1006 }
1007 DrawBoldBoundaries(context, channel, rect);
1008
1009 const auto drawSliders = artist->drawSliders;
1010 if (drawSliders) {
1011 DrawTimeSlider( context, rect, true, highlight && gripHit ); // directed right
1012 DrawTimeSlider( context, rect, false, highlight && gripHit ); // directed left
1013 }
1014}
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:81
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:762
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 158 of file WaveformView.cpp.

159{
160 return std::make_shared<WaveformVRulerControls>(shared_from_this());
161}

◆ DoSetMinimized()

void WaveformView::DoSetMinimized ( bool  minimized)
overrideprotectedvirtual

Reimplemented from ChannelView.

Definition at line 134 of file WaveformView.cpp.

135{
136 auto wt = FindWaveChannel();
137
138 bool bHalfWave;
139 gPrefs->Read(wxT("/GUI/CollapseToHalfWave"), &bHalfWave, false);
140 if (wt && bHalfWave) {
141 auto &cache = WaveformScale::Get(*wt);
142 if (minimized)
143 // Zoom to show fractionally more than the top half of the wave.
144 cache.SetDisplayBounds( -0.01f, 1.0f );
145 else
146 // Zoom out full
147 cache.SetDisplayBounds( -1.0f, 1.0f );
148 }
149
151}
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 1016 of file WaveformView.cpp.

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

154{
155 return sType;
156}
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: