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

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

943{
944 auto &dc = context.dc;
945 const auto artist = TrackArtist::Get( context );
946
947 bool highlight = false;
948 bool gripHit = false;
949#ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING
950 auto target = dynamic_cast<TimeShiftHandle*>(context.target.get());
951 gripHit = target && target->IsGripHit();
952 highlight = target && target->FindTrack().get() ==
953 &static_cast<const Track &>(channel.GetChannelGroup());
954#endif
955
956 const bool dB = !WaveformSettings::Get(channel).isLinear();
957
958 const auto &blankSelectedBrush = artist->blankSelectedBrush;
959 const auto &blankBrush = artist->blankBrush;
961 context, rect, channel, blankSelectedBrush, blankBrush );
962
963 for (const auto &pInterval : channel.Intervals()) {
964 bool selected = selectedClip &&
965 selectedClip == &pInterval->GetClip();
966 DrawClipWaveform(context, channel, *pInterval, rect, dB, muted, selected);
967 }
968 DrawBoldBoundaries(context, channel, rect);
969
970 const auto drawSliders = artist->drawSliders;
971 if (drawSliders) {
972 DrawTimeSlider( context, rect, true, highlight && gripHit ); // directed right
973 DrawTimeSlider( context, rect, false, highlight && gripHit ); // directed left
974 }
975}
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:69
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)
Definition: TrackArt.cpp:651
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 152 of file WaveformView.cpp.

153{
154 return std::make_shared<WaveformVRulerControls>(shared_from_this());
155}

◆ DoSetMinimized()

void WaveformView::DoSetMinimized ( bool  minimized)
overrideprotectedvirtual

Reimplemented from ChannelView.

Definition at line 128 of file WaveformView.cpp.

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

979{
980 if ( iPass == TrackArtist::PassTracks ) {
981 const auto artist = TrackArtist::Get(context);
982 const auto &pendingTracks = *artist->pPendingTracks;
983 auto &dc = context.dc;
984
985 const auto pChannel = FindChannel();
986 if (!pChannel)
987 return;
988 const auto &wc = static_cast<const WaveChannel&>(
989 pendingTracks.SubstitutePendingChangedChannel(*pChannel));
990
991 const auto hasSolo = artist->hasSolo;
992 bool muted = (hasSolo || wc.GetTrack().GetMute()) &&
993 !wc.GetTrack().GetSolo();
994
995#if defined(__WXMAC__)
996 wxAntialiasMode aamode = dc.GetGraphicsContext()->GetAntialiasMode();
997 dc.GetGraphicsContext()->SetAntialiasMode(wxANTIALIAS_NONE);
998#endif
999
1000 auto waveChannelView = GetWaveChannelView().lock();
1001 wxASSERT(waveChannelView.use_count());
1002
1003 auto selectedClip = waveChannelView->GetSelectedClip();
1004 DoDraw(context, wc, selectedClip.get(), rect, muted);
1005
1006#if defined(__WXMAC__)
1007 dc.GetGraphicsContext()->SetAntialiasMode(aamode);
1008#endif
1009 }
1010 WaveChannelSubView::Draw(context, rect, iPass);
1011}
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:2323
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 147 of file WaveformView.cpp.

148{
149 return sType;
150}
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: