Audacity  3.0.3
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 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
 
bool GetMinimized () const
 
void SetMinimized (bool minimized)
 
int GetCumulativeHeightBefore () const
 
int GetExpandedHeight () const
 
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
 
bool HandleXMLAttribute (const wxChar *attr, const wxChar *value) override
 
virtual Refinement GetSubViews (const wxRect &rect)
 
virtual bool IsSpectral () const
 
- Public Member Functions inherited from CommonTrackCell
 CommonTrackCell (const std::shared_ptr< Track > &pTrack)
 
 ~CommonTrackCell ()
 
std::shared_ptr< TrackDoFindTrack () override
 
virtual void Reparent (const std::shared_ptr< Track > &parent)
 
- 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
 
- Public Member Functions inherited from TrackPanelCell
 TrackPanelCell ()=default
 
 TrackPanelCell (const TrackPanelCell &) PROHIBITED
 
TrackPanelCelloperator= (const TrackPanelCell &) PROHIBITED
 
virtual ~TrackPanelCell ()=0
 
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 wxRect DrawingArea (TrackPanelDrawingContext &context, const wxRect &rect, const wxRect &panelRect, unsigned iPass)
 

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...
 
- Protected Member Functions inherited from CommonTrackPanelCell
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 > > >
 
- Public Types inherited from CommonTrackPanelCell
using Hook = std::function< unsigned(const TrackPanelMouseEvent &evt, AudacityProject *pProject) >
 
- 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 Public Member Functions inherited from CommonTrackPanelCell
static Hook InstallMouseWheelHook (const Hook &hook)
 
- 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 46 of file WaveformView.cpp.

49 {
50  auto &view = *this;
51  const auto pTrack =
52  std::static_pointer_cast< WaveTrack >( view.FindTrack() );
53 
55  st, pProject, currentTool, bMultiTool, pTrack);
56  auto &results = pair.second;
57 
58  if (!pair.first) {
59  UIHandlePtr result;
60 
61  if (bMultiTool) {
62  // Conditional hit tests
63  // If Tools toolbar were eliminated, we would keep these
64  // The priority of these, in case more than one might apply at one
65  // point, seems arbitrary
66  if (NULL != (result = EnvelopeHandle::WaveTrackHitTest(
67  view.mEnvelopeHandle, st.state, st.rect,
68  pProject, pTrack )))
69  results.push_back(result);
70  if (NULL != (result = TimeShiftHandle::HitTest(
71  view.mTimeShiftHandle, st.state, st.rect, pTrack )))
72  // This is the hit test on the "grips" drawn left and
73  // right in Multi only
74  results.push_back(result);
75  if (NULL != (result = SampleHandle::HitTest(
76  view.mSampleHandle, st.state, st.rect,
77  pProject, pTrack )))
78  results.push_back(result);
79  }
80  else {
81  switch ( currentTool ) {
82  // Unconditional hits appropriate to the tool
83  // If tools toolbar were eliminated, we would eliminate these
85  auto &viewInfo = ViewInfo::Get(*pProject);
86  auto time =
87  viewInfo.PositionToTime(st.state.m_x, st.rect.GetX());
88  auto envelope = pTrack->GetEnvelopeAtTime(time);
90  view.mEnvelopeHandle, envelope, false);
91  break;
92  }
95  view.mSampleHandle, st.state, pTrack );
96  break;
97  default:
98  result = {};
99  break;
100  }
101  if (result)
102  results.push_back(result);
103  }
104  }
105 
106  return std::move( results );
107 }

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

978 {
979  auto &dc = context.dc;
980  const auto artist = TrackArtist::Get( context );
981 
982  bool highlight = false;
983  bool gripHit = false;
984 #ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING
985  auto target = dynamic_cast<TimeShiftHandle*>(context.target.get());
986  gripHit = target && target->IsGripHit();
987  highlight = target && target->GetTrack().get() == track;
988 #endif
989 
990  const bool dB = !track->GetWaveformSettings().isLinear();
991 
992  const auto &blankSelectedBrush = artist->blankSelectedBrush;
993  const auto &blankBrush = artist->blankBrush;
995  context, rect, track, blankSelectedBrush, blankBrush );
996 
997  for (const auto& clip : track->GetClips())
998  {
999  DrawClipWaveform(context, track, clip.get(), rect,
1000  dB, muted, clip.get() == selectedClip);
1001  }
1002  DrawBoldBoundaries( context, track, rect );
1003 
1004  const auto drawSliders = artist->drawSliders;
1005  if (drawSliders) {
1006  DrawTimeSlider( context, rect, true, highlight && gripHit ); // directed right
1007  DrawTimeSlider( context, rect, false, highlight && gripHit ); // directed left
1008  }
1009 }

