Audacity 3.2.0
BrushHandle.h
Go to the documentation of this file.
1/**********************************************************************
2
3Audacity: A Digital Audio Editor
4
5BrushHandle.h
6
7Paul Licameli split from TrackPanel.cpp
8
9**********************************************************************/
10
11#ifndef __AUDACITY_BRUSH_HANDLE__
12#define __AUDACITY_BRUSH_HANDLE__
13
14#include <vector>
15#include "ProjectSettings.h"
17#include "../../UIHandle.h"
18#include "SelectedRegion.h"
19
20class AudacityProject;
22class SpectrumAnalyst;
23class Track;
24class ChannelView;
25class TrackList;
26class ViewInfo;
27class WaveTrack;
28class wxMouseState;
29
30class AUDACITY_DLL_API BrushHandle : public UIHandle
31{
33
34public:
36 // Call Init() on click; Commit() on release; destroy on cancel
37 class StateSaver {
38 public:
39 virtual ~StateSaver();
40 virtual void Init( AudacityProject &project, bool clearAll ) = 0;
41
42 void Commit()
43 {
44 mCommitted = true;
45 }
46
47 protected:
48 bool mCommitted = false;
49 };
50
51 explicit BrushHandle(
52 std::shared_ptr<StateSaver> pStateSaver,
53 const std::shared_ptr<ChannelView> &pChannelView,
54 const TrackList &trackList,
55 const TrackPanelMouseState &st, const ViewInfo &viewInfo,
56 const std::shared_ptr<SpectralData> &pSpectralData,
57 const ProjectSettings &pSettings);
58
59 BrushHandle &operator=(const BrushHandle&) = default;
60
61 virtual ~BrushHandle();
62
63 std::shared_ptr<const Track> FindTrack() const override;
64
65 bool IsDragging() const override;
66
67 void Enter(bool forward, AudacityProject *pProject) override;
68
69 bool Escape(AudacityProject *pProject) override;
70
71 void HandleHopBinData(int hopNum, int freqBinNum);
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*) override;
88
89private:
90 std::shared_ptr<StateSaver> mpStateSaver;
91 std::shared_ptr<SpectralData> mpSpectralData;
92
93 std::shared_ptr<WaveChannel> FindChannel();
94
95 // TrackPanelDrawable implementation
96 void Draw(
98 const wxRect &rect, unsigned iPass ) override;
99
100 std::weak_ptr<ChannelView> mpView;
101 wxRect mRect{};
102
103 // Example: For window size of 1024, with ratio 0.01
104 // It searches for (+-) 1024*0.01 = 10 bins
105 double mFreqSnappingRatio { 0.01 };
106
107 // Overtones bin will be selected according to the 0.999x of the dragged area
108 double mOvertonesThreshold { 0.999 };
109
110 bool mIsSmartSelection, mIsOvertones;
111 long long mSampleCountUpperBound, mSampleCountLowerBound;
112 wxInt64 mFreqUpperBound, mFreqLowerBound;
113 int mMostRecentX{ -1 }, mMostRecentY{ -1 };
116
117 std::shared_ptr<SelectionStateChanger> mSelectionStateChanger;
118};
119#endif
const auto project
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
virtual void Init(AudacityProject &project, bool clearAll)=0
std::shared_ptr< SelectionStateChanger > mSelectionStateChanger
Definition: BrushHandle.h:117
std::shared_ptr< StateSaver > mpStateSaver
Definition: BrushHandle.h:90
long long mSampleCountLowerBound
Definition: BrushHandle.h:111
BrushHandle(const BrushHandle &)
wxInt64 mFreqLowerBound
Definition: BrushHandle.h:112
bool mbCtrlDown
Definition: BrushHandle.h:115
std::weak_ptr< ChannelView > mpView
Definition: BrushHandle.h:100
int mBrushRadius
Definition: BrushHandle.h:114
bool mIsOvertones
Definition: BrushHandle.h:110
BrushHandle & operator=(const BrushHandle &)=default
std::shared_ptr< SpectralData > mpSpectralData
Definition: BrushHandle.h:91
Holds various per-project settings values, and sends events to the project when certain values change...
Used for finding the peaks, for snapping to peaks.
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:110
A flat linked list of tracks supporting Add, Remove, Clear, and Contains, serialization of the list o...
Definition: Track.h:850
virtual void Draw(TrackPanelDrawingContext &context, const wxRect &rect, unsigned iPass)
Short-lived drawing and event-handling object associated with a TrackPanelCell.
Definition: UIHandle.h:37
virtual void Enter(bool forward, AudacityProject *pProject)
Definition: UIHandle.cpp:19
virtual Result Drag(const TrackPanelMouseEvent &event, AudacityProject *pProject)=0
virtual Result Release(const TrackPanelMouseEvent &event, AudacityProject *pProject, wxWindow *pParent)=0
unsigned Result
Definition: UIHandle.h:40
virtual std::shared_ptr< const Track > FindTrack() const =0
virtual bool IsDragging() const
Definition: UIHandle.cpp:57
virtual HitTestPreview Preview(const TrackPanelMouseState &state, AudacityProject *pProject)=0
virtual bool Escape(AudacityProject *pProject)
Definition: UIHandle.cpp:38
virtual Result Cancel(AudacityProject *pProject)=0
virtual Result Click(const TrackPanelMouseEvent &event, AudacityProject *pProject)=0
A Track that contains audio waveform data.
Definition: WaveTrack.h:203