Audacity 3.2.0
Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
CutlineHandle Class Referencefinal

#include <CutlineHandle.h>

Inheritance diagram for CutlineHandle:
[legend]
Collaboration diagram for CutlineHandle:
[legend]

Public Member Functions

 CutlineHandle (const std::shared_ptr< WaveTrack > &pTrack, WaveTrackLocations locations, WaveTrackLocation location)
 
CutlineHandleoperator= (const CutlineHandle &)=default
 
virtual ~CutlineHandle ()
 
std::shared_ptr< const TrackFindTrack () const override
 
const WaveTrackLocationGetLocation ()
 
std::shared_ptr< WaveTrackGetTrack ()
 
void Enter (bool forward, AudacityProject *) override
 
bool HandlesRightClick () override
 Whether the handle has any special right-button handling. More...
 
Result Click (const TrackPanelMouseEvent &event, AudacityProject *pProject) override
 
Result Drag (const TrackPanelMouseEvent &event, AudacityProject *pProject) override
 
HitTestPreview Preview (const TrackPanelMouseState &state, AudacityProject *pProject) override
 
Result Release (const TrackPanelMouseEvent &event, AudacityProject *pProject, wxWindow *pParent) override
 
Result Cancel (AudacityProject *pProject) override
 
bool StopsOnKeystroke () override
 
- Public Member Functions inherited from UIHandle
virtual ~UIHandle ()=0
 
virtual void Enter (bool forward, AudacityProject *pProject)
 
virtual bool HasRotation () const
 
virtual bool Rotate (bool forward)
 
virtual bool HasEscape (AudacityProject *pProject) const
 
virtual bool Escape (AudacityProject *pProject)
 
virtual bool HandlesRightClick ()
 Whether the handle has any special right-button handling. More...
 
virtual Result Click (const TrackPanelMouseEvent &event, AudacityProject *pProject)=0
 
virtual Result Drag (const TrackPanelMouseEvent &event, AudacityProject *pProject)=0
 
virtual HitTestPreview Preview (const TrackPanelMouseState &state, AudacityProject *pProject)=0
 
virtual Result Release (const TrackPanelMouseEvent &event, AudacityProject *pProject, wxWindow *pParent)=0
 
virtual Result Cancel (AudacityProject *pProject)=0
 
virtual bool StopsOnKeystroke ()
 
virtual void OnProjectChange (AudacityProject *pProject)
 
virtual std::shared_ptr< const TrackFindTrack () const =0
 
virtual bool IsDragging () const
 
Result GetChangeHighlight () const
 
void SetChangeHighlight (Result val)
 
- Public Member Functions inherited from TrackPanelDrawable
virtual ~TrackPanelDrawable ()=0
 
virtual void Draw (TrackPanelDrawingContext &context, const wxRect &rect, unsigned iPass)
 
virtual wxRect DrawingArea (TrackPanelDrawingContext &context, const wxRect &rect, const wxRect &panelRect, unsigned iPass)
 

Static Public Member Functions

static UIHandlePtr HitAnywhere (const AudacityProject *pProject, bool cutline, UIHandlePtr ptr)
 
static UIHandlePtr HitTest (std::weak_ptr< CutlineHandle > &holder, const wxMouseState &state, const wxRect &rect, const AudacityProject *pProject, std::shared_ptr< WaveTrack > pTrack)
 
- Static Public Member Functions inherited from UIHandle
static UIHandle::Result NeedChangeHighlight (const UIHandle &, const UIHandle &)
 
static std::shared_ptr< const TrackTrackFromChannel (const std::shared_ptr< const Channel > &pChannel)
 A frequent convenience in the definition of UIHandles. More...
 
- Static Public Member Functions inherited from TrackPanelDrawable
static wxRect MaximizeWidth (const wxRect &rect, const wxRect &panelRect)
 
static wxRect MaximizeHeight (const wxRect &rect, const wxRect &panelRect)
 

Private Types

enum  Operation { Expand , Remove }
 

Private Member Functions

 CutlineHandle (const CutlineHandle &)=delete
 

Static Private Member Functions

static HitTestPreview HitPreview (bool unsafe)
 

Private Attributes

std::shared_ptr< WaveTrackmpTrack {}
 
Operation mOperation { Expand }
 
double mStartTime {}
 
double mEndTime {}
 
