Audacity 3.2.0
WaveChannelView.h
Go to the documentation of this file.
1/**********************************************************************
2
3Audacity: A Digital Audio Editor
4
5WaveChannelView.h
6
7Paul Licameli split from class WaveTrack
8
9**********************************************************************/
10
11#ifndef __AUDACITY_WAVE_TRACK_VIEW__
12#define __AUDACITY_WAVE_TRACK_VIEW__
13
14#include "../../../ui/CommonChannelView.h"
15#include "ClientData.h"
16#include "SampleCount.h"
17#include "WaveTrack.h"
18namespace WaveChannelViewConstants{ enum Display : int; }
20
21class ClipTimes;
22class CutlineHandle;
24class WaveChannel;
25class WaveChannelView;
27class ZoomInfo;
28
29
32
36
37class wxDC;
38
39class AUDACITY_DLL_API WaveChannelSubView : public CommonChannelView
40{
41public:
42
45
46 explicit
47 WaveChannelSubView(WaveChannelView &waveChannelView);
48
49 std::shared_ptr<WaveChannel> FindWaveChannel();
50
51 virtual const Type &SubViewType() const = 0;
52
53 // For undo and redo purpose
54 // Empty abstract method to be inherited, for copying the spectral data in SpectrumSubView
55 virtual void CopyToSubView(WaveChannelSubView *destSubView) const;
56
57 std::pair<
58 bool, // if true, hit-testing is finished
59 std::vector<UIHandlePtr>
60 > DoDetailedHitTest(
61 const TrackPanelMouseState &state,
62 const AudacityProject *pProject, int currentTool, bool bMultiTool,
63 const std::shared_ptr<WaveChannel> &wt);
64
65protected:
66 static void DrawBoldBoundaries(
67 TrackPanelDrawingContext &context, const WaveChannel &channel,
68 const wxRect &rect);
69
70 std::weak_ptr<WaveChannelView> GetWaveChannelView() const;
71
72 std::vector<MenuItem> GetMenuItems(
73 const wxRect &rect, const wxPoint *pPosition, AudacityProject *pProject )
74 override;
75
76private:
77 std::weak_ptr<SubViewCloseHandle> mCloseHandle;
78 std::weak_ptr<TrackPanelResizeHandle> mResizeHandle;
79 std::weak_ptr<SubViewAdjustHandle> mAdjustHandle;
80 std::weak_ptr<SubViewRearrangeHandle> mRearrangeHandle;
81 std::weak_ptr<WaveClipAdjustBorderHandle> mClipBorderAdjustHandle;
82 std::weak_ptr<CutlineHandle> mCutlineHandle;
83 std::weak_ptr<WaveChannelView> mwWaveChannelView;
84};
85
87 int index;
88 float fraction;
89};
90using WaveChannelSubViewPlacements = std::vector<WaveChannelSubViewPlacement>;
91
92class WaveChannelView;
95>;
96
97class AUDACITY_DLL_API WaveChannelView final
98 : public CommonChannelView
99 , public WaveChannelSubViews
100{
103
104public:
105 static constexpr int kChannelSeparatorThickness{ 8 };
106
108
109 static WaveChannelView &Get(WaveChannel &channel);
110 static const WaveChannelView &Get(const WaveChannel &channel);
111 static WaveChannelView *Find(WaveChannel *pChannel);
112 static const WaveChannelView *Find(const WaveChannel *pChannel);
113
115 static WaveChannelView &GetFirst(WaveTrack &wt);
116
118 static const WaveChannelView &GetFirst(const WaveTrack &wt);
119
121 static WaveChannelView *FindFirst(WaveTrack *pWt);
122
124 static const WaveChannelView *FindFirst(const WaveTrack *pWt);
125
126 using CommonChannelView::CommonChannelView;
127 ~WaveChannelView() override;
128
129 std::shared_ptr<WaveChannel> FindWaveChannel();
130
131 // Preserve some view state too for undo/redo purposes
132 void CopyTo(Track &track, size_t iChannel) const override;
133
134 std::shared_ptr<ChannelVRulerControls> DoGetVRulerControls() override;
135
136 // CommonChannelView implementation
137 void Reparent(const std::shared_ptr<Track> &parent, size_t iChannel)
138 override;
139
140 static std::pair<
141 bool, // if true, hit-testing is finished
142 std::vector<UIHandlePtr>
143 > DoDetailedHitTest(
144 const TrackPanelMouseState &state,
145 const AudacityProject *pProject, int currentTool, bool bMultiTool,
146 const std::shared_ptr<WaveChannel> &wt,
147 CommonChannelView &view);
148
149 std::vector<WaveChannelSubView::Type> GetDisplays() const;
150 void SetDisplay(Display display, bool exclusive = true);
151
153 { return DoGetPlacements(); }
155 { DoGetPlacements() = placements; }
156
157 // Return true if successful. Fails if you try to toggle off the only
158 // sub-view.
159 bool ToggleSubView( Display id );
160
161 // Get all the sub-views, in a sequence that is unspecified but in
162 // correspondence with the result of SavePlacements
163 std::vector<std::shared_ptr<WaveChannelSubView>> GetAllSubViews();
164
165 // Return cached height of rect in last call of GetSubViews
166 wxCoord GetLastHeight() const { return mLastHeight; }
167
168 bool GetMultiView() const { return DoGetMultiView(); }
169 void SetMultiView( bool value ) { DoGetMultiView() = value; }
170
171 WaveTrack::IntervalHolder GetSelectedClip();
172
173 // Returns a visible subset of subviews, sorted in the same
174 // order as they are supposed to be displayed
175
176
177 // Get the visible sub-views,
178 // if rect is provided then result will contain
179 // y coordinate for each subview within this rect
180 Refinement GetSubViews(const wxRect* rect = nullptr);
181
182 unsigned CaptureKey
183 (wxKeyEvent& event, ViewInfo& viewInfo, wxWindow* pParent,
184 AudacityProject* project) override;
185
186 unsigned KeyDown(wxKeyEvent& event, ViewInfo& viewInfo, wxWindow* pParent,
187 AudacityProject* project) override;
188
189 unsigned Char
190 (wxKeyEvent& event, ViewInfo& viewInfo, wxWindow* pParent,
191 AudacityProject* project) override;
192
193 unsigned LoseFocus(AudacityProject *project) override;
194
195 static bool ClipDetailsVisible(
196 const ClipTimes& clip, const ZoomInfo& zoomInfo, const wxRect& viewRect);
197 static wxRect ClipHitTestArea(const ClipTimes& clip,
198 const ZoomInfo& zoomInfo, const wxRect& viewRect);
199 static bool HitTest(const ClipTimes& clip, const ZoomInfo& zoomInfo, const wxRect& rect, const wxPoint& pos);
200
201 //FIXME: These functions do not push state to undo history
202 //because attempt to do so leads to a focus lose which, in
203 //turn finalizes text editing (state is saved after text
204 //editing was intentionally finished instead)
205
206 bool CutSelectedText(AudacityProject& project);
207 bool CopySelectedText(AudacityProject& project);
208 bool PasteText(AudacityProject& project);
209 bool SelectAllText(AudacityProject& project);
210
211 std::shared_ptr<CommonTrackCell> GetAffordanceControls() override;
212
213private:
214 void BuildSubViews() const;
215 void DoSetDisplay(Display display, bool exclusive = true);
216 bool SelectNextClip(ViewInfo& viewInfo, AudacityProject* project, bool forward);
217
218 // TrackPanelDrawable implementation
219 void Draw(
221 const wxRect &rect, unsigned iPass ) override;
222
223 std::vector<UIHandlePtr> DetailedHitTest
224 (const TrackPanelMouseState &state,
225 const AudacityProject *pProject, int currentTool, bool bMultiTool)
226 override;
227
228 // ChannelView implementation
229 Refinement GetSubViews(const wxRect& rect) override;
230
231private:
232
233 void DoSetMinimized( bool minimized ) override;
234
235 // Placements are in correspondence with the array of sub-views
236 // in the WaveChannelSubViews base class, though their sequence is
237 // unspecified and maybe different in different platforms.
238 WaveChannelSubViewPlacements &DoGetPlacements();
239 const WaveChannelSubViewPlacements &DoGetPlacements() const;
240 mutable wxCoord mLastHeight{};
241
242 bool &DoGetMultiView();
243 bool DoGetMultiView() const;
244
245 std::shared_ptr<CommonTrackCell> DoGetAffordance(Track& track);
246
247 std::shared_ptr<CommonTrackCell> mpAffordanceCellControl;
248
249 std::weak_ptr<TrackPanelCell> mKeyEventDelegate;
250
251 std::weak_ptr<WaveTrackAffordanceHandle> mAffordanceHandle;
252};
253#endif
Utility ClientData::Site to register hooks into a host class that attach client data.
const auto project
@ kChannelSeparatorThickness
std::vector< WaveChannelSubViewPlacement > WaveChannelSubViewPlacements
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
virtual std::shared_ptr< ChannelVRulerControls > DoGetVRulerControls()=0
static ChannelView * Find(Channel *pChannel)
void Reparent(const std::shared_ptr< Track > &parent, size_t iChannel) override
Object may be shared among tracks but hold a special back-pointer to one of them; reassign it.
Definition: ChannelView.cpp:31
static ChannelView & Get(Channel &channel)
virtual std::shared_ptr< CommonTrackCell > GetAffordanceControls()
virtual void DoSetMinimized(bool isMinimized)
void CopyTo(Track &track, size_t iChannel) const override
Copy state, for undo/redo purposes.
Definition: ChannelView.cpp:67
virtual Refinement GetSubViews(const wxRect &rect)
Utility to register hooks into a host class that attach client data.
Definition: ClientData.h:229
Implements some hit-testing shared by many ChannelView subtypes.
std::vector< UIHandlePtr > HitTest(const TrackPanelMouseState &, const AudacityProject *pProject) final
virtual std::vector< UIHandlePtr > DetailedHitTest(const TrackPanelMouseState &, const AudacityProject *pProject, int currentTool, bool bMultiTool)=0
virtual std::vector< MenuItem > GetMenuItems(const wxRect &rect, const wxPoint *pPosition, AudacityProject *pProject)
Return a list of items for DoContextMenu() (empties for separators)
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:110
virtual unsigned KeyDown(wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent, AudacityProject *project)
virtual unsigned CaptureKey(wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent, AudacityProject *project)
virtual unsigned LoseFocus(AudacityProject *project)
virtual unsigned Char(wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent, AudacityProject *project)
virtual void Draw(TrackPanelDrawingContext &context, const wxRect &rect, unsigned iPass)
Constructed from one channel, but changes height of all channels in a track.
Holds a msgid for the translation catalog; may also bind format arguments.
std::weak_ptr< SubViewAdjustHandle > mAdjustHandle
virtual const Type & SubViewType() const =0
std::weak_ptr< CutlineHandle > mCutlineHandle
std::weak_ptr< TrackPanelResizeHandle > mResizeHandle
std::weak_ptr< WaveChannelView > mwWaveChannelView
std::weak_ptr< WaveClipAdjustBorderHandle > mClipBorderAdjustHandle
std::weak_ptr< SubViewCloseHandle > mCloseHandle
std::weak_ptr< SubViewRearrangeHandle > mRearrangeHandle
void SetMultiView(bool value)
const WaveChannelSubViewPlacements & SavePlacements() const
bool GetMultiView() const
std::weak_ptr< WaveTrackAffordanceHandle > mAffordanceHandle
WaveChannelView & operator=(const WaveChannelView &)=delete
std::shared_ptr< CommonTrackCell > mpAffordanceCellControl
WaveChannelView(const WaveChannelView &)=delete
std::weak_ptr< TrackPanelCell > mKeyEventDelegate
wxCoord GetLastHeight() const
void RestorePlacements(const WaveChannelSubViewPlacements &placements)
Implements some features which are specific to Wave Clips.
A Track that contains audio waveform data.
Definition: WaveTrack.h:203
std::shared_ptr< Interval > IntervalHolder
Definition: WaveTrack.h:209
@ SkipCopying
ignore the source and leave empty