| 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 WaveChannel; |
| 23 |
class WaveClipChannel; |
| 24 |
|
| 25 |
class SampleHandle final : public UIHandle |
| 26 |
{ |
| 27 |
SampleHandle(const SampleHandle&) = delete; |
| 28 |
static HitTestPreview HitPreview |
| 29 |
(const wxMouseState &state, const AudacityProject *pProject, bool unsafe); |
| 30 |
|
| 31 |
public: |
| 32 |
explicit SampleHandle(const std::shared_ptr<WaveChannel> &pTrack); |
| 33 |
|
| 34 |
SampleHandle &operator=(const SampleHandle&) = default; |
| 35 |
|
| 36 |
static UIHandlePtr HitAnywhere( |
| 37 |
std::weak_ptr<SampleHandle> &holder, |
| 38 |
const wxMouseState &state, const std::shared_ptr<WaveChannel> &pChannel); |
| 39 |
static UIHandlePtr HitTest( |
| 40 |
std::weak_ptr<SampleHandle> &holder, |
| 41 |
const wxMouseState &state, const wxRect &rect, |
| 42 |
const AudacityProject *pProject, |
| 43 |
const std::shared_ptr<WaveChannel> &pChannel); |
| 44 |
|
| 45 |
virtual ~SampleHandle(); |
| 46 |
|
| 47 |
std::shared_ptr<const Track> FindTrack() const override; |
| 48 |
|
| 49 |
void Enter(bool forward, AudacityProject *) override; |
| 50 |
|
| 51 |
Result Click |
| 52 |
(const TrackPanelMouseEvent &event, AudacityProject *pProject) override; |
| 53 |
|
| 54 |
Result Drag |
| 55 |
(const TrackPanelMouseEvent &event, AudacityProject *pProject) override; |
| 56 |
|
| 57 |
HitTestPreview Preview |
| 58 |
(const TrackPanelMouseState &state, AudacityProject *pProject) |
| 59 |
override; |
| 60 |
|
| 61 |
Result Release |
| 62 |
(const TrackPanelMouseEvent &event, AudacityProject *pProject, |
| 63 |
wxWindow *pParent) override; |
| 64 |
|
| 65 |
Result Cancel(AudacityProject *pProject) override; |
| 66 |
|
| 67 |
bool StopsOnKeystroke() override { return true; } |
| 68 |
|
| 69 |
private: |
| 70 |
float FindSampleEditingLevel |
| 71 |
(const wxMouseEvent &event, const ViewInfo &viewInfo, double t0); |
| 72 |
|
| 73 |
std::shared_ptr<WaveChannel> mClickedTrack; |
| 74 |
std::shared_ptr<WaveClipChannel> mClickedClip {}; |
| 75 |
wxRect mRect{}; |
| 76 |
|
| 77 |
int mClickedStartPixel {}; |
| 78 |
int mLastDragPixel {}; |
| 79 |
float mLastDragSampleValue{}; |
| 80 |
bool mAltKey{}; |
| 81 |
}; |
| 82 |
|
| 83 |
#endif |