Audacity 3.2.0
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
WaveTrackAffordanceControls Class Reference

#include <WaveTrackAffordanceControls.h>

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

Public Member Functions

 WaveTrackAffordanceControls (const std::shared_ptr< Track > &pTrack)
 
std::vector< UIHandlePtrHitTest (const TrackPanelMouseState &state, const AudacityProject *pProject) override
 
void Draw (TrackPanelDrawingContext &context, const wxRect &rect, unsigned iPass) override
 
IntervalIterator GetSelectedInterval () const
 
unsigned CaptureKey (wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent, AudacityProject *project) override
 
unsigned KeyDown (wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent, AudacityProject *project) override
 
unsigned Char (wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent, AudacityProject *project) override
 
unsigned LoseFocus (AudacityProject *project) override
 
void OnTextEditFinished (AudacityProject *project, const wxString &text) override
 
void OnTextEditCancelled (AudacityProject *project) override
 
void OnTextModified (AudacityProject *project, const wxString &text) override
 
void OnTextContextMenu (AudacityProject *project, const wxPoint &position) override
 
unsigned OnAffordanceClick (const TrackPanelMouseEvent &event, AudacityProject *project)
 
bool OnTextCopy (AudacityProject &project)
 
bool OnTextCut (AudacityProject &project)
 
bool OnTextPaste (AudacityProject &project)
 
bool OnTextSelect (AudacityProject &project)
 
void StartEditSelectedClipName (AudacityProject &project)
 
void StartEditSelectedClipSpeed (AudacityProject &project)
 
void OnRenderClipStretching (AudacityProject &project) const
 
std::vector< MenuItemGetMenuItems (const wxRect &rect, const wxPoint *pPosition, AudacityProject *pProject) override
 Return a list of items for DoContextMenu() (empties for separators) More...
 
- Public Member Functions inherited from CommonTrackCell
 CommonTrackCell (const std::shared_ptr< Track > &pTrack, size_t iChannel)
 Construct from a track and a channel index. More...
 
 CommonTrackCell (ChannelGroup &group, size_t iChannel)
 Construct from a channel group and a channel index. More...
 
 ~CommonTrackCell ()
 
std::shared_ptr< TrackDoFindTrack () override
 
void Reparent (const std::shared_ptr< Track > &parent) override
 Object may be shared among tracks but hold a special back-pointer to one of them; reassign it. More...
 
size_t GetChannelIndex () const
 
std::shared_ptr< ChannelFindChannel ()
 May return null. More...
 
std::shared_ptr< const ChannelFindChannel () const
 May return null. More...
 
- Public Member Functions inherited from CommonTrackPanelCell
 CommonTrackPanelCell ()
 
virtual ~CommonTrackPanelCell ()=0
 
HitTestPreview DefaultPreview (const TrackPanelMouseState &, const AudacityProject *) override
 
std::shared_ptr< TrackFindTrack ()
 
std::shared_ptr< const TrackFindTrack () const
 
virtual std::vector< MenuItemGetMenuItems (const wxRect &rect, const wxPoint *pPosition, AudacityProject *pProject)
 Return a list of items for DoContextMenu() (empties for separators) More...
 
- Public Member Functions inherited from TrackPanelCell
 TrackPanelCell ()=default
 
 TrackPanelCell (const TrackPanelCell &)=delete
 
TrackPanelCelloperator= (const TrackPanelCell &)=delete
 
virtual ~TrackPanelCell ()=0
 
virtual HitTestPreview DefaultPreview (const TrackPanelMouseState &state, const AudacityProject *pProject)
 
virtual std::vector< UIHandlePtrHitTest (const TrackPanelMouseState &state, const AudacityProject *pProject)=0
 
virtual unsigned HandleWheelRotation (const TrackPanelMouseEvent &event, AudacityProject *pProject)
 
virtual std::shared_ptr< TrackPanelCellContextMenuDelegate ()
 
virtual unsigned DoContextMenu (const wxRect &rect, wxWindow *pParent, const wxPoint *pPosition, AudacityProject *pProject)
 
virtual unsigned CaptureKey (wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent, AudacityProject *project)
 
virtual unsigned KeyDown (wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent, AudacityProject *project)
 
virtual unsigned KeyUp (wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent, AudacityProject *project)
 
virtual unsigned Char (wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent, AudacityProject *project)
 
virtual unsigned LoseFocus (AudacityProject *project)
 
- Public Member Functions inherited from TrackPanelNode
 TrackPanelNode ()
 
virtual ~TrackPanelNode ()=0
 
- 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)
 
- Public Member Functions inherited from TrackAttachment
virtual ~TrackAttachment ()
 
virtual void CopyTo (Track &track) const
 Copy state, for undo/redo purposes. More...
 
virtual void Reparent (const std::shared_ptr< Track > &parent)
 Object may be shared among tracks but hold a special back-pointer to one of them; reassign it. More...
 
virtual void WriteXMLAttributes (XMLWriter &) const
 Serialize persistent attributes. More...
 
virtual bool HandleXMLAttribute (const std::string_view &attr, const XMLAttributeValueView &valueView)
 Deserialize an attribute, returning true if recognized. More...
 
- Public Member Functions inherited from ClientData::Base
virtual ~Base ()
 