WaveTrackLocations mLocations
 
WaveTrackLocation mLocation {}
 

Additional Inherited Members

- Public Types inherited from UIHandle
using Result = unsigned
 
using Cell = TrackPanelCell
 
- Protected Attributes inherited from UIHandle
Result mChangeHighlight { 0 }
 

Detailed Description

Definition at line 21 of file CutlineHandle.h.

Member Enumeration Documentation

◆ Operation

Enumerator
Expand 
Remove 

Definition at line 71 of file CutlineHandle.h.

Constructor & Destructor Documentation

◆ CutlineHandle() [1/2]

CutlineHandle::CutlineHandle ( const CutlineHandle )
privatedelete

◆ CutlineHandle() [2/2]

CutlineHandle::CutlineHandle ( const std::shared_ptr< WaveTrack > &  pTrack,
WaveTrackLocations  locations,
WaveTrackLocation  location 
)
explicit

Definition at line 29 of file CutlineHandle.cpp.

33 : mpTrack{ pTrack }
34 , mLocations{ move(locations) }
35 , mLocation{ location }
36{
37}
WaveTrackLocation mLocation
Definition: CutlineHandle.h:75
WaveTrackLocations mLocations
Definition: CutlineHandle.h:74
std::shared_ptr< WaveTrack > mpTrack
Definition: CutlineHandle.h:70

◆ ~CutlineHandle()

CutlineHandle::~CutlineHandle ( )
virtual

Definition at line 104 of file CutlineHandle.cpp.

105{
106}

Member Function Documentation

◆ Cancel()

UIHandle::Result CutlineHandle::Cancel ( AudacityProject pProject)
overridevirtual

Implements UIHandle.

Definition at line 203 of file CutlineHandle.cpp.

204{
205 using namespace RefreshCode;
207 ProjectHistory::Get( *pProject ).RollbackState();
208 if (mOperation == Expand) {
209 AudacityProject &project = *pProject;
210 auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
211 selectedRegion.setTimes( mStartTime, mEndTime );
212 }
213 return result;
214}
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
Operation mOperation
Definition: CutlineHandle.h:72
double mStartTime
Definition: CutlineHandle.h:73
bool setTimes(double t0, double t1)
Definition: ViewInfo.cpp:51
static ProjectHistory & Get(AudacityProject &project)
unsigned Result
Definition: UIHandle.h:40
NotifyingSelectedRegion selectedRegion
Definition: ViewInfo.h:216
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:235
Namespace containing an enum 'what to do on a refresh?'.
Definition: RefreshCode.h:16

References Expand, ProjectHistory::Get(), ViewInfo::Get(), mEndTime, mOperation, mStartTime, project, RefreshCode::RefreshCell, ProjectHistory::RollbackState(), ViewInfo::selectedRegion, and NotifyingSelectedRegion::setTimes().

Here is the call graph for this function:

◆ Click()

UIHandle::Result CutlineHandle::Click ( const TrackPanelMouseEvent event,
AudacityProject pProject 
)
overridevirtual

Someone has just clicked the mouse. What do we do?

Implements UIHandle.

Definition at line 118 of file CutlineHandle.cpp.

120{
121 using namespace RefreshCode;
122 const bool unsafe = ProjectAudioIO::Get( *pProject ).IsAudioActive();
123 if ( unsafe )
124 return Cancelled;
125
126 const wxMouseEvent &event = evt.event;
127 auto &viewInfo = ViewInfo::Get( *pProject );
128
129 // Can affect the track by merging clips, expanding a cutline, or
130 // deleting a cutline.
131 // All the change is done at button-down. Button-up just commits the undo item.
132
134
135 // FIXME: Disable this and return true when CutLines aren't showing?
136 // (Don't use gPrefs-> for the fix as registry access is slow).
137
138 // Cutline data changed on either branch, so refresh the track display.
140
141 if (event.LeftDown())
142 {
144 mStartTime = viewInfo.selectedRegion.t0();
145 mEndTime = viewInfo.selectedRegion.t1();
146
147 // When user presses left button on cut line, expand the line again
148 double cutlineStart = 0, cutlineEnd = 0;
150 mLocation.pos, &cutlineStart, &cutlineEnd);
151 viewInfo.selectedRegion.setTimes(cutlineStart, cutlineEnd);
152 }
153 else if (event.RightDown())
154 {
156 if (!removed)
157 // Nothing happened, make no Undo item
158 return Cancelled;
160 }
161 else
162 result = RefreshNone;
163
164 return result;
165}
bool IsAudioActive() const
static ProjectAudioIO & Get(AudacityProject &project)
WAVE_TRACK_API void ExpandCutLine(WaveTrack &track, double cutLinePosition, double *cutlineStart=nullptr, double *cutlineEnd=nullptr)
WAVE_TRACK_API bool RemoveCutLine(WaveTrack &track, double cutLinePosition)
Remove cut line, without expanding the audio in it.

