Audacity 3.2.0
TrackView.h
Go to the documentation of this file.
1/**********************************************************************
2
3Audacity: A Digital Audio Editor
4
5TrackView.h
6
7Paul 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
17
18class Track;
19class TrackList;
22
23class AUDACITY_DLL_API TrackView /* not final */ : public CommonTrackCell
24 , public std::enable_shared_from_this<TrackView>
25{
26 TrackView( const TrackView& ) = delete;
27 TrackView &operator=( const TrackView& ) = delete;
28
29public:
30 enum : unsigned { DefaultHeight = 150 };
31
32 explicit
33 TrackView( const std::shared_ptr<Track> &pTrack );
34 virtual ~TrackView() = 0;
35
36 // some static conveniences, useful for summation over track iterator
37 // ranges
38 static int GetTrackHeight( const Track *pTrack );
39 static int GetChannelGroupHeight( const Track *pTrack );
40 // Total height of the given track and all previous ones (constant time!)
41 static int GetCumulativeHeight( const Track *pTrack );
42 static int GetTotalHeight( const TrackList &list );
43
44 // Copy view state, for undo/redo purposes
45 void CopyTo( Track &track ) const override;
46
47 static TrackView &Get( Track & );
48 static const TrackView &Get( const Track & );
49 static TrackView *Find( Track * );
50 static const TrackView *Find( const Track * );
51
52 bool GetMinimized() const { return mMinimized; }
53 void SetMinimized( bool minimized );
54
56 int GetCumulativeHeightBefore() const { return mY; }
57
59
60 int GetExpandedHeight() const { return mHeight; }
61
63
64 virtual int GetMinimizedHeight() const = 0;
65
67
75 int GetHeight() const;
76
78 void SetCumulativeHeightBefore(int y) { DoSetY( y ); }
79
84 void SetExpandedHeight(int height);
85
86 // Return another, associated TrackPanelCell object that implements the
87 // mouse actions for the vertical ruler
88 std::shared_ptr<TrackVRulerControls> GetVRulerControls();
89 std::shared_ptr<const TrackVRulerControls> GetVRulerControls() const;
90
91 // Returns cell that would be used at affordance area, by default returns nullptr,
92 // meaning that track has no such area.
93 virtual std::shared_ptr<CommonTrackCell> GetAffordanceControls();
94
95 void WriteXMLAttributes( XMLWriter & ) const override;
97 const std::string_view& attr, const XMLAttributeValueView& valueView )
98 override;
99
100 // New virtual function. The default just returns a one-element array
101 // containing this. Overrides might refine the Y axis.
102 using Refinement = std::vector< std::pair<
103 wxCoord, std::shared_ptr< TrackView >
104 > >;
105 virtual Refinement GetSubViews( const wxRect &rect );
106
107 // default is false
108 virtual bool IsSpectral() const;
109
110 virtual void DoSetMinimized( bool isMinimized );
111
112private:
113
114 // No need yet to make this virtual
115 void DoSetY(int y);
116
117 void DoSetHeight(int h);
118
119protected:
120
121 // Private factory to make appropriate object; class TrackView handles
122 // memory management thereafter
123 virtual std::shared_ptr<TrackVRulerControls> DoGetVRulerControls() = 0;
124
125 std::shared_ptr<TrackVRulerControls> mpVRulerControls;
126
127private:
128 bool mMinimized{ false };
129 int mY{ 0 };
130 int mHeight{ DefaultHeight };
131};
132
134
135struct DoGetViewTag;
136
139 DoGetViewTag,
140 std::shared_ptr< TrackView >,
141 Track
142>;
144
145struct GetDefaultTrackHeightTag;
146
149 GetDefaultTrackHeightTag,
150 int,
151 Track
152>;
154
155#endif
Utility for non-intrusive definition of a new method on a base class.
DECLARE_EXPORTED_ATTACHED_VIRTUAL(AUDACITY_DLL_API, DoGetView)
Class template generates single-dispatch, open method registry tables.
virtual bool HandleXMLAttribute(const std::string_view &attr, const XMLAttributeValueView &valueView)
Deserialize an attribute, returning true if recognized.
virtual void CopyTo(Track &track) const
Copy state, for undo/redo purposes.
virtual void WriteXMLAttributes(XMLWriter &) const
Serialize persistent attributes.
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:164
A flat linked list of tracks supporting Add, Remove, Clear, and Contains, serialization of the list o...
Definition: Track.h:909
void SetCumulativeHeightBefore(int y)
Set cached value dependent on position within the track list.
Definition: TrackView.h:78
std::shared_ptr< TrackVRulerControls > mpVRulerControls
Definition: TrackView.h:125
bool GetMinimized() const
Definition: TrackView.h:52
int GetCumulativeHeightBefore() const
Definition: TrackView.h:56
int GetExpandedHeight() const
Definition: TrackView.h:60
TrackView(const TrackView &)=delete
virtual std::shared_ptr< TrackVRulerControls > DoGetVRulerControls()=0
virtual int GetMinimizedHeight() const =0
std::vector< std::pair< wxCoord, std::shared_ptr< TrackView > > > Refinement
Definition: TrackView.h:104
TrackView & operator=(const TrackView &)=delete
A view into an attribute value. The class does not take the ownership of the data.
Base class for XMLFileWriter and XMLStringWriter that provides the general functionality for creating...
Definition: XMLWriter.h:25
PROJECT_FILE_IO_API wxString Find(const FilePath &path)
Services * Get()
Fetch the global instance, or nullptr if none is yet installed.
Definition: BasicUI.cpp:196