- Public Member Functions inherited from TextEditDelegate
virtual ~TextEditDelegate ()
 
virtual void OnTextEditFinished (AudacityProject *project, const wxString &text)=0
 
virtual void OnTextEditCancelled (AudacityProject *project)=0
 
virtual void OnTextModified (AudacityProject *project, const wxString &text)=0
 
virtual void OnTextContextMenu (AudacityProject *project, const wxPoint &position)=0
 

Private Types

using IntervalIterator = ChannelGroup::IntervalIterator< WaveTrack::Interval >
 

Private Member Functions

bool IsIntervalVisible (const IntervalIterator &it) const noexcept
 
bool StartEditClipName (AudacityProject &project, IntervalIterator it)
 Starts in-place clip name editing or shows a Clip Name Edit dialog, depending on prefs. More...
 
void ResetClipNameEdit ()
 
void OnTrackListEvent (const TrackListEvent &evt)
 
void OnSelectionChange (NotifyingSelectedRegionMessage)
 
unsigned ExitTextEditing ()
 
std::shared_ptr< TextEditHelperMakeTextEditHelper (const wxString &text)
 

Private Attributes

IntervalIterator mFocusInterval
 
std::weak_ptr< ClipOverflowButtonHandlemOverflowButtonHandle
 
std::weak_ptr< ClipPitchAndSpeedButtonHandlemPitchButtonHandle
 
std::weak_ptr< ClipPitchAndSpeedButtonHandlemSpeedButtonHandle
 
std::weak_ptr< WaveTrackAffordanceHandlemAffordanceHandle
 
std::weak_ptr< TrackPanelResizeHandlemResizeHandle
 
std::weak_ptr< WaveClipTitleEditHandlemTitleEditHandle
 
std::weak_ptr< SelectHandlemSelectHandle
 
std::weak_ptr< WaveClipAdjustBorderHandlemClipBorderAdjustHandle
 
IntervalIterator mEditedInterval
 
std::shared_ptr< TextEditHelpermTextEditHelper
 
wxFont mClipNameFont
 
std::vector< IntervalIteratormVisibleIntervals
 
Observer::Subscription mTrackListEventSubscription
 
Observer::Subscription mSelectionChangeSubscription
 

Additional Inherited Members

- 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)
 
- Protected Member Functions inherited from CommonTrackPanelCell
virtual std::shared_ptr< TrackDoFindTrack ()=0
 
unsigned DoContextMenu (const wxRect &rect, wxWindow *pParent, const wxPoint *pPosition, AudacityProject *pProject) override
 
unsigned HandleWheelRotation (const TrackPanelMouseEvent &event, AudacityProject *pProject) override
 

Detailed Description

Definition at line 38 of file WaveTrackAffordanceControls.h.

Member Typedef Documentation

◆ IntervalIterator

Definition at line 43 of file WaveTrackAffordanceControls.h.

Constructor & Destructor Documentation

◆ WaveTrackAffordanceControls()

WaveTrackAffordanceControls::WaveTrackAffordanceControls ( const std::shared_ptr< Track > &  pTrack)

Definition at line 152 of file WaveTrackAffordanceControls.cpp.

