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 ChannelFindChannel () 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 ChannelFindChannel () 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 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 28 of file CutlineHandle.cpp.

32 : mpTrack{ pTrack }
33 , mLocations{ move(locations) }
34 , mLocation{ location }
35{
36}
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 111 of file CutlineHandle.cpp.

112{
113}

Member Function Documentation

◆ Cancel()

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

Implements UIHandle.

Definition at line 209 of file CutlineHandle.cpp.

210{
211 using namespace RefreshCode;
213 ProjectHistory::Get( *pProject ).RollbackState();
214 if (mOperation == Expand) {
215 AudacityProject &project = *pProject;
216 auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
217 selectedRegion.setTimes( mStartTime, mEndTime );
218 }
219 return result;
220}
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:39
NotifyingSelectedRegion selectedRegion
Definition: ViewInfo.h:215
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 125 of file CutlineHandle.cpp.

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

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

Here is the call graph for this function:

◆ Drag()

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

Implements UIHandle.

Definition at line 173 of file CutlineHandle.cpp.

175{
177}

References RefreshCode::RefreshNone.

◆ Enter()

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

Reimplemented from UIHandle.

Definition at line 38 of file CutlineHandle.cpp.

39{
40#ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING
42#endif
43}
Result mChangeHighlight
Definition: UIHandle.h:147

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

◆ FindChannel()

std::shared_ptr< const Channel > CutlineHandle::FindChannel ( ) const
overridevirtual
Returns
pointer to associated channel, if any

Implements UIHandle.

Definition at line 115 of file CutlineHandle.cpp.

116{
117 return mpTrack;
118}

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 120 of file CutlineHandle.cpp.

121{
122 return true;
123}

◆ HitAnywhere()

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

◆ HitPreview()

HitTestPreview CutlineHandle::HitPreview ( bool  unsafe)
staticprivate

Definition at line 45 of file CutlineHandle.cpp.

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

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 82 of file CutlineHandle.cpp.

87{
88 // Substitute the leader
89 if (!pTrack->GetOwner())
90 return {};
91 auto iter = pTrack->GetOwner()->Find(pTrack.get());
92 if (!*iter)
93 return {};
94 pTrack = (*iter)->SharedPointer<WaveTrack>();
95
96 auto &viewInfo = ViewInfo::Get(*pProject);
99
100 auto locations = FindWaveTrackLocations(*pTrack);
101 WaveTrackLocation location;
102 if (!IsOverCutline(locations, viewInfo, rect, state, &location))
103 return {};
104
105 auto result =
106 std::make_shared<CutlineHandle>(pTrack, move(locations), location);
107 result = AssignUIHandlePtr(holder, result);
108 return result;
109}
std::shared_ptr< Subclass > AssignUIHandlePtr(std::weak_ptr< Subclass > &holder, const std::shared_ptr< Subclass > &pNew)
Definition: UIHandle.h:159
WaveTrackLocations FindWaveTrackLocations(const WaveTrack &track)
A Track that contains audio waveform data.
Definition: WaveTrack.h:227
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 179 of file CutlineHandle.cpp.

181{
182 const bool unsafe = ProjectAudioIO::Get( *pProject ).IsAudioActive();
183 return HitPreview( unsafe );
184}
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 186 of file CutlineHandle.cpp.

188{
190
191 // Only now commit the result to the undo stack
192 switch (mOperation) {
193 default:
194 wxASSERT(false);
195 case Expand:
196 ProjectHistory::Get( *pProject )
197 .PushState(XO("Expanded Cut Line"), XO("Expand"));
198 break;
199 case Remove:
200 ProjectHistory::Get( *pProject )
201 .PushState(XO("Removed Cut Line"), XO("Remove"));
202 break;
203 }
204
205 // Nothing to do for the display
206 return result;
207}
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(), FindChannel(), 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: