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 bool IsClicked() const;
64
65 void Enter(bool forward, AudacityProject *pProject) override;
66
67 bool Escape(AudacityProject *pProject) override;
68
69 void HandleHopBinData(int hopNum, int freqBinNum);
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*) override;
86
87private:
88 std::shared_ptr<StateSaver> mpStateSaver;
89 std::shared_ptr<SpectralData> mpSpectralData;
90
91 std::weak_ptr<Track> FindTrack();
92
93 // TrackPanelDrawable implementation
94 void Draw(
96 const wxRect &rect, unsigned iPass ) override;
97
98 std::weak_ptr<ChannelView> mpView;
99 wxRect mRect{};
100
101 // Example: For window size of 1024, with ratio 0.01
102 // It searches for (+-) 1024*0.01 = 10 bins
103 double mFreqSnappingRatio { 0.01 };
104
105 // Overtones bin will be selected according to the 0.999x of the dragged area
106 double mOvertonesThreshold { 0.999 };
107
108 bool mIsSmartSelection, mIsOvertones;
109 long long mSampleCountUpperBound, mSampleCountLowerBound;
110 wxInt64 mFreqUpperBound, mFreqLowerBound;
111 int mMostRecentX{ -1 }, mMostRecentY{ -1 };
114
115 std::shared_ptr<SelectionStateChanger> mSelectionStateChanger;
116};
117#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:115
std::shared_ptr< StateSaver > mpStateSaver
Definition: BrushHandle.h:88
long long mSampleCountLowerBound
Definition: BrushHandle.h:109
BrushHandle(const BrushHandle &)
wxInt64 mFreqLowerBound
Definition: BrushHandle.h:110
bool mbCtrlDown
Definition: BrushHandle.h:113
std::weak_ptr< ChannelView > mpView
Definition: BrushHandle.h:98
int mBrushRadius
Definition: BrushHandle.h:112
bool mIsOvertones
Definition: BrushHandle.h:108
BrushHandle & operator=(const BrushHandle &)=default
std::shared_ptr< SpectralData > mpSpectralData
Definition: BrushHandle.h:89
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:123
A flat linked list of tracks supporting Add, Remove, Clear, and Contains, serialization of the list o...
Definition: Track.h:987
virtual void Draw(TrackPanelDrawingContext &context, const wxRect &rect, unsigned iPass)
Short-lived drawing and event-handling object associated with a TrackPanelCell.
Definition: UIHandle.h:35
virtual void Enter(bool forward, AudacityProject *pProject)
Definition: UIHandle.cpp:20
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:38
virtual HitTestPreview Preview(const TrackPanelMouseState &state, AudacityProject *pProject)=0
virtual bool Escape(AudacityProject *pProject)
Definition: UIHandle.cpp:39
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:220
std::shared_ptr< Track > FindTrack(TrackPanelCell *pCell)
Definition: TrackPanel.cpp:525