153 : CommonTrackCell{ pTrack, 0 }
154 , mClipNameFont{ wxFontInfo{} }
155{
156 if (auto trackList = pTrack->GetOwner())
157 {
158 mTrackListEventSubscription = trackList->Subscribe(
160 if(auto project = trackList->GetOwner())
161 {
162 auto& viewInfo = ViewInfo::Get(*project);
164 viewInfo.selectedRegion.Subscribe(
165 *this,
167 }
168 }
169}
const auto project
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:235
void OnTrackListEvent(const TrackListEvent &evt)
void OnSelectionChange(NotifyingSelectedRegionMessage)
Observer::Subscription mSelectionChangeSubscription
Observer::Subscription mTrackListEventSubscription

References ViewInfo::Get(), mSelectionChangeSubscription, mTrackListEventSubscription, OnSelectionChange(), OnTrackListEvent(), and project.

Here is the call graph for this function:

Member Function Documentation

◆ CaptureKey()

unsigned WaveTrackAffordanceControls::CaptureKey ( wxKeyEvent &  event,
ViewInfo viewInfo,
wxWindow *  pParent,
AudacityProject project 
)
overridevirtual

Reimplemented from TrackPanelCell.

Definition at line 464 of file WaveTrackAffordanceControls.cpp.

465{
466 if (!mTextEditHelper
467 || !mTextEditHelper->CaptureKey(event.GetKeyCode(), event.GetModifiers()))
468 // Handle the event if it can be processed by the text editor (if any)
469 event.Skip();
471}
std::shared_ptr< TextEditHelper > mTextEditHelper

References mTextEditHelper, and RefreshCode::RefreshNone.

◆ Char()

unsigned WaveTrackAffordanceControls::Char ( wxKeyEvent &  event,
ViewInfo viewInfo,
wxWindow *  pParent,
AudacityProject project 
)
overridevirtual

Reimplemented from TrackPanelCell.

Definition at line 489 of file WaveTrackAffordanceControls.cpp.

490{
491 if (mTextEditHelper && mTextEditHelper->OnChar(event.GetUnicodeKey(), project))
494}

References mTextEditHelper, project, RefreshCode::RefreshCell, and RefreshCode::RefreshNone.

◆ Draw()

void WaveTrackAffordanceControls::Draw ( TrackPanelDrawingContext context,
const wxRect &  rect,
unsigned  iPass 
)
overridevirtual

Reimplemented from TrackPanelDrawable.

Definition at line 271 of file WaveTrackAffordanceControls.cpp.

272{
273 if (iPass == TrackArtist::PassBackground) {
274 auto track = FindTrack();
275 const auto artist = TrackArtist::Get(context);
276
277 TrackArt::DrawBackgroundWithSelection(context, rect, track.get(), artist->blankSelectedBrush, artist->blankBrush);
278
279 mVisibleIntervals.clear();
280
281 const auto waveTrack = std::static_pointer_cast<WaveTrack>(track->SubstitutePendingChangedTrack());
282 const auto& zoomInfo = *artist->pZoomInfo;
283 {
284 wxDCClipper dcClipper(context.dc, rect);
285
286 context.dc.SetTextBackground(wxTransparentColor);
287 context.dc.SetTextForeground(theTheme.Colour(clrClipNameText));
288 context.dc.SetFont(mClipNameFont);
289
290 auto px = context.lastState.m_x;
291 auto py = context.lastState.m_y;
292
293 const auto overflowHandle = mOverflowButtonHandle.lock();
294 const auto intervals = waveTrack->Intervals();
295 for(auto it = intervals.begin(); it != intervals.end(); ++it)
296 {
297 auto interval = *it;
298 const auto& clip = *interval->GetClip(0);
299 const auto clipRect = ClipParameters::GetClipRect(
300 clip, zoomInfo, rect);
301
302 if(!WaveChannelView::ClipDetailsVisible(clip, zoomInfo, rect))
303 {
304 TrackArt::DrawClipFolded(context.dc, clipRect);
305 continue;
306 }
307
308 const auto selected = GetSelectedInterval() == it;
309 const auto highlightAffordance =
310 !overflowHandle && (selected || clipRect.Contains(px, py));
311 auto affordanceRect = TrackArt::DrawClipAffordance(
312 context.dc, clipRect, highlightAffordance, selected);
313
314 if (
315 const auto overflowButtonRect =
316 LowlitClipButton::DrawOnClip<ClipButtonId::Overflow>(
317 { clip, zoomInfo, rect }, context.dc))
318 affordanceRect.width -= overflowButtonRect->width;
319 if (
320 const auto speedButtonRect =
321 LowlitClipButton::DrawOnClip<ClipButtonId::Speed>(
322 { clip, zoomInfo, rect }, context.dc))
323 affordanceRect.width -= speedButtonRect->width;
324 if (
325 const auto pitchButtonRect =
326 LowlitClipButton::DrawOnClip<ClipButtonId::Pitch>(
327 { clip, zoomInfo, rect }, context.dc))
328 affordanceRect.width -= pitchButtonRect->width;
329
330 if (mTextEditHelper && mEditedInterval == it)
331 {
332 if (!mTextEditHelper->Draw(context.dc, affordanceRect))
333 {
334 mTextEditHelper->Cancel(nullptr);
336 context.dc, affordanceRect, interval->GetName());
337 }
338 }
340 context.dc, affordanceRect, interval->GetName()))
341 mVisibleIntervals.push_back(it);
342 }
343 }
344
345 }
346}
THEME_API Theme theTheme
Definition: Theme.cpp:82
std::shared_ptr< Track > FindTrack()
wxColour & Colour(int iIndex)
static TrackArtist * Get(TrackPanelDrawingContext &)
Definition: TrackArtist.cpp:69
static bool ClipDetailsVisible(const ClipTimes &clip, const ZoomInfo &zoomInfo, const wxRect &viewRect)
std::vector< IntervalIterator > mVisibleIntervals
std::weak_ptr< ClipOverflowButtonHandle > mOverflowButtonHandle
IntervalIterator GetSelectedInterval() const
AUDACITY_DLL_API bool DrawClipTitle(wxDC &dc, const wxRect &affordanceRect, const wxString &title)
Definition: TrackArt.cpp:289
AUDACITY_DLL_API void DrawClipFolded(wxDC &dc, const wxRect &rect)
Definition: TrackArt.cpp:346
AUDACITY_DLL_API void DrawBackgroundWithSelection(TrackPanelDrawingContext &context, const wxRect &rect, const Track *track, const wxBrush &selBrush, const wxBrush &unselBrush, bool useSelection=true)
Definition: TrackArt.cpp:651
AUDACITY_DLL_API wxRect DrawClipAffordance(wxDC &dc, const wxRect &clipRect, bool highlight=false, bool selected=false)
Definition: TrackArt.cpp:223
static wxRect GetClipRect(const ClipTimes &clip, const ZoomInfo &zoomInfo, const wxRect &viewRect, bool *outShowSamples=nullptr)

References WaveChannelView::ClipDetailsVisible(), ThemeBase::Colour(), TrackPanelDrawingContext::dc, TrackArt::DrawBackgroundWithSelection(), TrackArt::DrawClipAffordance(), TrackArt::DrawClipFolded(), TrackArt::DrawClipTitle(), CommonTrackPanelCell::FindTrack(), TrackArtist::Get(), ClipParameters::GetClipRect(), GetSelectedInterval(), TrackPanelDrawingContext::lastState, mClipNameFont, mEditedInterval, mOverflowButtonHandle, mTextEditHelper, mVisibleIntervals, TrackArtist::PassBackground, and theTheme.