References TrackPanelDrawingContext::dc, TrackArt::DrawBackgroundWithSelection(), WaveTrackSubView::DrawBoldBoundaries(), anonymous_namespace{WaveformView.cpp}::DrawClipWaveform(), anonymous_namespace{WaveformView.cpp}::DrawTimeSlider(), TrackArtist::Get(), WaveTrack::GetClips(), WaveTrack::GetWaveformSettings(), 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 135 of file WaveformView.cpp.

136 {
137  return std::make_shared<WaveformVRulerControls>( shared_from_this() );
138 }

◆ DoSetMinimized()

void WaveformView::DoSetMinimized ( bool  minimized)
overrideprotectedvirtual

Reimplemented from TrackView.

Definition at line 109 of file WaveformView.cpp.

110 {
111  auto wt = static_cast<WaveTrack*>( FindTrack().get() );
112 
113 #ifdef EXPERIMENTAL_HALF_WAVE
114  bool bHalfWave;
115  gPrefs->Read(wxT("/GUI/CollapseToHalfWave"), &bHalfWave, false);
116  if( bHalfWave )
117  {
118  if (minimized)
119  // Zoom to show fractionally more than the top half of the wave.
120  wt->SetDisplayBounds( -0.01f, 1.0f );
121  else
122  // Zoom out full
123  wt->SetDisplayBounds( -1.0f, 1.0f );
124  }
125 #endif
126 
127  TrackView::DoSetMinimized( minimized );
128 }

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

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

1013 {
1014  if ( iPass == TrackArtist::PassTracks ) {
1015  auto &dc = context.dc;
1016  // Update cache for locations, e.g. cutlines and merge points
1017  // Bug2588: do this for both channels, even if one is not drawn, so that
1018  // cut-line editing (which depends on the locations cache) works properly.
1019  // If both channels are visible, we will duplicate this effort, but that
1020  // matters little.
1021  for( auto channel:
1022  TrackList::Channels(static_cast<WaveTrack*>(FindTrack().get())) )
1023  channel->UpdateLocationsCache();
1024 
1025  const auto wt = std::static_pointer_cast<const WaveTrack>(
1026  FindTrack()->SubstitutePendingChangedTrack());
1027 
1028  const auto artist = TrackArtist::Get( context );
1029  const auto hasSolo = artist->hasSolo;
1030  bool muted = (hasSolo || wt->GetMute()) &&
1031  !wt->GetSolo();
1032 
1033 #if defined(__WXMAC__)
1034  wxAntialiasMode aamode = dc.GetGraphicsContext()->GetAntialiasMode();
1035  dc.GetGraphicsContext()->SetAntialiasMode(wxANTIALIAS_NONE);
1036 #endif
1037 
1038  auto waveTrackView = GetWaveTrackView().lock();
1039  wxASSERT(waveTrackView.use_count());
1040 
1041  auto selectedClip = waveTrackView->GetSelectedClip().lock();
1042  DoDraw(context, wt.get(), selectedClip.get(), rect, muted);
1043 
1044 #if defined(__WXMAC__)
1045  dc.GetGraphicsContext()->SetAntialiasMode(aamode);
1046 #endif
1047  }
1048  WaveTrackSubView::Draw( context, rect, iPass );
1049 }

References TrackList::Channels(), TrackPanelDrawingContext::dc, DoDraw(), TrackPanelDrawable::Draw(), CommonTrackPanelCell::FindTrack(), 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 130 of file WaveformView.cpp.

131 {
132  return sType;
133 }

References sType.

◆ WaveTrackSubView()

WaveTrackSubView::WaveTrackSubView
explicit

Definition at line 46 of file WaveTrackView.cpp.

