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 Channel;
18class NoteTrack;
19class Track;
20class ViewInfo;
21
22class StretchHandle : public UIHandle
23{
24public:
26 stretchNone = 0, // false value!
30 };
31
32 // Stretching applies to a selected region after quantizing the
33 // region to beat boundaries (subbeat stretching is not supported,
34 // but maybe it should be enabled with shift or ctrl or something)
35 // Stretching can drag the left boundary (the right stays fixed),
36 // the right boundary (the left stays fixed), or the center (splits
37 // the selection into two parts: when left part grows, the right
38 // part shrinks, keeping the leftmost and rightmost boundaries
39 // fixed.
40 struct StretchState {
41 StretchEnum mMode { stretchCenter }; // remembers what to drag
42
43 using QuantizedTimeAndBeat = std::pair< double, double >;
44
48 double mLeftBeats {}; // how many beats from left to cursor
49 double mRightBeats {}; // how many beats from cursor to right
50
52 };
53
54private:
56 static HitTestPreview HitPreview(StretchEnum stretchMode, bool unsafe);
57
58public:
59 explicit StretchHandle
60 ( const std::shared_ptr<NoteTrack> &pTrack,
61 const StretchState &stretchState );
62
64
65 static UIHandlePtr HitTest
66 (std::weak_ptr<StretchHandle> &holder,
67 const TrackPanelMouseState &state, const AudacityProject *pProject,
68 const std::shared_ptr<NoteTrack> &pTrack );
69
70 virtual ~StretchHandle();
71
72 std::shared_ptr<const Track> FindTrack() const override;
73
75 (const TrackPanelMouseEvent &event, AudacityProject *pProject) override;
76
78 (const TrackPanelMouseEvent &event, AudacityProject *pProject) override;
79
81 (const TrackPanelMouseState &state, AudacityProject *pProject)
82 override;
83
85 (const TrackPanelMouseEvent &event, AudacityProject *pProject,
86 wxWindow *pParent) override;
87
88 Result Cancel(AudacityProject *pProject) override;
89
90 bool StopsOnKeystroke() override { return true; }
91
92private:
93 static double GetT0(const Track &track, const ViewInfo &viewInfo);
94 static double GetT1(const Track &track, const ViewInfo &viewInfo);
95
96 void Stretch(AudacityProject *pProject, int mouseXCoordinate,
97 int trackLeftEdge, Channel *pChannel);
98
99 std::shared_ptr<NoteTrack> mpTrack{};
100 int mLeftEdge{ -1 };
101
103};
104
105#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:78
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:90
std::shared_ptr< NoteTrack > mpTrack
Definition: StretchHandle.h:99
static double GetT1(const Track &track, const ViewInfo &viewInfo)
Result Release(const TrackPanelMouseEvent &event, AudacityProject *pProject, wxWindow *pParent) override
std::shared_ptr< const Track > FindTrack() const override
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
void Stretch(AudacityProject *pProject, int mouseXCoordinate, int trackLeftEdge, Channel *pChannel)
Result Cancel(AudacityProject *pProject) override
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:110
Short-lived drawing and event-handling object associated with a TrackPanelCell.
Definition: UIHandle.h:37
unsigned Result
Definition: UIHandle.h:40
QuantizedTimeAndBeat mBeatCenter
Definition: StretchHandle.h:45
QuantizedTimeAndBeat mBeat0
Definition: StretchHandle.h:46
QuantizedTimeAndBeat mBeat1
Definition: StretchHandle.h:47
std::pair< double, double > QuantizedTimeAndBeat
Definition: StretchHandle.h:43