Here is the call graph for this function:

◆ ExitTextEditing()

unsigned WaveTrackAffordanceControls::ExitTextEditing ( )
private

Definition at line 546 of file WaveTrackAffordanceControls.cpp.

547{
548 using namespace RefreshCode;
549 if (mTextEditHelper)
550 {
551 if (auto trackList = FindTrack()->GetOwner())
552 {
553 mTextEditHelper->Finish(trackList->GetOwner());
554 }
556 return RefreshCell;
557 }
558 return RefreshNone;
559}
Namespace containing an enum 'what to do on a refresh?'.
Definition: RefreshCode.h:16

References CommonTrackPanelCell::FindTrack(), mTextEditHelper, RefreshCode::RefreshCell, RefreshCode::RefreshNone, and ResetClipNameEdit().

Referenced by LoseFocus(), OnAffordanceClick(), OnSelectionChange(), and OnTrackListEvent().

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

◆ GetMenuItems()

auto WaveTrackAffordanceControls::GetMenuItems ( const wxRect &  rect,
const wxPoint *  pPosition,
AudacityProject pProject 
)
overridevirtual

Return a list of items for DoContextMenu() (empties for separators)

If the vector is empty (as in the default), there is no context menu.

Commands are invoked with temporary selection fields of CommandContext set to a point selected region at the mouse pick, and the cell's track.

A function may be given, but if it is null, then the command can be found by name in the CommandManager.

An item in the list with no command name marks a menu separator.

The menu item is enabled only if it contains a true flag, but if looked up in the command manager, it must also satisfy the command manager's conditions.

Reimplemented from CommonTrackPanelCell.

Definition at line 698 of file WaveTrackAffordanceControls.cpp.

701{
702 return GetWaveClipMenuItems();
703}
std::vector< CommonTrackPanelCell::MenuItem > GetWaveClipMenuItems()

References GetWaveClipMenuItems().

Here is the call graph for this function:

◆ GetSelectedInterval()

auto WaveTrackAffordanceControls::GetSelectedInterval ( ) const

Definition at line 392 of file WaveTrackAffordanceControls.cpp.

393{
394 if (auto handle = mAffordanceHandle.lock())
395 {
396 return handle->Clicked() ? mFocusInterval : IntervalIterator{};
397 }
398 return {};
399}
ChannelGroup::IntervalIterator< WaveTrack::Interval > IntervalIterator
std::weak_ptr< WaveTrackAffordanceHandle > mAffordanceHandle

References mAffordanceHandle, and mFocusInterval.

Referenced by Draw().

Here is the caller graph for this function:

◆ HitTest()

std::vector< UIHandlePtr > WaveTrackAffordanceControls::HitTest ( const TrackPanelMouseState state,
const AudacityProject pProject 
)
overridevirtual

Implements TrackPanelCell.

Definition at line 171 of file WaveTrackAffordanceControls.cpp.

