Audacity  3.0.3
WaveTrackView.h
Go to the documentation of this file.
1 /**********************************************************************
2 
3 Audacity: A Digital Audio Editor
4 
5 WaveTrackView.h
6 
7 Paul Licameli split from class WaveTrack
8 
9 **********************************************************************/
10 
11 #ifndef __AUDACITY_WAVE_TRACK_VIEW__
12 #define __AUDACITY_WAVE_TRACK_VIEW__
13 
14 #include "../../../ui/CommonTrackView.h"
15 #include "../../../../ClientData.h"
16 namespace WaveTrackViewConstants{ enum Display : int; }
17 #include "audacity/Types.h"
19 
20 class CutlineHandle;
21 class TranslatableString;
22 class WaveTrack;
23 class WaveTrackView;
24 
25 class AUDACITY_DLL_API WaveTrackSubView : public CommonTrackView
26 {
27 public:
28 
31 
32  explicit
33  WaveTrackSubView( WaveTrackView &waveTrackView );
34 
35  virtual const Type &SubViewType() const = 0;
36 
37  std::pair<
38  bool, // if true, hit-testing is finished
39  std::vector<UIHandlePtr>
41  const TrackPanelMouseState &state,
42  const AudacityProject *pProject, int currentTool, bool bMultiTool,
43  const std::shared_ptr<WaveTrack> &wt );
44 
45 protected:
46  static void DrawBoldBoundaries(
47  TrackPanelDrawingContext &context, const WaveTrack *track,
48  const wxRect &rect );
49 
50 private:
51  std::weak_ptr<UIHandle> mCloseHandle;
52  std::weak_ptr<UIHandle> mAdjustHandle;
53  std::weak_ptr<UIHandle> mRearrangeHandle;
54  std::weak_ptr<CutlineHandle> mCutlineHandle;
55  std::weak_ptr<WaveTrackView> mwWaveTrackView;
56 };
57 
59  int index;
60  float fraction;
61 };
62 using WaveTrackSubViewPlacements = std::vector< WaveTrackSubViewPlacement >;
63 
64 class WaveTrackView;
67 >;
68 
69 class AUDACITY_DLL_API WaveTrackView final
70  : public CommonTrackView
71  , public WaveTrackSubViews
72 {
73  WaveTrackView( const WaveTrackView& ) = delete;
74  WaveTrackView &operator=( const WaveTrackView& ) = delete;
75 
76 public:
78 
79  static WaveTrackView &Get( WaveTrack &track );
80  static const WaveTrackView &Get( const WaveTrack &track );
81 
82  explicit
83  WaveTrackView( const std::shared_ptr<Track> &pTrack );
84  ~WaveTrackView() override;
85 
86  // Preserve some view state too for undo/redo purposes
87  void CopyTo( Track &track ) const override;
88 
89  std::shared_ptr<TrackVRulerControls> DoGetVRulerControls() override;
90 
91  // CommonTrackView implementation
92  void Reparent( const std::shared_ptr<Track> &parent ) override;
93 
94  static std::pair<
95  bool, // if true, hit-testing is finished
96  std::vector<UIHandlePtr>
97  > DoDetailedHitTest(
98  const TrackPanelMouseState &state,
99  const AudacityProject *pProject, int currentTool, bool bMultiTool,
100  const std::shared_ptr<WaveTrack> &wt,
101  CommonTrackView &view);
102 
103  std::vector< WaveTrackSubView::Type > GetDisplays() const;
104  void SetDisplay(Display display, bool exclusive = true);
105 
107  { return mPlacements; }
109  { mPlacements = placements; }
110 
111  // Return true if successful. Fails if you try to toggle off the only
112  // sub-view.
113  bool ToggleSubView( Display id );
114 
115  // Get all the sub-views, in a sequence that is unspecified but in
116  // correspondence with the result of SavePlacements
117  std::vector< std::shared_ptr< WaveTrackSubView > > GetAllSubViews();
118 
119  // Return cached height of rect in last call of GetSubViews
120  wxCoord GetLastHeight() const { return mLastHeight; }
121 
122  bool GetMultiView() const { return mMultiView; }
123  void SetMultiView( bool value ) { mMultiView = value; }
124 
125 private:
126  void BuildSubViews() const;
127  void DoSetDisplay(Display display, bool exclusive = true);
128 
129  // TrackPanelDrawable implementation
130  void Draw(
131  TrackPanelDrawingContext &context,
132  const wxRect &rect, unsigned iPass ) override;
133 
134  std::vector<UIHandlePtr> DetailedHitTest
135  (const TrackPanelMouseState &state,
136  const AudacityProject *pProject, int currentTool, bool bMultiTool)
137  override;
138 
139  // TrackView implementation
140  // Get the visible sub-views with top y coordinates
141  Refinement GetSubViews( const wxRect &rect ) override;
142 
143 protected:
144  void DoSetMinimized( bool minimized ) override;
145 
146  // Placements are in correspondence with the array of sub-views
147  // in the WaveTrackSubViews base class, though their sequence is
148  // unspecified and maybe different in different platforms.
150  mutable wxCoord mLastHeight{};
151 
152  bool mMultiView{ false };
153 };
154 
155 // Helper for drawing routines
156 class SelectedRegion;
157 class WaveClip;
158 class ZoomInfo;
159 
160 struct AUDACITY_DLL_API ClipParameters
161 {
162  // Do a bunch of calculations common to waveform and spectrum drawing.
164  (bool spectrum, const WaveTrack *track, const WaveClip *clip, const wxRect &rect,
165  const SelectedRegion &selectedRegion, const ZoomInfo &zoomInfo);
166 
167  double tOffset;
168  double rate;
169  double h; // absolute time of left edge of display
170  double tpre; // offset corrected time of left edge of display
171  double h1;
172  double tpost; // offset corrected time of right edge of display
173 
174  // Calculate actual selection bounds so that t0 > 0 and t1 < the
175  // end of the track
176  double t0;
177  double t1;
178 
181 
184 
185  wxRect hiddenMid;
187 
188  wxRect mid;
190 
191  void DrawClipEdges( wxDC &dc, const wxRect &rect ) const;
192 };
193 
194 #endif
ClipParameters::tpost
double tpost
Definition: WaveTrackView.h:172
TranslatableString
Holds a msgid for the translation catalog; may also bind format arguments.
Definition: TranslatableString.h:32
WaveTrackView::mPlacements
WaveTrackSubViewPlacements mPlacements
Definition: WaveTrackView.h:149
WaveTrack
A Track that contains audio waveform data.
Definition: WaveTrack.h:68
CommonTrackView
Definition: CommonTrackView.h:20
WaveTrackSubViewPlacement::fraction
float fraction
Definition: WaveTrackView.h:60
WaveTrackSubView::SubViewType
virtual const Type & SubViewType() const =0
ClipParameters::rate
double rate
Definition: WaveTrackView.h:168
WaveTrackView
Definition: WaveTrackView.h:72
WaveTrackView::operator=
WaveTrackView & operator=(const WaveTrackView &)=delete
TrackView::Get
static TrackView & Get(Track &)
Definition: TrackView.cpp:63
ClipParameters::averagePixelsPerSample
double averagePixelsPerSample
Definition: WaveTrackView.h:179
CutlineHandle
Definition: CutlineHandle.h:22
ZoomInfo
Definition: ZoomInfo.h:47
WaveTrackViewConstants
Definition: WaveTrackView.h:16
TrackPanelDrawingContext
Definition: TrackPanelDrawingContext.h:22
WaveTrackView::RestorePlacements
void RestorePlacements(const WaveTrackSubViewPlacements &placements)
Definition: WaveTrackView.h:108
WaveTrackView::GetMultiView
bool GetMultiView() const
Definition: WaveTrackView.h:122
ClipParameters::h
double h
Definition: WaveTrackView.h:169
WaveTrackViewConstants::Display
Display
Definition: WaveTrackViewConstants.h:18
ClipParameters::hiddenLeftOffset
int hiddenLeftOffset
Definition: WaveTrackView.h:186
WaveTrackView::GetLastHeight
wxCoord GetLastHeight() const
Definition: WaveTrackView.h:120
WaveTrackSubView
Definition: WaveTrackView.h:26
ClientData::SkipCopying
@ SkipCopying
ignore the source and leave empty
Definition: ClientDataHelpers.h:34
WaveTrackSubView::mCloseHandle
std::weak_ptr< UIHandle > mCloseHandle
Definition: WaveTrackView.h:51
ClipParameters::ssel0
sampleCount ssel0
Definition: WaveTrackView.h:182
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)
ClipParameters::hiddenMid
wxRect hiddenMid
Definition: WaveTrackView.h:185
WaveClip
This allows multiple clips to be a part of one WaveTrack.
Definition: WaveClip.h:172
ClipParameters::showIndividualSamples
bool showIndividualSamples
Definition: WaveTrackView.h:180
WaveTrackView::WaveTrackView
WaveTrackView(const WaveTrackView &)=delete
WaveTrackSubViewType
Definition: WaveTrackViewConstants.h:91
ClipParameters::ssel1
sampleCount ssel1
Definition: WaveTrackView.h:183
ClientData::Site
Utility to register hooks into a host class that attach client data.
Definition: ClientData.h:220
ClipParameters
Definition: WaveTrackView.h:161
WaveTrackSubView::mwWaveTrackView
std::weak_ptr< WaveTrackView > mwWaveTrackView
Definition: WaveTrackView.h:55
WaveTrackSubViewPlacements
std::vector< WaveTrackSubViewPlacement > WaveTrackSubViewPlacements
Definition: WaveTrackView.h:62
TrackView::DoSetMinimized
virtual void DoSetMinimized(bool isMinimized)
Definition: TrackView.cpp:126
WaveTrackView::SavePlacements
const WaveTrackSubViewPlacements & SavePlacements() const
Definition: WaveTrackView.h:106
ClipParameters::tOffset
double tOffset
Definition: WaveTrackView.h:167
WaveTrackSubViewPlacement
Definition: WaveTrackView.h:58
WaveTrackSubView::mRearrangeHandle
std::weak_ptr< UIHandle > mRearrangeHandle
Definition: WaveTrackView.h:53
ClipParameters::t0
double t0
Definition: WaveTrackView.h:176
Types.h
ClipParameters::leftOffset
int leftOffset
Definition: WaveTrackView.h:189
Track
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:238
sampleCount
Definition: Types.h:66
AudacityProject
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:112
ClipParameters::h1
double h1
Definition: WaveTrackView.h:171
TrackView::GetSubViews
virtual Refinement GetSubViews(const wxRect &rect)
Definition: TrackView.cpp:116
ClipParameters::mid
wxRect mid
Definition: WaveTrackView.h:188
TrackPanelMouseState
Definition: TrackPanelMouseEvent.h:28
TrackView::CopyTo
void CopyTo(Track &track) const override
Definition: TrackView.cpp:52
WaveTrackSubView::mAdjustHandle
std::weak_ptr< UIHandle > mAdjustHandle
Definition: WaveTrackView.h:52
ClipParameters::t1
double t1
Definition: WaveTrackView.h:177
CommonTrackCell::Reparent
virtual void Reparent(const std::shared_ptr< Track > &parent)
Definition: CommonTrackPanelCell.cpp:64
ClipParameters::tpre
double tpre
Definition: WaveTrackView.h:170
WaveTrackSubView::mCutlineHandle
std::weak_ptr< CutlineHandle > mCutlineHandle
Definition: WaveTrackView.h:54
CommonTrackView::DetailedHitTest
virtual std::vector< UIHandlePtr > DetailedHitTest(const TrackPanelMouseState &, const AudacityProject *pProject, int currentTool, bool bMultiTool)=0
WaveTrackSubViewPlacement::index
int index
Definition: WaveTrackView.h:59
TrackView::DoGetVRulerControls
virtual std::shared_ptr< TrackVRulerControls > DoGetVRulerControls()=0
WaveTrackView::SetMultiView
void SetMultiView(bool value)
Definition: WaveTrackView.h:123
SelectedRegion
Defines a selected portion of a project.
Definition: SelectedRegion.h:38
TrackPanelDrawable::Draw
virtual void Draw(TrackPanelDrawingContext &context, const wxRect &rect, unsigned iPass)
Definition: TrackPanelDrawable.cpp:17