Audacity  3.0.3
SampleHandle.h
Go to the documentation of this file.
1 /**********************************************************************
2 
3 Audacity: A Digital Audio Editor
4 
5 SampleHandle.h
6 
7 Paul Licameli
8 
9 **********************************************************************/
10 
11 #ifndef __AUDACITY_SAMPLE_HANDLE__
12 #define __AUDACITY_SAMPLE_HANDLE__
13 
14 #include "../../../../UIHandle.h"
15 #include "SampleCount.h"
16 
17 class wxMouseEvent;
18 class wxMouseState;
19 
20 class Track;
21 class ViewInfo;
22 class WaveTrack;
23 
24 class SampleHandle final : public UIHandle
25 {
26  SampleHandle(const SampleHandle&) = delete;
28  (const wxMouseState &state, const AudacityProject *pProject, bool unsafe);
29 
30 public:
31  explicit SampleHandle( const std::shared_ptr<WaveTrack> &pTrack );
32 
33  SampleHandle &operator=(const SampleHandle&) = default;
34 
36  (std::weak_ptr<SampleHandle> &holder,
37  const wxMouseState &state, const std::shared_ptr<WaveTrack> &pTrack);
38  static UIHandlePtr HitTest
39  (std::weak_ptr<SampleHandle> &holder,
40  const wxMouseState &state, const wxRect &rect,
41  const AudacityProject *pProject, const std::shared_ptr<WaveTrack> &pTrack);
42 
43  virtual ~SampleHandle();
44 
45  std::shared_ptr<WaveTrack> GetTrack() const { return mClickedTrack; }
46 
47  void Enter(bool forward, AudacityProject *) override;
48 
50  (const TrackPanelMouseEvent &event, AudacityProject *pProject) override;
51 
52  Result Drag
53  (const TrackPanelMouseEvent &event, AudacityProject *pProject) override;
54 
56  (const TrackPanelMouseState &state, AudacityProject *pProject)
57  override;
58 
60  (const TrackPanelMouseEvent &event, AudacityProject *pProject,
61  wxWindow *pParent) override;
62 
63  Result Cancel(AudacityProject *pProject) override;
64 
65  bool StopsOnKeystroke() override { return true; }
66 
67 private:
69  (const wxMouseEvent &event, const ViewInfo &viewInfo, double t0);
70 
71  std::shared_ptr<WaveTrack> mClickedTrack;
72  wxRect mRect{};
73 
77  bool mAltKey{};
78 };
79 
80 #endif
SampleHandle::Cancel
Result Cancel(AudacityProject *pProject) override
Definition: SampleHandle.cpp:429
WaveTrack
A Track that contains audio waveform data.
Definition: WaveTrack.h:69
SampleHandle::Enter
void Enter(bool forward, AudacityProject *) override
Definition: SampleHandle.cpp:42
SampleHandle::mLastDragSampleValue
float mLastDragSampleValue
Definition: SampleHandle.h:76
SampleHandle::mClickedStartSample
sampleCount mClickedStartSample
Definition: SampleHandle.h:74
SampleHandle::HitAnywhere
static UIHandlePtr HitAnywhere(std::weak_ptr< SampleHandle > &holder, const wxMouseState &state, const std::shared_ptr< WaveTrack > &pTrack)
Definition: SampleHandle.cpp:73
ViewInfo
Definition: ViewInfo.h:202
SampleHandle::operator=
SampleHandle & operator=(const SampleHandle &)=default
SampleHandle::FindSampleEditingLevel
float FindSampleEditingLevel(const wxMouseEvent &event, const ViewInfo &viewInfo, double t0)
Definition: SampleHandle.cpp:437
SampleHandle::~SampleHandle
virtual ~SampleHandle()
Definition: SampleHandle.cpp:163
SampleHandle::HitPreview
static HitTestPreview HitPreview(const wxMouseState &state, const AudacityProject *pProject, bool unsafe)
Definition: SampleHandle.cpp:50
SampleHandle::StopsOnKeystroke
bool StopsOnKeystroke() override
Definition: SampleHandle.h:65
SampleHandle::Preview
HitTestPreview Preview(const TrackPanelMouseState &state, AudacityProject *pProject) override
Definition: SampleHandle.cpp:402
UIHandle
Short-lived drawing and event-handling object associated with a TrackPanelCell.
Definition: UIHandle.h:35
SampleHandle
Definition: SampleHandle.h:25
SampleCount.h
UIHandle::Result
unsigned Result
Definition: UIHandle.h:38
SampleHandle::Drag
Result Drag(const TrackPanelMouseEvent &event, AudacityProject *pProject) override
Definition: SampleHandle.cpp:319
UIHandlePtr
std::shared_ptr< UIHandle > UIHandlePtr
Definition: CellularPanel.h:28
HitTestPreview
Definition: HitTestResult.h:20
SampleHandle::SampleHandle
SampleHandle(const SampleHandle &)=delete
SampleHandle::mLastDragSample
sampleCount mLastDragSample
Definition: SampleHandle.h:75
SampleHandle::GetTrack
std::shared_ptr< WaveTrack > GetTrack() const
Definition: SampleHandle.h:45
SampleHandle::mClickedTrack
std::shared_ptr< WaveTrack > mClickedTrack
Definition: SampleHandle.h:71
SampleHandle::mRect
wxRect mRect
Definition: SampleHandle.h:72
Track
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:239
sampleCount
Positions or offsets within audio files need a wide type.
Definition: SampleCount.h:18
AudacityProject
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:92
TrackPanelMouseEvent
Definition: TrackPanelMouseEvent.h:46
TrackPanelMouseState
Definition: TrackPanelMouseEvent.h:28
SampleHandle::Click
Result Click(const TrackPanelMouseEvent &event, AudacityProject *pProject) override
Definition: SampleHandle.cpp:190
SampleHandle::mAltKey
bool mAltKey
Definition: SampleHandle.h:77
SampleHandle::Release
Result Release(const TrackPanelMouseEvent &event, AudacityProject *pProject, wxWindow *pParent) override
Definition: SampleHandle.cpp:409
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