867  : CommonTrackView( waveTrackView.FindTrack() )
868 {
869  mwWaveTrackView = std::static_pointer_cast<WaveTrackView>(
870  waveTrackView.shared_from_this() );
871 }

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:
WaveformSettings::isLinear
bool isLinear() const
Definition: WaveformSettings.h:71
ViewInfo::Get
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:241
WaveTrack
A Track that contains audio waveform data.
Definition: WaveTrack.h:69
CommonTrackView
Definition: CommonTrackView.h:20
ToolCodes::drawTool
@ drawTool
Definition: ProjectSettings.h:42
gPrefs
FileConfig * gPrefs
Definition: Prefs.cpp:70
EnvelopeHandle::WaveTrackHitTest
static UIHandlePtr WaveTrackHitTest(std::weak_ptr< EnvelopeHandle > &holder, const wxMouseState &state, const wxRect &rect, const AudacityProject *pProject, const std::shared_ptr< WaveTrack > &wt)
Definition: EnvelopeHandle.cpp:88
CommonTrackPanelCell::FindTrack
std::shared_ptr< Track > FindTrack()
Definition: CommonTrackPanelCell.h:46
TrackList::Channels
static auto Channels(TrackType *pTrack) -> TrackIterRange< TrackType >
Definition: Track.h:1484
SampleHandle::HitAnywhere
static UIHandlePtr HitAnywhere(std::weak_ptr< SampleHandle > &holder, const wxMouseState &state, const std::shared_ptr< WaveTrack > &pTrack)
Definition: SampleHandle.cpp:73
WaveTrackSubView::DrawBoldBoundaries
static void DrawBoldBoundaries(TrackPanelDrawingContext &context, const WaveTrack *track, const wxRect &rect)
Definition: WaveTrackView.cpp:773
TrackPanelDrawingContext::dc
wxDC & dc
Definition: TrackPanelDrawingContext.h:23
TimeShiftHandle::HitTest
static UIHandlePtr HitTest(std::weak_ptr< TimeShiftHandle > &holder, const wxMouseState &state, const wxRect &rect, const std::shared_ptr< Track > &pTrack)
Definition: TimeShiftHandle.cpp:89
WaveTrackSubView::DoDetailedHitTest
std::pair< bool, std::vector< UIHandlePtr > > DoDetailedHitTest(const TrackPanelMouseState &state, const AudacityProject *pProject, int currentTool, bool bMultiTool, const std::shared_ptr< WaveTrack > &wt)
TrackArtist::Get
static TrackArtist * Get(TrackPanelDrawingContext &)
Definition: TrackArtist.cpp:79
sType
static WaveTrackSubView::Type sType
Definition: WaveformView.cpp:37
anonymous_namespace{WaveformView.cpp}::DrawClipWaveform
void DrawClipWaveform(TrackPanelDrawingContext &context, const WaveTrack *track, const WaveClip *clip, const wxRect &rect, bool dB, bool muted, bool selected)
Definition: WaveformView.cpp:668
TimeShiftHandle::IsGripHit
bool IsGripHit() const
Definition: TimeShiftHandle.h:273
WaveformView::DoDraw
static void DoDraw(TrackPanelDrawingContext &context, const WaveTrack *track, const WaveClip *selectedClip, const wxRect &rect, bool muted)
Definition: WaveformView.cpp:973
WaveTrack::GetClips
WaveClipHolders & GetClips()
Definition: WaveTrack.h:371
UIHandlePtr
std::shared_ptr< UIHandle > UIHandlePtr
Definition: CellularPanel.h:28
WaveTrackSubView::mwWaveTrackView
std::weak_ptr< WaveTrackView > mwWaveTrackView
Definition: WaveTrackView.h:80
TrackView::DoSetMinimized
virtual void DoSetMinimized(bool isMinimized)
Definition: TrackView.cpp:126
WaveTrack::GetWaveformSettings
const WaveformSettings & GetWaveformSettings() const
Definition: WaveTrack.cpp:811
TimeShiftHandle
Definition: TimeShiftHandle.h:262
TrackArt::DrawBackgroundWithSelection
AUDACITY_DLL_API void DrawBackgroundWithSelection(TrackPanelDrawingContext &context, const wxRect &rect, const Track *track, const wxBrush &selBrush, const wxBrush &unselBrush, bool useSelection=true)
Definition: TrackArtist.cpp:528
ToolCodes::envelopeTool
@ envelopeTool
Definition: ProjectSettings.h:41
TrackPanelDrawingContext::target
UIHandlePtr target
Definition: TrackPanelDrawingContext.h:24
WaveTrackSubView::GetWaveTrackView
std::weak_ptr< WaveTrackView > GetWaveTrackView() const
Definition: WaveTrackView.cpp:814
TrackArtist::PassTracks
@ PassTracks
Definition: TrackArtist.h:81
anonymous_namespace{WaveformView.cpp}::DrawTimeSlider
void DrawTimeSlider(TrackPanelDrawingContext &context, const wxRect &rect, bool rightwards, bool highlight)
Definition: WaveformView.cpp:911
EnvelopeHandle::HitAnywhere
static UIHandlePtr HitAnywhere(std::weak_ptr< EnvelopeHandle > &holder, Envelope *envelope, bool timeTrack)
Definition: EnvelopeHandle.cpp:46
SampleHandle::HitTest
static UIHandlePtr HitTest(std::weak_ptr< SampleHandle > &holder, const wxMouseState &state, const wxRect &rect, const AudacityProject *pProject, const std::shared_ptr< WaveTrack > &pTrack)
Definition: SampleHandle.cpp:111
TrackPanelDrawable::Draw
virtual void Draw(TrackPanelDrawingContext &context, const wxRect &rect, unsigned iPass)
Definition: TrackPanelDrawable.cpp:17