Audacity 3.2.0
WaveClipTrimHandle.h
Go to the documentation of this file.
1/*!********************************************************************
2*
3 Audacity: A Digital Audio Editor
4
5 WaveClipTrimHandle.h
6
7 Vitaly Sverchinsky
8
9 **********************************************************************/
10
11#pragma once
12
13#include "UIHandle.h"
14#include "WaveClip.h"
15
16class WaveTrackView;
17class WaveTrack;
18
20{
21 static constexpr int BoundaryThreshold = 5;
22
23 static HitTestPreview HitPreview(const AudacityProject*, bool unsafe);
24
25 //Different policies implement different trimming scenarios
27 {
28 public:
29 virtual ~ClipTrimPolicy();
30
31 virtual bool Init(const TrackPanelMouseEvent& event) = 0;
32 virtual UIHandle::Result Trim(const TrackPanelMouseEvent& event, AudacityProject& project) = 0;
33 virtual void Finish(AudacityProject& project) = 0;
34 virtual void Cancel() = 0;
35
36 virtual void Draw(
38 const wxRect &rect,
39 unsigned iPass);
40
41 virtual wxRect DrawingArea(
43 const wxRect &rect,
44 const wxRect &panelRect,
45 unsigned iPass);
46 };
47 class AdjustBorder;
49
50 std::unique_ptr<ClipTrimPolicy> mClipTrimPolicy{};
51
52public:
53 WaveClipTrimHandle(std::unique_ptr<ClipTrimPolicy>& clipTrimPolicy);
54
55 static UIHandlePtr HitAnywhere(std::weak_ptr<WaveClipTrimHandle>& holder,
56 const std::shared_ptr<WaveTrack>& waveTrack,
57 const AudacityProject* pProject,
58 const TrackPanelMouseState& state);
59
60 static UIHandlePtr HitTest(std::weak_ptr<WaveClipTrimHandle>& holder,
61 WaveTrackView& view, const AudacityProject* pProject,
62 const TrackPanelMouseState& state);
63
64 HitTestPreview Preview(const TrackPanelMouseState& mouseState, AudacityProject* pProject) override;
65
67 (const TrackPanelMouseEvent& event, AudacityProject* pProject) override;
68
70 (const TrackPanelMouseEvent& event, AudacityProject* pProject) override;
71
73 (const TrackPanelMouseEvent& event, AudacityProject* pProject,
74 wxWindow* pParent) override;
75
76 Result Cancel(AudacityProject* pProject) override;
77
78 // TrackPanelDrawable implementation
79
80 void Draw(TrackPanelDrawingContext &context,
81 const wxRect &rect,
82 unsigned iPass ) override;
83
85 const wxRect &rect,
86 const wxRect &panelRect,
87 unsigned iPass) override;
88};
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
Short-lived drawing and event-handling object associated with a TrackPanelCell.
Definition: UIHandle.h:35
unsigned Result
Definition: UIHandle.h:38
virtual wxRect DrawingArea(TrackPanelDrawingContext &, const wxRect &rect, const wxRect &panelRect, unsigned iPass)
virtual void Finish(AudacityProject &project)=0
virtual void Draw(TrackPanelDrawingContext &context, const wxRect &rect, unsigned iPass)
virtual bool Init(const TrackPanelMouseEvent &event)=0
virtual UIHandle::Result Trim(const TrackPanelMouseEvent &event, AudacityProject &project)=0
Result Release(const TrackPanelMouseEvent &event, AudacityProject *pProject, wxWindow *pParent) override
Result Cancel(AudacityProject *pProject) override
static HitTestPreview HitPreview(const AudacityProject *, bool unsafe)
Result Drag(const TrackPanelMouseEvent &event, AudacityProject *pProject) override
WaveClipTrimHandle(std::unique_ptr< ClipTrimPolicy > &clipTrimPolicy)
Result Click(const TrackPanelMouseEvent &event, AudacityProject *pProject) override
HitTestPreview Preview(const TrackPanelMouseState &mouseState, AudacityProject *pProject) override
wxRect DrawingArea(TrackPanelDrawingContext &, const wxRect &rect, const wxRect &panelRect, unsigned iPass) override
std::unique_ptr< ClipTrimPolicy > mClipTrimPolicy
static UIHandlePtr HitTest(std::weak_ptr< WaveClipTrimHandle > &holder, WaveTrackView &view, const AudacityProject *pProject, const TrackPanelMouseState &state)
static UIHandlePtr HitAnywhere(std::weak_ptr< WaveClipTrimHandle > &holder, const std::shared_ptr< WaveTrack > &waveTrack, const AudacityProject *pProject, const TrackPanelMouseState &state)
static constexpr int BoundaryThreshold
void Draw(TrackPanelDrawingContext &context, const wxRect &rect, unsigned iPass) override
A Track that contains audio waveform data.
Definition: WaveTrack.h:57