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)
 
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 GetY () const
 
int GetActualHeight () const
 
int GetHeight () const
 
void SetY (int y)
 
void SetHeight (int height)
 
std::shared_ptr< TrackVRulerControlsGetVRulerControls ()
 
std::shared_ptr< const TrackVRulerControlsGetVRulerControls () const
 
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 DoContextMenu (const wxRect &rect, wxWindow *pParent, 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)
 
- 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 TrackView
void DoSetY (int y)
 
void DoSetHeight (int h)
 
- Protected Member Functions inherited from CommonTrackPanelCell
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 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 wxRect &  rect,
bool  muted 
)
staticprivate

Definition at line 968 of file WaveformView.cpp.

972 {
973  auto &dc = context.dc;
974  const auto artist = TrackArtist::Get( context );
975 
976  bool highlight = false;
977  bool gripHit = false;
978 #ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING
979  auto target = dynamic_cast<TimeShiftHandle*>(context.target.get());
980  gripHit = target && target->IsGripHit();
981  highlight = target && target->GetTrack().get() == track;
982 #endif
983 
984  const bool dB = !track->GetWaveformSettings().isLinear();
985 
986  const auto &blankSelectedBrush = artist->blankSelectedBrush;
987  const auto &blankBrush = artist->blankBrush;
989  context, rect, track, blankSelectedBrush, blankBrush );
990 
991  for (const auto &clip: track->GetClips())
992  DrawClipWaveform(context, track, clip.get(), rect,
993  dB, muted);
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 }

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

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

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

779  : CommonTrackView( waveTrackView.FindTrack() )
780 {
781  mwWaveTrackView = std::static_pointer_cast<WaveTrackView>(
782  waveTrackView.shared_from_this() );
783 }

Member Data Documentation

◆ mEnvelopeHandle

std::weak_ptr<EnvelopeHandle> WaveformView::mEnvelopeHandle
protected

Definition at line 53 of file WaveformView.h.

◆ mSampleHandle

std::weak_ptr<SampleHandle> WaveformView::mSampleHandle
protected

Definition at line 52 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:156
WaveTrack
A Track that contains audio waveform data.
Definition: WaveTrack.h:68
CommonTrackView
Definition: CommonTrackView.h:20
ToolCodes::drawTool
@ drawTool
Definition: ProjectSettings.h:37
gPrefs
FileConfig * gPrefs
Definition: Prefs.cpp:68
WaveformView::DoDraw
static void DoDraw(TrackPanelDrawingContext &context, const WaveTrack *track, const wxRect &rect, bool muted)
Definition: WaveformView.cpp:968
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:44
TrackList::Channels
static auto Channels(TrackType *pTrack) -> TrackIterRange< TrackType >
Definition: Track.h:1467
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:722
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:74
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:75
sType
static WaveTrackSubView::Type sType
Definition: WaveformView.cpp:37
TimeShiftHandle::IsGripHit
bool IsGripHit() const
Definition: TimeShiftHandle.h:266
WaveTrack::GetClips
WaveClipHolders & GetClips()
Definition: WaveTrack.h:365
UIHandlePtr
std::shared_ptr< UIHandle > UIHandlePtr
Definition: CellularPanel.h:28
WaveTrackSubView::mwWaveTrackView
std::weak_ptr< WaveTrackView > mwWaveTrackView
Definition: WaveTrackView.h:55
TrackView::DoSetMinimized
virtual void DoSetMinimized(bool isMinimized)
Definition: TrackView.cpp:126
WaveTrack::GetWaveformSettings
const WaveformSettings & GetWaveformSettings() const
Definition: WaveTrack.cpp:713
anonymous_namespace{WaveformView.cpp}::DrawClipWaveform
void DrawClipWaveform(TrackPanelDrawingContext &context, const WaveTrack *track, const WaveClip *clip, const wxRect &rect, bool dB, bool muted)
Definition: WaveformView.cpp:668
TimeShiftHandle
Definition: TimeShiftHandle.h:255
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:386
ToolCodes::envelopeTool
@ envelopeTool
Definition: ProjectSettings.h:36
TrackPanelDrawingContext::target
UIHandlePtr target
Definition: TrackPanelDrawingContext.h:24
TrackArtist::PassTracks
@ PassTracks
Definition: TrackArtist.h:63
anonymous_namespace{WaveformView.cpp}::DrawTimeSlider
void DrawTimeSlider(TrackPanelDrawingContext &context, const wxRect &rect, bool rightwards, bool highlight)
Definition: WaveformView.cpp:906
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