172{
173 std::vector<UIHandlePtr> results;
174
175 const auto px = state.state.m_x;
176 const auto py = state.state.m_y;
177 const wxPoint mousePoint { px, py };
178
179 const auto rect = state.rect;
180
181 auto track = std::static_pointer_cast<WaveTrack>(FindTrack());
182 // Assume only leader channels have affordance areas
183 assert(track->IsLeader());
184
185 {
188 track,
189 pProject,
190 state);
191
192 if (handle)
193 results.push_back(handle);
194 }
195
196 if (mTextEditHelper && mTextEditHelper->GetBBox().Contains(px, py))
197 {
198 results.push_back(
201 std::make_shared<WaveClipTitleEditHandle>(
202 mTextEditHelper, track)
203 )
204 );
205 }
206
207 const auto waveTrack = std::static_pointer_cast<WaveTrack>(track->SubstitutePendingChangedTrack());
208 auto& zoomInfo = ViewInfo::Get(*pProject);
209 const auto intervals = waveTrack->Intervals();
210 for(auto it = intervals.begin(); it != intervals.end(); ++it)
211 {
212 if (it == mEditedInterval)
213 continue;
214
215 const auto clip = (*it)->GetClip(0);
216 if (LowlitClipButton::HitTest<ClipButtonId::Overflow>(
217 { *clip, zoomInfo, rect }, mousePoint))
218 {
219 results.push_back(AssignUIHandlePtr(
220 mOverflowButtonHandle, std::make_shared<ClipOverflowButtonHandle>(
221 track, *it, weak_from_this())));
222 mFocusInterval = it;
223 break;
224 }
225 else if (LowlitClipButton::HitTest<ClipButtonId::Pitch>(
226 { *clip, zoomInfo, rect }, mousePoint))
227 {
228 results.push_back(AssignUIHandlePtr(
230 std::make_shared<ClipPitchAndSpeedButtonHandle>(
232 mFocusInterval = it;
233 break;
234 }
235 else if (LowlitClipButton::HitTest<ClipButtonId::Speed>(
236 { *clip, zoomInfo, rect }, mousePoint))
237 {
238 results.push_back(AssignUIHandlePtr(
240 std::make_shared<ClipPitchAndSpeedButtonHandle>(
242 mFocusInterval = it;
243 break;
244 }
246 *clip, zoomInfo, state.rect, mousePoint))
247 {
248 results.push_back(AssignUIHandlePtr(
250 std::make_shared<WaveTrackAffordanceHandle>(track, clip)));
251 mFocusInterval = it;
252 break;
253 }
254 }
255
256 const auto& settings = ProjectSettings::Get(*pProject);
257 const auto currentTool = settings.GetTool();
258 if (currentTool == ToolCodes::multiTool || currentTool == ToolCodes::selectTool)
259 {
260 results.push_back(
262 mSelectHandle, state, pProject,
263 ChannelView::Get(*track).shared_from_this()
264 )
265 );
266 }
267
268 return results;
269}
static Settings & settings()
Definition: TrackInfo.cpp:69
std::shared_ptr< Subclass > AssignUIHandlePtr(std::weak_ptr< Subclass > &holder, const std::shared_ptr< Subclass > &pNew)
Definition: UIHandle.h:159
static ChannelView & Get(Channel &channel)
static ProjectSettings & Get(AudacityProject &project)
static UIHandlePtr HitTest(std::weak_ptr< SelectHandle > &holder, const TrackPanelMouseState &state, const AudacityProject *pProject, const std::shared_ptr< ChannelView > &pChannelView)
static bool HitTest(const WaveClip &clip, const ZoomInfo &zoomInfo, const wxRect &rect, const wxPoint &pos)
static UIHandlePtr HitAnywhere(std::weak_ptr< WaveClipAdjustBorderHandle > &holder, const std::shared_ptr< WaveTrack > &waveTrack, const AudacityProject *pProject, const TrackPanelMouseState &state)
std::weak_ptr< ClipPitchAndSpeedButtonHandle > mPitchButtonHandle
std::weak_ptr< WaveClipAdjustBorderHandle > mClipBorderAdjustHandle
std::weak_ptr< ClipPitchAndSpeedButtonHandle > mSpeedButtonHandle
std::weak_ptr< SelectHandle > mSelectHandle
std::weak_ptr< WaveClipTitleEditHandle > mTitleEditHandle

References AssignUIHandlePtr(), CommonTrackPanelCell::FindTrack(), ViewInfo::Get(), ProjectSettings::Get(), ChannelView::Get(), WaveClipAdjustBorderHandle::HitAnywhere(), WaveChannelView::HitTest(), SelectHandle::HitTest(), mAffordanceHandle, mClipBorderAdjustHandle, mEditedInterval, mFocusInterval, mOverflowButtonHandle, mPitchButtonHandle, mSelectHandle, mSpeedButtonHandle, mTextEditHelper, mTitleEditHandle, ToolCodes::multiTool, ClipPitchAndSpeedButtonHandle::Pitch, TrackPanelMouseState::rect, ToolCodes::selectTool, settings(), ClipPitchAndSpeedButtonHandle::Speed, and TrackPanelMouseState::state.

Here is the call graph for this function:

◆ IsIntervalVisible()

bool WaveTrackAffordanceControls::IsIntervalVisible ( const IntervalIterator it) const
privatenoexcept

Definition at line 348 of file WaveTrackAffordanceControls.cpp.

349{
350 return std::find(mVisibleIntervals.begin(),
351 mVisibleIntervals.end(),
352 it) != mVisibleIntervals.end();
353}

Referenced by StartEditClipName().

Here is the caller graph for this function:

◆ KeyDown()

unsigned WaveTrackAffordanceControls::KeyDown ( wxKeyEvent &  event,
ViewInfo viewInfo,
wxWindow *  pParent,
AudacityProject project 
)
overridevirtual

Reimplemented from TrackPanelCell.

Definition at line 474 of file WaveTrackAffordanceControls.cpp.

475{
476 auto keyCode = event.GetKeyCode();
477
478 if (mTextEditHelper)
479 {
480 if (!mTextEditHelper->OnKeyDown(keyCode, event.GetModifiers(), project)
482 event.Skip();
483
485 }
487}
static bool IsGoodEditKeyCode(int keyCode)

References TextEditHelper::IsGoodEditKeyCode(), mTextEditHelper, project, RefreshCode::RefreshCell, and RefreshCode::RefreshNone.

Here is the call graph for this function:

◆ LoseFocus()

unsigned WaveTrackAffordanceControls::LoseFocus ( AudacityProject project)
overridevirtual

Reimplemented from TrackPanelCell.

Definition at line 496 of file WaveTrackAffordanceControls.cpp.

497{
498 return ExitTextEditing();
499}

References ExitTextEditing().

Here is the call graph for this function:

◆ MakeTextEditHelper()

std::shared_ptr< TextEditHelper > WaveTrackAffordanceControls::MakeTextEditHelper ( const wxString &  text)
private

Definition at line 690 of file WaveTrackAffordanceControls.cpp.

691{
692 auto helper = std::make_shared<TextEditHelper>(shared_from_this(), text, mClipNameFont);
693 helper->SetTextColor(theTheme.Colour(clrClipNameText));
694 helper->SetTextSelectionColor(theTheme.Colour(clrClipNameTextSelection));
695 return helper;
696}

References ThemeBase::Colour(), mClipNameFont, and theTheme.

Referenced by StartEditClipName().

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

◆ OnAffordanceClick()

unsigned WaveTrackAffordanceControls::OnAffordanceClick ( const TrackPanelMouseEvent event,
AudacityProject project 
)

Definition at line 601 of file WaveTrackAffordanceControls.cpp.

602{
603 auto& viewInfo = ViewInfo::Get(*project);
604 if (mTextEditHelper)
605 {
606 if (auto interval = *mEditedInterval)
607 {
608 auto affordanceRect = ClipParameters::GetClipRect(*interval->GetClip(0), viewInfo, event.rect);
609 if (!affordanceRect.Contains(event.event.GetPosition()))
610 return ExitTextEditing();
611 }
612 }
613 else if (auto interval = *mFocusInterval)
614 {
615 if (event.event.LeftDClick())
616 {
617 auto affordanceRect = ClipParameters::GetClipRect(*interval->GetClip(0), viewInfo, event.rect);
618 if (affordanceRect.Contains(event.event.GetPosition()) &&
620 {
621 event.event.Skip(false);
623 }
624 }
625 }
627}
bool StartEditClipName(AudacityProject &project, IntervalIterator it)
Starts in-place clip name editing or shows a Clip Name Edit dialog, depending on prefs.

References TrackPanelMouseEvent::event, ExitTextEditing(), ViewInfo::Get(), ClipParameters::GetClipRect(), mEditedInterval, mFocusInterval, mTextEditHelper, project, TrackPanelMouseEvent::rect, RefreshCode::RefreshCell, RefreshCode::RefreshNone, and StartEditClipName().

Here is the call graph for this function:

◆ OnRenderClipStretching()

void WaveTrackAffordanceControls::OnRenderClipStretching ( AudacityProject project) const

Definition at line 663 of file WaveTrackAffordanceControls.cpp.

665{
666 const auto [track, it] = SelectedIntervalOfFocusedTrack(project);
667
668 if (track != FindTrack().get())
669 return;
670
671 auto interval = *it;
672
673 if (!interval || !interval->HasPitchOrSpeed())
674 return;
675
677 [track = track, interval = interval](const ProgressReporter& progress) {
678 track->ApplyPitchAndSpeed(
679 { { interval->GetPlayStartTime(), interval->GetPlayEndTime() } },
680 progress);
681 },
682 XO("Applying..."));
683
685 XO("Rendered time-stretched audio"), XO("Render"));
686
687 SelectInterval(project, *interval);
688}
XO("Cut/Copy/Paste")
std::function< void(double)> ProgressReporter
Definition: Track.h:53
void PushState(const TranslatableString &desc, const TranslatableString &shortDesc)
static ProjectHistory & Get(AudacityProject &project)
WAVE_TRACK_API void WithClipRenderingProgress(std::function< void(const ProgressReporter &)> action, TranslatableString title=defaultStretchRenderingTitle, TranslatableString message=XO("Rendering Clip"))
void SelectInterval(AudacityProject &project, const WaveTrack::Interval &interval)
std::pair< WaveTrack *, ChannelGroup::IntervalIterator< WaveTrack::Interval > > SelectedIntervalOfFocusedTrack(AudacityProject &project)

References CommonTrackPanelCell::FindTrack(), ProjectHistory::Get(), project, ProjectHistory::PushState(), anonymous_namespace{WaveTrackAffordanceControls.cpp}::SelectedIntervalOfFocusedTrack(), anonymous_namespace{WaveTrackAffordanceControls.cpp}::SelectInterval(), WaveTrackUtilities::WithClipRenderingProgress(), and XO().

Here is the call graph for this function:

◆ OnSelectionChange()

void WaveTrackAffordanceControls::OnSelectionChange ( NotifyingSelectedRegionMessage  )
private

Definition at line 541 of file WaveTrackAffordanceControls.cpp.

542{
544}

References ExitTextEditing().

Referenced by WaveTrackAffordanceControls().

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

◆ OnTextContextMenu()

void WaveTrackAffordanceControls::OnTextContextMenu ( AudacityProject project,
const wxPoint &  position 
)
overridevirtual

Implements TextEditDelegate.

Definition at line 525 of file WaveTrackAffordanceControls.cpp.

526{
527}

◆ OnTextCopy()

bool WaveTrackAffordanceControls::OnTextCopy ( AudacityProject project)

Definition at line 561 of file WaveTrackAffordanceControls.cpp.

562{
563 if (mTextEditHelper)
564 {
565 mTextEditHelper->CopySelectedText(project);
566 return true;
567 }
568 return false;
569}

References mTextEditHelper, and project.

Referenced by WaveChannelView::CopySelectedText().

Here is the caller graph for this function:

◆ OnTextCut()

bool WaveTrackAffordanceControls::OnTextCut ( AudacityProject project)

Definition at line 571 of file WaveTrackAffordanceControls.cpp.

572{
573 if (mTextEditHelper)
574 {
575 mTextEditHelper->CutSelectedText(project);
576 return true;
577 }
578 return false;
579}

References mTextEditHelper, and project.

Referenced by WaveChannelView::CutSelectedText().

Here is the caller graph for this function:

◆ OnTextEditCancelled()

void WaveTrackAffordanceControls::OnTextEditCancelled ( AudacityProject project)
overridevirtual

Implements TextEditDelegate.

Definition at line 515 of file WaveTrackAffordanceControls.cpp.

516{
518}

References ResetClipNameEdit().

Here is the call graph for this function:

◆ OnTextEditFinished()

void WaveTrackAffordanceControls::OnTextEditFinished ( AudacityProject project,
const wxString &  text 
)
overridevirtual

Implements TextEditDelegate.

Definition at line 501 of file WaveTrackAffordanceControls.cpp.

502{
503 if (auto interval = *mEditedInterval)
504 {
505 if (text != interval->GetName()) {
506 interval->SetName(text);
507
508 ProjectHistory::Get(*project).PushState(XO("Modified Clip Name"),
509 XO("Clip Name Edit"));
510 }
511 }
513}

References ProjectHistory::Get(), mEditedInterval, ProjectHistory::PushState(), ResetClipNameEdit(), and XO().

Here is the call graph for this function:

◆ OnTextModified()

void WaveTrackAffordanceControls::OnTextModified ( AudacityProject project,
const wxString &  text 
)
overridevirtual

Implements TextEditDelegate.

Definition at line 520 of file WaveTrackAffordanceControls.cpp.

521{
522 //Nothing to do
523}

◆ OnTextPaste()

bool WaveTrackAffordanceControls::OnTextPaste ( AudacityProject project)

Definition at line 581 of file WaveTrackAffordanceControls.cpp.

582{
583 if (mTextEditHelper)
584 {
585 mTextEditHelper->PasteSelectedText(project);
586 return true;
587 }
588 return false;
589}

References mTextEditHelper, and project.

Referenced by WaveChannelView::PasteText().

Here is the caller graph for this function:

◆ OnTextSelect()

bool WaveTrackAffordanceControls::OnTextSelect ( AudacityProject project)

Definition at line 591 of file WaveTrackAffordanceControls.cpp.

592{
593 if (mTextEditHelper)
594 {
595 mTextEditHelper->SelectAll();
596 return true;
597 }
598 return false;
599}

References mTextEditHelper.

Referenced by WaveChannelView::SelectAllText().

Here is the caller graph for this function:

◆ OnTrackListEvent()

void WaveTrackAffordanceControls::OnTrackListEvent ( const TrackListEvent evt)
private

Definition at line 535 of file WaveTrackAffordanceControls.cpp.

536{
539}
const Type mType
Definition: Track.h:980
@ SELECTION_CHANGE
Posted when the set of selected tracks changes.
Definition: Track.h:949

References ExitTextEditing(), TrackListEvent::mType, and TrackListEvent::SELECTION_CHANGE.

Referenced by WaveTrackAffordanceControls().

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

◆ ResetClipNameEdit()

void WaveTrackAffordanceControls::ResetClipNameEdit ( )
private

Definition at line 529 of file WaveTrackAffordanceControls.cpp.

530{
531 mTextEditHelper.reset();
532 mEditedInterval = {};
533}

References mEditedInterval, and mTextEditHelper.

Referenced by ExitTextEditing(), OnTextEditCancelled(), and OnTextEditFinished().

Here is the caller graph for this function:

◆ StartEditClipName()

bool WaveTrackAffordanceControls::StartEditClipName ( AudacityProject project,
IntervalIterator  it 
)
private

Starts in-place clip name editing or shows a Clip Name Edit dialog, depending on prefs.

Parameters
clipto be edited. Should belong to the same WaveTrack as returned by FindTrack()

Definition at line 355 of file WaveTrackAffordanceControls.cpp.

356{
357 bool useDialog{ false };
358 gPrefs->Read(wxT("/GUI/DialogForNameNewLabel"), &useDialog, false);
359
360 auto interval = *it;
361 if(!interval)
362 return false;
363
364 if (useDialog)
365 {
367 auto oldName = interval->GetName();
368 Command.mName = oldName;
369 auto result = Command.PromptUser(&GetProjectFrame(project));
370 if (result && Command.mName != oldName)
371 {
372 interval->SetName(Command.mName);
373 ProjectHistory::Get(project).PushState(XO("Modified Clip Name"),
374 XO("Clip Name Edit"));
375 }
376 }
377 else if(it != mEditedInterval)
378 {
379 if(!IsIntervalVisible(it))
380 return false;
381
382 if (mTextEditHelper)
383 mTextEditHelper->Finish(&project);
384
385 mEditedInterval = it;
386 mTextEditHelper = MakeTextEditHelper(interval->GetName());
387 }
388
389 return true;
390}
wxT("CloseDown"))
audacity::BasicSettings * gPrefs
Definition: Prefs.cpp:68
AUDACITY_DLL_API wxFrame & GetProjectFrame(AudacityProject &project)
Get the top-level window associated with the project (as a wxFrame only, when you do not need to use ...
bool IsIntervalVisible(const IntervalIterator &it) const noexcept
std::shared_ptr< TextEditHelper > MakeTextEditHelper(const wxString &text)
virtual bool Read(const wxString &key, bool *value) const =0
constexpr auto Command
Definition: MenuRegistry.h:456

References MenuRegistry::Command, ProjectHistory::Get(), GetProjectFrame(), gPrefs, IsIntervalVisible(), MakeTextEditHelper(), mEditedInterval, mTextEditHelper, project, ProjectHistory::PushState(), audacity::BasicSettings::Read(), wxT(), and XO().

Referenced by OnAffordanceClick(), and StartEditSelectedClipName().

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

◆ StartEditSelectedClipName()

void WaveTrackAffordanceControls::StartEditSelectedClipName ( AudacityProject project)

Definition at line 629 of file WaveTrackAffordanceControls.cpp.

630{
631 auto [track, it] = SelectedIntervalOfFocusedTrack(project);
632 if(track != FindTrack().get())
633 return;
635}

References CommonTrackPanelCell::FindTrack(), project, anonymous_namespace{WaveTrackAffordanceControls.cpp}::SelectedIntervalOfFocusedTrack(), and StartEditClipName().

Here is the call graph for this function:

◆ StartEditSelectedClipSpeed()

void WaveTrackAffordanceControls::StartEditSelectedClipSpeed ( AudacityProject project)

Definition at line 647 of file WaveTrackAffordanceControls.cpp.

649{
650 auto [track, it] = SelectedIntervalOfFocusedTrack(project);
651
652 if (track != FindTrack().get())
653 return;
654
655 auto interval = *it;
656
657 if (!interval)
658 return;
659
660 ShowClipPitchAndSpeedDialog(project, *track, *interval);
661}
void ShowClipPitchAndSpeedDialog(AudacityProject &project, WaveTrack &track, WaveTrack::Interval &interval, std::optional< PitchAndSpeedDialogFocus > focus)

References CommonTrackPanelCell::FindTrack(), project, anonymous_namespace{WaveTrackAffordanceControls.cpp}::SelectedIntervalOfFocusedTrack(), and ShowClipPitchAndSpeedDialog().

Here is the call graph for this function:

Member Data Documentation

◆ mAffordanceHandle

std::weak_ptr<WaveTrackAffordanceHandle> WaveTrackAffordanceControls::mAffordanceHandle
private

Definition at line 49 of file WaveTrackAffordanceControls.h.

Referenced by GetSelectedInterval(), and HitTest().

◆ mClipBorderAdjustHandle

std::weak_ptr<WaveClipAdjustBorderHandle> WaveTrackAffordanceControls::mClipBorderAdjustHandle
private

Definition at line 53 of file WaveTrackAffordanceControls.h.

Referenced by HitTest().

◆ mClipNameFont

wxFont WaveTrackAffordanceControls::mClipNameFont
private

Definition at line 58 of file WaveTrackAffordanceControls.h.

Referenced by Draw(), and MakeTextEditHelper().

◆ mEditedInterval

IntervalIterator WaveTrackAffordanceControls::mEditedInterval
private

◆ mFocusInterval

IntervalIterator WaveTrackAffordanceControls::mFocusInterval
private

Definition at line 45 of file WaveTrackAffordanceControls.h.

Referenced by GetSelectedInterval(), HitTest(), and OnAffordanceClick().

◆ mOverflowButtonHandle

std::weak_ptr<ClipOverflowButtonHandle> WaveTrackAffordanceControls::mOverflowButtonHandle
private

Definition at line 46 of file WaveTrackAffordanceControls.h.

Referenced by Draw(), and HitTest().

◆ mPitchButtonHandle

std::weak_ptr<ClipPitchAndSpeedButtonHandle> WaveTrackAffordanceControls::mPitchButtonHandle
private

Definition at line 47 of file WaveTrackAffordanceControls.h.

Referenced by HitTest().

◆ mResizeHandle

std::weak_ptr<TrackPanelResizeHandle> WaveTrackAffordanceControls::mResizeHandle
private

Definition at line 50 of file WaveTrackAffordanceControls.h.

◆ mSelectHandle

std::weak_ptr<SelectHandle> WaveTrackAffordanceControls::mSelectHandle
private

Definition at line 52 of file WaveTrackAffordanceControls.h.

Referenced by HitTest().

◆ mSelectionChangeSubscription

Observer::Subscription WaveTrackAffordanceControls::mSelectionChangeSubscription
private

Definition at line 124 of file WaveTrackAffordanceControls.h.

Referenced by WaveTrackAffordanceControls().

◆ mSpeedButtonHandle

std::weak_ptr<ClipPitchAndSpeedButtonHandle> WaveTrackAffordanceControls::mSpeedButtonHandle
private

Definition at line 48 of file WaveTrackAffordanceControls.h.

Referenced by HitTest().

◆ mTextEditHelper

std::shared_ptr<TextEditHelper> WaveTrackAffordanceControls::mTextEditHelper
private

◆ mTitleEditHandle

std::weak_ptr<WaveClipTitleEditHandle> WaveTrackAffordanceControls::mTitleEditHandle
private

Definition at line 51 of file WaveTrackAffordanceControls.h.

Referenced by HitTest().

◆ mTrackListEventSubscription

Observer::Subscription WaveTrackAffordanceControls::mTrackListEventSubscription
private

Definition at line 123 of file WaveTrackAffordanceControls.h.

Referenced by WaveTrackAffordanceControls().

◆ mVisibleIntervals

std::vector<IntervalIterator> WaveTrackAffordanceControls::mVisibleIntervals
private

Definition at line 61 of file WaveTrackAffordanceControls.h.

Referenced by Draw().


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