Audacity 3.2.0
StretchHandle.h
Go to the documentation of this file.
1/**********************************************************************
2
3Audacity: A Digital Audio Editor
4
5StretchHandle.h
6
7Paul Licameli split from TrackPanel.cpp
8
9**********************************************************************/
10
11#ifndef __AUDACITY_STRETCH_HANDLE__
12#define __AUDACITY_STRETCH_HANDLE__
13
14#include "../../../../UIHandle.h"
15
16class Alg_seq;
17class NoteTrack;
18class Track;
19class ViewInfo;
20
21class StretchHandle : public UIHandle
22{
23public:
25 stretchNone = 0, // false value!
29 };
30
31 // Stretching applies to a selected region after quantizing the
32 // region to beat boundaries (subbeat stretching is not supported,
33 // but maybe it should be enabled with shift or ctrl or something)
34 // Stretching can drag the left boundary (the right stays fixed),
35 // the right boundary (the left stays fixed), or the center (splits
36 // the selection into two parts: when left part grows, the right
37 // part shrinks, keeping the leftmost and rightmost boundaries
38 // fixed.
39 struct StretchState {
40 StretchEnum mMode { stretchCenter }; // remembers what to drag
41
42 using QuantizedTimeAndBeat = std::pair< double, double >;
43
47 double mLeftBeats {}; // how many beats from left to cursor
48 double mRightBeats {}; // how many beats from cursor to right
49
51 };
52
53private:
55 static HitTestPreview HitPreview(StretchEnum stretchMode, bool unsafe);
56
57public:
58 explicit StretchHandle
59 ( const std::shared_ptr<NoteTrack> &pTrack,
60 const StretchState &stretchState );
61
63
64 static UIHandlePtr HitTest
65 (std::weak_ptr<StretchHandle> &holder,
66 const TrackPanelMouseState &state, const AudacityProject *pProject,
67 const std::shared_ptr<NoteTrack> &pTrack );
68
69 virtual ~StretchHandle();
70
72 (const TrackPanelMouseEvent &event, AudacityProject *pProject) override;
73
75 (const TrackPanelMouseEvent &event, AudacityProject *pProject) override;
76
78 (const TrackPanelMouseState &state, AudacityProject *pProject)
79 override;
80
82 (const TrackPanelMouseEvent &event, AudacityProject *pProject,
83 wxWindow *pParent) override;
84
85 Result Cancel(AudacityProject *pProject) override;
86
87 bool StopsOnKeystroke() override { return true; }
88
89private:
90 static double GetT0(const Track &track, const ViewInfo &viewInfo);
91 static double GetT1(const Track &track, const ViewInfo &viewInfo);
92
93 void Stretch
94 (AudacityProject *pProject, int mouseXCoordinate, int trackLeftEdge, Track *pTrack);
95
96 std::shared_ptr<NoteTrack> mpTrack{};
97 int mLeftEdge{ -1 };
98
100};
101
102#endif
std::shared_ptr< UIHandle > UIHandlePtr
Definition: CellularPanel.h:28
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:89
A Track that is used for Midi notes. (Somewhat old code).
Definition: NoteTrack.h:67
Result Click(const TrackPanelMouseEvent &event, AudacityProject *pProject) override
Result Drag(const TrackPanelMouseEvent &event, AudacityProject *pProject) override
StretchState mStretchState
Definition: StretchHandle.h:99
static double GetT0(const Track &track, const ViewInfo &viewInfo)
bool StopsOnKeystroke() override
Definition: StretchHandle.h:87
std::shared_ptr< NoteTrack > mpTrack
Definition: StretchHandle.h:96
static double GetT1(const Track &track, const ViewInfo &viewInfo)
Result Release(const TrackPanelMouseEvent &event, AudacityProject *pProject, wxWindow *pParent) override
void Stretch(AudacityProject *pProject, int mouseXCoordinate, int trackLeftEdge, Track *pTrack)
HitTestPreview Preview(const TrackPanelMouseState &state, AudacityProject *pProject) override
StretchHandle(const StretchHandle &)
static HitTestPreview HitPreview(StretchEnum stretchMode, bool unsafe)
virtual ~StretchHandle()
static UIHandlePtr HitTest(std::weak_ptr< StretchHandle > &holder, const TrackPanelMouseState &state, const AudacityProject *pProject, const std::shared_ptr< NoteTrack > &pTrack)
StretchHandle & operator=(const StretchHandle &)=default
Result Cancel(AudacityProject *pProject) override
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:225
Short-lived drawing and event-handling object associated with a TrackPanelCell.
Definition: UIHandle.h:35
unsigned Result
Definition: UIHandle.h:38
QuantizedTimeAndBeat mBeatCenter
Definition: StretchHandle.h:44
QuantizedTimeAndBeat mBeat0
Definition: StretchHandle.h:45
QuantizedTimeAndBeat mBeat1
Definition: StretchHandle.h:46
std::pair< double, double > QuantizedTimeAndBeat
Definition: StretchHandle.h:42