References Cancelled, TrackPanelMouseEvent::event, Expand, WaveTrackUtilities::ExpandCutLine(), ProjectAudioIO::Get(), ViewInfo::Get(), ProjectAudioIO::IsAudioActive(), mEndTime, mLocation, mOperation, mpTrack, mStartTime, WaveTrackLocation::pos, RefreshCode::RefreshCell, RefreshCode::RefreshNone, Remove, and WaveTrackUtilities::RemoveCutLine().

Here is the call graph for this function:

◆ Drag()

UIHandle::Result CutlineHandle::Drag ( const TrackPanelMouseEvent event,
AudacityProject pProject 
)
overridevirtual

Implements UIHandle.

Definition at line 167 of file CutlineHandle.cpp.

169{
171}

References RefreshCode::RefreshNone.

◆ Enter()

void CutlineHandle::Enter ( bool  forward,
AudacityProject  
)
overridevirtual

Reimplemented from UIHandle.

Definition at line 39 of file CutlineHandle.cpp.

40{
41#ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING
43#endif
44}
Result mChangeHighlight
Definition: UIHandle.h:152

References UIHandle::mChangeHighlight, and RefreshCode::RefreshCell.

◆ FindTrack()

std::shared_ptr< const Track > CutlineHandle::FindTrack ( ) const
overridevirtual
Returns
pointer to associated track, if any

Implements UIHandle.

Definition at line 108 of file CutlineHandle.cpp.

109{
110 return mpTrack;
111}

References mpTrack.

◆ GetLocation()

const WaveTrackLocation & CutlineHandle::GetLocation ( )
inline

Definition at line 44 of file CutlineHandle.h.

44{ return mLocation; }

References mLocation.

◆ GetTrack()

std::shared_ptr< WaveTrack > CutlineHandle::GetTrack ( )
inline

Definition at line 45 of file CutlineHandle.h.

45{ return mpTrack; }

References mpTrack.

Referenced by WaveChannelSubView::DrawBoldBoundaries().

Here is the caller graph for this function:

◆ HandlesRightClick()

bool CutlineHandle::HandlesRightClick ( )
overridevirtual

Whether the handle has any special right-button handling.

If not, then Click() will not be called for right click. Default is always false

Reimplemented from UIHandle.

Definition at line 113 of file CutlineHandle.cpp.

114{
115 return true;
116}

◆ HitAnywhere()

static UIHandlePtr CutlineHandle::HitAnywhere ( const AudacityProject pProject,
bool  cutline,
UIHandlePtr  ptr 
)
static

◆ HitPreview()

HitTestPreview CutlineHandle::HitPreview ( bool  unsafe)
staticprivate

Definition at line 46 of file CutlineHandle.cpp.

47{
48 static auto disabledCursor =
49 ::MakeCursor(wxCURSOR_NO_ENTRY, DisabledCursorXpm, 16, 16);
50 static wxCursor arrowCursor{ wxCURSOR_ARROW };
51 return { XO("Left-Click to expand, Right-Click to remove"),
52 (unsafe ? &*disabledCursor : &arrowCursor) };
53}
XO("Cut/Copy/Paste")
std::unique_ptr< wxCursor > MakeCursor(int WXUNUSED(CursorId), const char *const pXpm[36], int HotX, int HotY)
Definition: TrackPanel.cpp:189

References MakeCursor(), and XO().

Referenced by Preview().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ HitTest()

UIHandlePtr CutlineHandle::HitTest ( std::weak_ptr< CutlineHandle > &  holder,
const wxMouseState &  state,
const wxRect &  rect,
const AudacityProject pProject,
std::shared_ptr< WaveTrack pTrack 
)
static

