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
71 std::shared_ptr<const Channel> FindChannel() const override;
72
74 (const TrackPanelMouseEvent &event, AudacityProject *pProject) override;
75
77 (const TrackPanelMouseEvent &event, AudacityProject *pProject) override;
78
80 (const TrackPanelMouseState &state, AudacityProject *pProject)
81 override;
82
84 (const TrackPanelMouseEvent &event, AudacityProject *pProject,
85 wxWindow *pParent) override;
86
87 Result Cancel(AudacityProject *pProject) override;
88
89 bool StopsOnKeystroke() override { return true; }
90
91private:
92 static double GetT0(const Track &track, const ViewInfo &viewInfo);
93 static double GetT1(const Track &track, const ViewInfo &viewInfo);
94
95 void Stretch
96 (AudacityProject *pProject, int mouseXCoordinate, int trackLeftEdge, Track *pTrack);
97
98 std::shared_ptr<NoteTrack> mpTrack{};
99 int mLeftEdge{ -1 };
100
102};
103
104#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:90
A Track that is used for Midi notes. (Somewhat old code).
Definition: NoteTrack.h:86
Result Click(const TrackPanelMouseEvent &event, AudacityProject *pProject) override
Result Drag(const TrackPanelMouseEvent &event, AudacityProject *pProject) override
StretchState mStretchState
static double GetT0(const Track &track, const ViewInfo &viewInfo)
bool StopsOnKeystroke() override
Definition: StretchHandle.h:89
std::shared_ptr< NoteTrack > mpTrack
Definition: StretchHandle.h:98
std::shared_ptr< const Channel > FindChannel() const override
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:122
Short-lived drawing and event-handling object associated with a TrackPanelCell.
Definition: UIHandle.h:36
unsigned Result
Definition: UIHandle.h:39
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