Audacity  3.0.3
TrackView.h
Go to the documentation of this file.
1 /**********************************************************************
2 
3 Audacity: A Digital Audio Editor
4 
5 TrackView.h
6 
7 Paul Licameli split from class Track
8 
9 **********************************************************************/
10 
11 #ifndef __AUDACITY_TRACK_VIEW__
12 #define __AUDACITY_TRACK_VIEW__
13 
14 #include <memory>
15 #include "CommonTrackPanelCell.h" // to inherit
16 
17 class Track;
18 class TrackList;
21 
22 class AUDACITY_DLL_API TrackView /* not final */ : public CommonTrackCell
23  , public std::enable_shared_from_this<TrackView>
24 {
25  TrackView( const TrackView& ) = delete;
26  TrackView &operator=( const TrackView& ) = delete;
27 
28 public:
29  enum : unsigned { DefaultHeight = 150 };
30 
31  explicit
32  TrackView( const std::shared_ptr<Track> &pTrack );
33  virtual ~TrackView() = 0;
34 
35  // some static conveniences, useful for summation over track iterator
36  // ranges
37  static int GetTrackHeight( const Track *pTrack );
38  static int GetChannelGroupHeight( const Track *pTrack );
39  // Total height of the given track and all previous ones (constant time!)
40  static int GetCumulativeHeight( const Track *pTrack );
41  static int GetTotalHeight( const TrackList &list );
42 
43  // Copy view state, for undo/redo purposes
44  void CopyTo( Track &track ) const override;
45 
46  static TrackView &Get( Track & );
47  static const TrackView &Get( const Track & );
48 
49  bool GetMinimized() const { return mMinimized; }
50  void SetMinimized( bool minimized );
51 
52  int GetY() const { return mY; }
53  int GetActualHeight() const { return mHeight; }
54  virtual int GetMinimizedHeight() const = 0;
55  int GetHeight() const;
56 
57  void SetY(int y) { DoSetY( y ); }
58  void SetHeight(int height);
59 
60  // Return another, associated TrackPanelCell object that implements the
61  // mouse actions for the vertical ruler
62  std::shared_ptr<TrackVRulerControls> GetVRulerControls();
63  std::shared_ptr<const TrackVRulerControls> GetVRulerControls() const;
64 
65 
66  void WriteXMLAttributes( XMLWriter & ) const override;
67  bool HandleXMLAttribute( const wxChar *attr, const wxChar *value ) override;
68 
69  // New virtual function. The default just returns a one-element array
70  // containing this. Overrides might refine the Y axis.
71  using Refinement = std::vector< std::pair<
72  wxCoord, std::shared_ptr< TrackView >
73  > >;
74  virtual Refinement GetSubViews( const wxRect &rect );
75 
76  // default is false
77  virtual bool IsSpectral() const;
78 
79  virtual void DoSetMinimized( bool isMinimized );
80 
81 protected:
82 
83  // No need yet to make this virtual
84  void DoSetY(int y);
85 
86  void DoSetHeight(int h);
87 
88  // Private factory to make appropriate object; class TrackView handles
89  // memory management thereafter
90  virtual std::shared_ptr<TrackVRulerControls> DoGetVRulerControls() = 0;
91 
92  std::shared_ptr<TrackVRulerControls> mpVRulerControls;
93 
94 private:
95  bool mMinimized{ false };
96  int mY{ 0 };
97  int mHeight{ DefaultHeight };
98 };
99 
100 #include "../../AttachedVirtualFunction.h"
101 
102 struct DoGetViewTag;
103 
104 using DoGetView =
106  DoGetViewTag,
107  std::shared_ptr< TrackView >,
108  Track
109 >;
110 
111 struct GetDefaultTrackHeightTag;
112 
115  GetDefaultTrackHeightTag,
116  int,
117  Track
118 >;
119 
120 #endif
XMLWriter
Base class for XMLFileWriter and XMLStringWriter that provides the general functionality for creating...
Definition: XMLWriter.h:23
TrackView::TrackView
TrackView(const TrackView &)=delete
CommonTrackCell::CopyTo
virtual void CopyTo(Track &track) const
Definition: CommonTrackPanelCell.cpp:60
AttachedVirtualFunction
Class template generates single-dispatch, open method registry tables.
Definition: AttachedVirtualFunction.h:161
TrackView::GetMinimized
bool GetMinimized() const
Definition: TrackView.h:49
TrackList
A flat linked list of tracks supporting Add, Remove, Clear, and Contains, serialization of the list o...
Definition: Track.h:1263
TrackView::Refinement
std::vector< std::pair< wxCoord, std::shared_ptr< TrackView > > > Refinement
Definition: TrackView.h:73
TrackView::SetY
void SetY(int y)
Definition: TrackView.h:57
TrackView::operator=
TrackView & operator=(const TrackView &)=delete
TrackVRulerControls
Definition: TrackVRulerControls.h:25
CommonTrackCell::WriteXMLAttributes
virtual void WriteXMLAttributes(XMLWriter &) const
Definition: CommonTrackPanelCell.cpp:74
CommonTrackPanelCell.h
TrackView::GetActualHeight
int GetActualHeight() const
Definition: TrackView.h:53
TrackView::GetY
int GetY() const
Definition: TrackView.h:52
TrackView::mpVRulerControls
std::shared_ptr< TrackVRulerControls > mpVRulerControls
Definition: TrackView.h:92
Track
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:238
TrackView
Definition: TrackView.h:24
TrackPanelResizerCell
Definition: TrackPanelResizerCell.h:24
CommonTrackCell::HandleXMLAttribute
virtual bool HandleXMLAttribute(const wxChar *attr, const wxChar *value)
Definition: CommonTrackPanelCell.cpp:78
TrackView::GetMinimizedHeight
virtual int GetMinimizedHeight() const =0
CommonTrackCell
Definition: CommonTrackPanelCell.h:59
TrackView::DoGetVRulerControls
virtual std::shared_ptr< TrackVRulerControls > DoGetVRulerControls()=0