method that tells us if the mouse event landed on an editable Cutline

Definition at line 83 of file CutlineHandle.cpp.

88{
89 auto &viewInfo = ViewInfo::Get(*pProject);
92
93 auto locations = FindWaveTrackLocations(*pTrack);
94 WaveTrackLocation location;
95 if (!IsOverCutline(locations, viewInfo, rect, state, &location))
96 return {};
97
98 auto result =
99 std::make_shared<CutlineHandle>(pTrack, move(locations), location);
100 result = AssignUIHandlePtr(holder, result);
101 return result;
102}
std::shared_ptr< Subclass > AssignUIHandlePtr(std::weak_ptr< Subclass > &holder, const std::shared_ptr< Subclass > &pNew)
Definition: UIHandle.h:164
WaveTrackLocations FindWaveTrackLocations(const WaveTrack &track)
bool IsOverCutline(const WaveTrackLocations &locations, const ViewInfo &viewInfo, const wxRect &rect, const wxMouseState &state, WaveTrackLocation *pmLocation)

References AssignUIHandlePtr(), FindWaveTrackLocations(), ViewInfo::Get(), and anonymous_namespace{CutlineHandle.cpp}::IsOverCutline().

Referenced by WaveChannelSubView::DoDetailedHitTest().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=()

CutlineHandle & CutlineHandle::operator= ( const CutlineHandle )
default

◆ Preview()

HitTestPreview CutlineHandle::Preview ( const TrackPanelMouseState state,
AudacityProject pProject 
)
overridevirtual

Implements UIHandle.

Definition at line 173 of file CutlineHandle.cpp.

175{
176 const bool unsafe = ProjectAudioIO::Get( *pProject ).IsAudioActive();
177 return HitPreview( unsafe );
178}
static HitTestPreview HitPreview(bool unsafe)

References ProjectAudioIO::Get(), HitPreview(), and ProjectAudioIO::IsAudioActive().

Here is the call graph for this function:

◆ Release()

UIHandle::Result CutlineHandle::Release ( const TrackPanelMouseEvent event,
AudacityProject pProject,
wxWindow *  pParent 
)
overridevirtual

Implements UIHandle.

Definition at line 180 of file CutlineHandle.cpp.

182{
184
185 // Only now commit the result to the undo stack
186 switch (mOperation) {
187 default:
188 wxASSERT(false);
189 case Expand:
190 ProjectHistory::Get( *pProject )
191 .PushState(XO("Expanded Cut Line"), XO("Expand"));
192 break;
193 case Remove:
194 ProjectHistory::Get( *pProject )
195 .PushState(XO("Removed Cut Line"), XO("Remove"));
196 break;
197 }
198
199 // Nothing to do for the display
200 return result;
201}
void PushState(const TranslatableString &desc, const TranslatableString &shortDesc)

References Expand, ProjectHistory::Get(), mOperation, ProjectHistory::PushState(), RefreshCode::RefreshNone, Remove, and XO().

Here is the call graph for this function:

◆ StopsOnKeystroke()

bool CutlineHandle::StopsOnKeystroke ( )
inlineoverridevirtual

Reimplemented from UIHandle.

Definition at line 67 of file CutlineHandle.h.

67{ return true; }

Member Data Documentation

◆ mEndTime

double CutlineHandle::mEndTime {}
private

Definition at line 73 of file CutlineHandle.h.

Referenced by Cancel(), and Click().

◆ mLocation

WaveTrackLocation CutlineHandle::mLocation {}
private

Definition at line 75 of file CutlineHandle.h.

Referenced by Click(), and GetLocation().

◆ mLocations

WaveTrackLocations CutlineHandle::mLocations
private

Definition at line 74 of file CutlineHandle.h.

◆ mOperation

Operation CutlineHandle::mOperation { Expand }
private

Definition at line 72 of file CutlineHandle.h.

Referenced by Cancel(), Click(), and Release().

◆ mpTrack

std::shared_ptr<WaveTrack> CutlineHandle::mpTrack {}
private

Definition at line 70 of file CutlineHandle.h.

Referenced by Click(), FindTrack(), and GetTrack().

◆ mStartTime

double CutlineHandle::mStartTime {}
private

Definition at line 73 of file CutlineHandle.h.

Referenced by Cancel(), and Click().


The documentation for this class was generated from the following files: