Audacity  3.0.3
Public Member Functions | 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
 
bool StartEditClipName (AudacityProject *project)
 
std::weak_ptr< WaveClipGetSelectedClip () 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
 
bool StartEditNameOfMatchingClip (AudacityProject &project, std::function< bool(WaveClip &)> test)
 
unsigned OnAffordanceClick (const TrackPanelMouseEvent &event, AudacityProject *project)
 
- Public Member Functions inherited from CommonTrackCell
 CommonTrackCell (const std::shared_ptr< Track > &pTrack)
 
 ~CommonTrackCell ()
 
virtual void CopyTo (Track &track) const
 
std::shared_ptr< TrackDoFindTrack () override
 
virtual void Reparent (const std::shared_ptr< Track > &parent)
 
virtual void WriteXMLAttributes (XMLWriter &) const
 
virtual bool HandleXMLAttribute (const wxChar *attr, const wxChar *value)
 
- 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 &) PROHIBITED
 
TrackPanelCelloperator= (const TrackPanelCell &) PROHIBITED
 
virtual ~TrackPanelCell ()=0
 
virtual std::shared_ptr< TrackPanelCellContextMenuDelegate ()
 
virtual unsigned KeyUp (wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent, AudacityProject *project)
 
- Public Member Functions inherited from TrackPanelNode
 TrackPanelNode ()
 
virtual ~TrackPanelNode ()=0
 
- Public Member Functions inherited from TrackPanelDrawable
virtual ~TrackPanelDrawable ()=0
 
virtual wxRect DrawingArea (TrackPanelDrawingContext &context, const wxRect &rect, const wxRect &panelRect, unsigned iPass)
 
- Public Member Functions inherited from TextEditDelegate
virtual ~TextEditDelegate ()
 

Private Member Functions

void ResetClipNameEdit ()
 
void OnTrackChanged (TrackListEvent &evt)
 
unsigned ExitTextEditing ()
 
bool SelectNextClip (ViewInfo &viewInfo, AudacityProject *project, bool forward)
 
std::shared_ptr< TextEditHelperMakeTextEditHelper (const wxString &text)
 

Private Attributes

std::weak_ptr< WaveClipmFocusClip
 
std::weak_ptr< WaveTrackAffordanceHandlemAffordanceHandle
 
std::weak_ptr< TrackPanelResizeHandlemResizeHandle
 
std::weak_ptr< WaveClipTitleEditHandlemTitleEditHandle
 
std::weak_ptr< SelectHandlemSelectHandle
 
std::weak_ptr< WaveClipTrimHandlemClipTrimHandle
 
std::weak_ptr< WaveClipmEditedClip
 
std::shared_ptr< TextEditHelpermTextEditHelper
 
wxFont mClipNameFont
 

Additional Inherited Members

- Public Types inherited from CommonTrackPanelCell
using Hook = std::function< unsigned(const TrackPanelMouseEvent &evt, AudacityProject *pProject) >
 
- Static Public Member Functions inherited from CommonTrackPanelCell
static Hook InstallMouseWheelHook (const Hook &hook)
 
- 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
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 33 of file WaveTrackAffordanceControls.h.

Constructor & Destructor Documentation

◆ WaveTrackAffordanceControls()

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

Definition at line 164 of file WaveTrackAffordanceControls.cpp.

165  : CommonTrackCell(pTrack), mClipNameFont(wxFont(wxFontInfo()))
166 {
167  if (auto trackList = pTrack->GetOwner())
168  {
169  trackList->Bind(EVT_TRACKLIST_SELECTION_CHANGE,
171  this);
172  }
173 }

References Track::GetOwner(), and OnTrackChanged().

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 411 of file WaveTrackAffordanceControls.cpp.

412 {
413  const auto keyCode = event.GetKeyCode();
414  bool handleIt =
415  // Handle the event if we are already editing clip name text...
416  (mTextEditHelper != nullptr)
417  // ... or it is the navigation key
418  || (keyCode == WXK_TAB);
419  if (!handleIt)
420  event.Skip();
422 }

References mTextEditHelper, and RefreshCode::RefreshNone.

◆ Char()

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

Reimplemented from TrackPanelCell.

Definition at line 447 of file WaveTrackAffordanceControls.cpp.

448 {
449  if (mTextEditHelper && mTextEditHelper->OnChar(event.GetUnicodeKey(), project))
452 }

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

◆ Draw()

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

Reimplemented from TrackPanelDrawable.

Definition at line 259 of file WaveTrackAffordanceControls.cpp.

260 {
261  if (iPass == TrackArtist::PassBackground) {
262  auto track = FindTrack();
263  const auto artist = TrackArtist::Get(context);
264 
265  TrackArt::DrawBackgroundWithSelection(context, rect, track.get(), artist->blankSelectedBrush, artist->blankBrush);
266 
267  const auto waveTrack = std::static_pointer_cast<WaveTrack>(track->SubstitutePendingChangedTrack());
268  const auto& zoomInfo = *artist->pZoomInfo;
269 
270  {
271  wxDCClipper dcClipper(context.dc, rect);
272 
273  context.dc.SetTextBackground(wxTransparentColor);
274  context.dc.SetTextForeground(theTheme.Colour(clrClipNameText));
275  context.dc.SetFont(mClipNameFont);
276 
277  auto px = context.lastState.m_x;
278  auto py = context.lastState.m_y;
279 
280  for (const auto& clip : waveTrack->GetClips())
281  {
282  auto affordanceRect
283  = ClipParameters::GetClipRect(*clip.get(), zoomInfo, rect);
284  if (affordanceRect.IsEmpty())
285  continue;
286 
287  auto selected = GetSelectedClip().lock() == clip;
288  auto highlight = selected || affordanceRect.Contains(px, py);
289  if (mTextEditHelper && mEditedClip.lock() == clip)
290  {
291  TrackArt::DrawClipAffordance(context.dc, affordanceRect, wxEmptyString, highlight, selected);
292  mTextEditHelper->Draw(context.dc, TrackArt::GetAffordanceTitleRect(affordanceRect));
293  }
294  else
295  TrackArt::DrawClipAffordance(context.dc, affordanceRect, clip->GetName(), highlight, selected);
296 
297  }
298  }
299 
300  }
301 }

References ThemeBase::Colour(), TrackPanelDrawingContext::dc, TrackArt::DrawBackgroundWithSelection(), TrackArt::DrawClipAffordance(), CommonTrackPanelCell::FindTrack(), TrackArtist::Get(), TrackArt::GetAffordanceTitleRect(), ClipParameters::GetClipRect(), GetSelectedClip(), TrackPanelDrawingContext::lastState, mClipNameFont, mEditedClip, mTextEditHelper, TrackArtist::PassBackground, and theTheme.

Here is the call graph for this function:

◆ ExitTextEditing()

unsigned WaveTrackAffordanceControls::ExitTextEditing ( )
private

Definition at line 499 of file WaveTrackAffordanceControls.cpp.

500 {
501  using namespace RefreshCode;
502  if (mTextEditHelper)
503  {
504  if (auto trackList = FindTrack()->GetOwner())
505  {
506  mTextEditHelper->Finish(trackList->GetOwner());
507  }
509  return RefreshCell;
510  }
511  return RefreshNone;
512 }

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

Referenced by LoseFocus(), OnAffordanceClick(), and OnTrackChanged().

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

◆ GetSelectedClip()

std::weak_ptr< WaveClip > WaveTrackAffordanceControls::GetSelectedClip ( ) const

Definition at line 340 of file WaveTrackAffordanceControls.cpp.

341 {
342  if (auto handle = mAffordanceHandle.lock())
343  {
344  return handle->Clicked() ? mFocusClip : std::weak_ptr<WaveClip>();
345  }
346  return {};
347 }

References mAffordanceHandle, and mFocusClip.

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 175 of file WaveTrackAffordanceControls.cpp.

176 {
177  std::vector<UIHandlePtr> results;
178 
179  auto px = state.state.m_x;
180  auto py = state.state.m_y;
181 
182  const auto rect = state.rect;
183 
184  const auto track = FindTrack();
185 
186  {
187  auto handle = WaveClipTrimHandle::HitAnywhere(
189  std::static_pointer_cast<WaveTrack>(track).get(),
190  pProject,
191  state);
192 
193  if (handle)
194  results.push_back(handle);
195  }
196 
197  auto trackList = track->GetOwner();
198  if ((std::abs(rect.GetTop() - py) <= WaveTrackView::kChannelSeparatorThickness / 2)
199  && trackList
200  && !track->IsLeader())
201  {
202  //given that track is not a leader there always should be
203  //another track before this one
204  auto prev = std::prev(trackList->Find(track.get()));
205  results.push_back(
207  mResizeHandle,
208  std::make_shared<TrackPanelResizeHandle>((*prev)->shared_from_this(), py)
209  )
210  );
211  }
212 
213  if (mTextEditHelper && mTextEditHelper->GetBBox().Contains(px, py))
214  {
215  results.push_back(
218  std::make_shared<WaveClipTitleEditHandle>(mTextEditHelper)
219  )
220  );
221  }
222 
223  auto editClipLock = mEditedClip.lock();
224  const auto waveTrack = std::static_pointer_cast<WaveTrack>(track->SubstitutePendingChangedTrack());
225  auto& zoomInfo = ViewInfo::Get(*pProject);
226  for (const auto& clip : waveTrack->GetClips())
227  {
228  if (clip == editClipLock)
229  continue;
230 
231  auto affordanceRect = ClipParameters::GetClipRect(*clip.get(), zoomInfo, state.rect);
232  if (affordanceRect.Contains(px, py))
233  {
234  results.push_back(
237  std::make_shared<WaveTrackAffordanceHandle>(track, clip)
238  )
239  );
240  mFocusClip = clip;
241  break;
242  }
243  }
244 
245  const auto& settings = ProjectSettings::Get(*pProject);
246  const auto currentTool = settings.GetTool();
247  if (currentTool == ToolCodes::multiTool || currentTool == ToolCodes::selectTool)
248  {
249  results.push_back(
251  mSelectHandle, state, pProject, std::static_pointer_cast<TrackView>(track->GetTrackView())
252  )
253  );
254  }
255 
256  return results;
257 }

References AssignUIHandlePtr(), CommonTrackPanelCell::FindTrack(), ViewInfo::Get(), ProjectSettings::Get(), ClipParameters::GetClipRect(), WaveClipTrimHandle::HitAnywhere(), SelectHandle::HitTest(), WaveTrackView::kChannelSeparatorThickness, mAffordanceHandle, mClipTrimHandle, mEditedClip, mFocusClip, mResizeHandle, mSelectHandle, mTextEditHelper, mTitleEditHandle, ToolCodes::multiTool, TrackPanelMouseState::rect, ToolCodes::selectTool, settings(), and TrackPanelMouseState::state.

Here is the call graph for this function:

◆ KeyDown()

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

Reimplemented from TrackPanelCell.

Definition at line 425 of file WaveTrackAffordanceControls.cpp.

426 {
427  auto keyCode = event.GetKeyCode();
428 
429  if (mTextEditHelper)
430  {
431  mTextEditHelper->OnKeyDown(keyCode, event.GetModifiers(), project);
432  if (!TextEditHelper::IsGoodEditKeyCode(keyCode))
433  event.Skip();
434  }
435  else
436  {
437  switch (keyCode)
438  {
439  case WXK_TAB: {
440  SelectNextClip(viewInfo, project, event.GetModifiers() != wxMOD_SHIFT);
441  } break;
442  }
443  }
445 }

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

Here is the call graph for this function:

◆ LoseFocus()

unsigned WaveTrackAffordanceControls::LoseFocus ( AudacityProject project)
overridevirtual

Reimplemented from TrackPanelCell.

Definition at line 454 of file WaveTrackAffordanceControls.cpp.

455 {
456  return ExitTextEditing();
457 }

References ExitTextEditing().

Here is the call graph for this function:

◆ MakeTextEditHelper()

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

Definition at line 629 of file WaveTrackAffordanceControls.cpp.

630 {
631  auto helper = std::make_shared<TextEditHelper>(shared_from_this(), text, mClipNameFont);
632  helper->SetTextColor(theTheme.Colour(clrClipNameText));
633  helper->SetTextSelectionColor(theTheme.Colour(clrClipNameTextSelection));
634  return helper;
635 }

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 lock = mEditedClip.lock())
607  {
608  auto affordanceRect = ClipParameters::GetClipRect(*lock.get(), viewInfo, event.rect);
609  if (!affordanceRect.Contains(event.event.GetPosition()))
610  return ExitTextEditing();
611  }
612  }
613  else if (auto lock = mFocusClip.lock())
614  {
615  if (event.event.LeftDClick())
616  {
617  auto affordanceRect = ClipParameters::GetClipRect(*lock.get(), viewInfo, event.rect);
618  if (affordanceRect.Contains(event.event.GetPosition()) &&
619  StartEditClipName(project))
620  {
621  event.event.Skip();
623  }
624  }
625  }
627 }

References RefreshCode::Cancelled, TrackPanelMouseEvent::event, ExitTextEditing(), ViewInfo::Get(), ClipParameters::GetClipRect(), mEditedClip, mFocusClip, mTextEditHelper, TrackPanelMouseEvent::rect, RefreshCode::RefreshCell, RefreshCode::RefreshNone, and StartEditClipName().

Here is the call graph for this function:

◆ OnTextContextMenu()

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

Implements TextEditDelegate.

Definition at line 483 of file WaveTrackAffordanceControls.cpp.

484 {
485 }

◆ OnTextEditCancelled()

void WaveTrackAffordanceControls::OnTextEditCancelled ( AudacityProject project)
overridevirtual

Implements TextEditDelegate.

Definition at line 473 of file WaveTrackAffordanceControls.cpp.

474 {
476 }

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 459 of file WaveTrackAffordanceControls.cpp.

460 {
461  if (auto lock = mEditedClip.lock())
462  {
463  if (text != lock->GetName()) {
464  lock->SetName(text);
465 
466  ProjectHistory::Get(*project).PushState(XO("Modified Clip Name"),
467  XO("Clip Name Edit"), UndoPush::CONSOLIDATE);
468  }
469  }
471 }

References CONSOLIDATE, ProjectHistory::Get(), mEditedClip, 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 478 of file WaveTrackAffordanceControls.cpp.

479 {
480  //Nothing to do
481 }

◆ OnTrackChanged()

void WaveTrackAffordanceControls::OnTrackChanged ( TrackListEvent evt)
private

Definition at line 493 of file WaveTrackAffordanceControls.cpp.

494 {
495  evt.Skip();
496  ExitTextEditing();
497 }

References ExitTextEditing().

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 487 of file WaveTrackAffordanceControls.cpp.

488 {
489  mTextEditHelper.reset();
490  mEditedClip.reset();
491 }

References mEditedClip, and mTextEditHelper.

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

Here is the caller graph for this function:

◆ SelectNextClip()

bool WaveTrackAffordanceControls::SelectNextClip ( ViewInfo viewInfo,
AudacityProject project,
bool  forward 
)
private

Definition at line 533 of file WaveTrackAffordanceControls.cpp.

534 {
535  //Iterates through clips in a looped manner
536  auto waveTrack = std::dynamic_pointer_cast<WaveTrack>(FindTrack());
537  if (!waveTrack)
538  return false;
539  auto clips = waveTrack->SortedClipArray();
540  if (clips.empty())
541  return false;
542 
543  const WaveClip* clip{ };
544  if (forward)
545  {
546  clip = NextClipLooped(viewInfo, clips.begin(), clips.end(), [&](const WaveClip* other) {
547  return other->GetPlayStartTime() >= viewInfo.selectedRegion.t1();
548  });
549  }
550  else
551  {
552  clip = NextClipLooped(viewInfo, clips.rbegin(), clips.rend(), [&](const WaveClip* other) {
553  return other->GetPlayStartTime() <= viewInfo.selectedRegion.t0();
554  });
555  }
556 
557  viewInfo.selectedRegion.setTimes(clip->GetPlayStartTime(), clip->GetPlayEndTime());
558  ProjectHistory::Get(*project).ModifyState(false);
559 
560  // create and send message to screen reader
561  auto it = std::find(clips.begin(), clips.end(), clip);
562  auto index = std::distance(clips.begin(), it);
563 
564  auto message = XP(
565  /* i18n-hint:
566  string is the name of a clip
567  first number is the position of that clip in a sequence of clips,
568  second number counts the clips */
569  "%s, %d of %d clip",
570  "%s, %d of %d clips",
571  2
572  )(
573  clip->GetName(),
574  static_cast<int>(index + 1),
575  static_cast<int>(clips.size())
576  );
577 
578  TrackFocus::Get(*project).MessageForScreenReader(message);
579  return true;
580 }

References CommonTrackPanelCell::FindTrack(), TrackFocus::Get(), ProjectHistory::Get(), ProjectHistory::ModifyState(), anonymous_namespace{WaveTrackAffordanceControls.cpp}::NextClipLooped(), ViewInfo::selectedRegion, NotifyingSelectedRegion::setTimes(), and XP.

Referenced by KeyDown().

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

◆ StartEditClipName()

bool WaveTrackAffordanceControls::StartEditClipName ( AudacityProject project)

Definition at line 303 of file WaveTrackAffordanceControls.cpp.

304 {
305  if (auto lock = mFocusClip.lock())
306  {
307  auto clip = lock.get();
308 
309  bool useDialog{ false };
310  gPrefs->Read(wxT("/GUI/DialogForNameNewLabel"), &useDialog, false);
311 
312  if (useDialog)
313  {
315  auto oldName = clip->GetName();
316  Command.mName = oldName;
317  auto result = Command.PromptUser(&GetProjectFrame(*project));
318  if (result && Command.mName != oldName)
319  {
320  clip->SetName(Command.mName);
321  ProjectHistory::Get(*project).PushState(XO("Modified Clip Name"),
322  XO("Clip Name Edit"), UndoPush::CONSOLIDATE);
323 
324  return true;
325  }
326  }
327  else
328  {
329  if (mTextEditHelper)
330  mTextEditHelper->Finish(project);
331 
332  mEditedClip = lock;
333  mTextEditHelper = MakeTextEditHelper(clip->GetName());
334  return true;
335  }
336  }
337  return false;
338 }

References MenuTable::Command(), CONSOLIDATE, ProjectHistory::Get(), GetProjectFrame(), gPrefs, MakeTextEditHelper(), mEditedClip, mFocusClip, mTextEditHelper, ProjectHistory::PushState(), and XO.

Referenced by OnAffordanceClick(), and StartEditNameOfMatchingClip().

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

◆ StartEditNameOfMatchingClip()

bool WaveTrackAffordanceControls::StartEditNameOfMatchingClip ( AudacityProject project,
std::function< bool(WaveClip &)>  test 
)
Parameters
testEdit the first clip in the track's list satisfying the test

Definition at line 582 of file WaveTrackAffordanceControls.cpp.

584 {
585  //Attempts to invoke name editing if there is a selected clip
586  auto waveTrack = std::dynamic_pointer_cast<WaveTrack>(FindTrack());
587  if (!waveTrack)
588  return false;
589  auto clips = waveTrack->GetClips();
590 
591  auto it = std::find_if(clips.begin(), clips.end(),
592  [&](auto pClip){ return pClip && test && test(*pClip); });
593  if (it != clips.end())
594  {
595  mFocusClip = *it;
596  return StartEditClipName(&project);
597  }
598  return false;
599 }

References CommonTrackPanelCell::FindTrack(), mFocusClip, and StartEditClipName().

Here is the call graph for this function:

Member Data Documentation

◆ mAffordanceHandle

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

Definition at line 40 of file WaveTrackAffordanceControls.h.

Referenced by GetSelectedClip(), and HitTest().

◆ mClipNameFont

wxFont WaveTrackAffordanceControls::mClipNameFont
private

Definition at line 49 of file WaveTrackAffordanceControls.h.

Referenced by Draw(), and MakeTextEditHelper().

◆ mClipTrimHandle

std::weak_ptr<WaveClipTrimHandle> WaveTrackAffordanceControls::mClipTrimHandle
private

Definition at line 44 of file WaveTrackAffordanceControls.h.

Referenced by HitTest().

◆ mEditedClip

std::weak_ptr<WaveClip> WaveTrackAffordanceControls::mEditedClip
private

◆ mFocusClip

std::weak_ptr<WaveClip> WaveTrackAffordanceControls::mFocusClip
private

◆ mResizeHandle

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

Definition at line 41 of file WaveTrackAffordanceControls.h.

Referenced by HitTest().

◆ mSelectHandle

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

Definition at line 43 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 42 of file WaveTrackAffordanceControls.h.

Referenced by HitTest().


The documentation for this class was generated from the following files:
SetWaveClipNameCommand
Definition: WaveTrackAffordanceControls.cpp:83
ProjectHistory::ModifyState
void ModifyState(bool bWantsAutoSave)
Definition: ProjectHistory.cpp:124
ViewInfo::Get
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:241
WaveTrackView::kChannelSeparatorThickness
static constexpr int kChannelSeparatorThickness
Definition: WaveTrackView.h:102
WaveTrackAffordanceControls::mClipNameFont
wxFont mClipNameFont
Definition: WaveTrackAffordanceControls.h:49
WaveTrackAffordanceControls::ResetClipNameEdit
void ResetClipNameEdit()
Definition: WaveTrackAffordanceControls.cpp:487
TrackPanelMouseEvent::rect
const wxRect & rect
Definition: TrackPanelMouseEvent.h:59
anonymous_namespace{WaveTrackAffordanceControls.cpp}::NextClipLooped
const WaveClip * NextClipLooped(ViewInfo &viewInfo, Iter begin, Iter end, Comp comp)
Definition: WaveTrackAffordanceControls.cpp:518
ToolCodes::selectTool
@ selectTool
Definition: ProjectSettings.h:40
RefreshCode::RefreshNone
@ RefreshNone
Definition: RefreshCode.h:21
gPrefs
FileConfig * gPrefs
Definition: Prefs.cpp:70
CommonTrackPanelCell::FindTrack
std::shared_ptr< Track > FindTrack()
Definition: CommonTrackPanelCell.h:46
WaveTrackAffordanceControls::mAffordanceHandle
std::weak_ptr< WaveTrackAffordanceHandle > mAffordanceHandle
Definition: WaveTrackAffordanceControls.h:40
RefreshCode::Cancelled
@ Cancelled
Definition: RefreshCode.h:23
XO
#define XO(s)
Definition: Internat.h:31
Track::GetOwner
std::shared_ptr< TrackList > GetOwner() const
Definition: Track.h:379
ProjectSettings::Get
static ProjectSettings & Get(AudacityProject &project)
Definition: ProjectSettings.cpp:44
TrackPanelDrawingContext::dc
wxDC & dc
Definition: TrackPanelDrawingContext.h:23
WaveTrackAffordanceControls::mFocusClip
std::weak_ptr< WaveClip > mFocusClip
Definition: WaveTrackAffordanceControls.h:39
TrackPanelMouseState::rect
const wxRect & rect
Definition: TrackPanelMouseEvent.h:39
TrackArt::GetAffordanceTitleRect
AUDACITY_DLL_API wxRect GetAffordanceTitleRect(const wxRect &affordanceRect)
Definition: TrackArtist.cpp:358
WaveTrackAffordanceControls::mEditedClip
std::weak_ptr< WaveClip > mEditedClip
Definition: WaveTrackAffordanceControls.h:46
NotifyingSelectedRegion::setTimes
bool setTimes(double t0, double t1)
Definition: ViewInfo.cpp:62
ClipParameters::GetClipRect
static wxRect GetClipRect(const WaveClip &clip, const ZoomInfo &zoomInfo, const wxRect &viewRect)
Definition: WaveTrackView.cpp:1448
WaveClip
This allows multiple clips to be a part of one WaveTrack.
Definition: WaveClip.h:175
TrackArt::DrawClipAffordance
AUDACITY_DLL_API void DrawClipAffordance(wxDC &dc, const wxRect &affordanceRect, const wxString &title, bool highlight=false, bool selected=false)
Definition: TrackArtist.cpp:302
ViewInfo::selectedRegion
NotifyingSelectedRegion selectedRegion
Definition: ViewInfo.h:229
TrackArtist::Get
static TrackArtist * Get(TrackPanelDrawingContext &)
Definition: TrackArtist.cpp:79
ToolCodes::multiTool
@ multiTool
Definition: ProjectSettings.h:44
CommonTrackCell::CommonTrackCell
CommonTrackCell(const std::shared_ptr< Track > &pTrack)
Definition: CommonTrackPanelCell.cpp:132
TrackPanelDrawingContext::lastState
wxMouseState lastState
Definition: TrackPanelDrawingContext.h:25
WaveTrackAffordanceControls::mResizeHandle
std::weak_ptr< TrackPanelResizeHandle > mResizeHandle
Definition: WaveTrackAffordanceControls.h:41
WaveTrackAffordanceControls::GetSelectedClip
std::weak_ptr< WaveClip > GetSelectedClip() const
Definition: WaveTrackAffordanceControls.cpp:340
WaveTrackAffordanceControls::mTitleEditHandle
std::weak_ptr< WaveClipTitleEditHandle > mTitleEditHandle
Definition: WaveTrackAffordanceControls.h:42
TrackFocus::Get
Track * Get()
Definition: TrackPanelAx.cpp:755
WaveTrackAffordanceControls::ExitTextEditing
unsigned ExitTextEditing()
Definition: WaveTrackAffordanceControls.cpp:499
WaveClipTrimHandle::HitAnywhere
static UIHandlePtr HitAnywhere(std::weak_ptr< WaveClipTrimHandle > &holder, WaveTrack *waveTrack, const AudacityProject *pProject, const TrackPanelMouseState &state)
Definition: WaveClipTrimHandle.cpp:64
RefreshCode::RefreshCell
@ RefreshCell
Definition: RefreshCode.h:24
theTheme
THEME_API Theme theTheme
Definition: Theme.cpp:79
WaveTrackAffordanceControls::OnTrackChanged
void OnTrackChanged(TrackListEvent &evt)
Definition: WaveTrackAffordanceControls.cpp:493
ProjectHistory::PushState
void PushState(const TranslatableString &desc, const TranslatableString &shortDesc)
Definition: ProjectHistory.cpp:90
TrackArt::DrawBackgroundWithSelection
AUDACITY_DLL_API void DrawBackgroundWithSelection(TrackPanelDrawingContext &context, const wxRect &rect, const Track *track, const wxBrush &selBrush, const wxBrush &unselBrush, bool useSelection=true)
Definition: TrackArtist.cpp:528
XP
#define XP(sing, plur, n)
Definition: Internat.h:96
SelectHandle::HitTest
static UIHandlePtr HitTest(std::weak_ptr< SelectHandle > &holder, const TrackPanelMouseState &state, const AudacityProject *pProject, const std::shared_ptr< TrackView > &pTrackView)
Definition: SelectHandle.cpp:362
MenuTable::Command
std::unique_ptr< CommandItem > Command(const CommandID &name, const TranslatableString &label_in, void(Handler::*pmf)(const CommandContext &), CommandFlag flags, const CommandManager::Options &options={}, CommandHandlerFinder finder=FinderScope::DefaultFinder())
Definition: CommandManager.h:675
WaveTrackAffordanceControls::StartEditClipName
bool StartEditClipName(AudacityProject *project)
Definition: WaveTrackAffordanceControls.cpp:303
GetProjectFrame
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 ...
Definition: ProjectWindows.cpp:72
WaveTrackAffordanceControls::SelectNextClip
bool SelectNextClip(ViewInfo &viewInfo, AudacityProject *project, bool forward)
Definition: WaveTrackAffordanceControls.cpp:533
WaveTrackAffordanceControls::MakeTextEditHelper
std::shared_ptr< TextEditHelper > MakeTextEditHelper(const wxString &text)
Definition: WaveTrackAffordanceControls.cpp:629
UndoPush::CONSOLIDATE
@ CONSOLIDATE
ThemeBase::Colour
wxColour & Colour(int iIndex)
Definition: Theme.cpp:1189
TextEditHelper::IsGoodEditKeyCode
static bool IsGoodEditKeyCode(int keyCode)
Definition: TextEditHelper.cpp:26
WaveTrackAffordanceControls::mSelectHandle
std::weak_ptr< SelectHandle > mSelectHandle
Definition: WaveTrackAffordanceControls.h:43
AssignUIHandlePtr
std::shared_ptr< Subclass > AssignUIHandlePtr(std::weak_ptr< Subclass > &holder, const std::shared_ptr< Subclass > &pNew)
Definition: UIHandle.h:151
WaveTrackAffordanceControls::mClipTrimHandle
std::weak_ptr< WaveClipTrimHandle > mClipTrimHandle
Definition: WaveTrackAffordanceControls.h:44
WaveTrackAffordanceControls::mTextEditHelper
std::shared_ptr< TextEditHelper > mTextEditHelper
Definition: WaveTrackAffordanceControls.h:47
settings
static Settings & settings()
Definition: TrackInfo.cpp:86
RefreshCode
Namespace containing an enum 'what to do on a refresh?'.
Definition: RefreshCode.h:16
TrackArtist::PassBackground
@ PassBackground
Definition: TrackArtist.h:86
TrackPanelMouseEvent::event
wxMouseEvent & event
Definition: TrackPanelMouseEvent.h:58
TrackPanelMouseState::state
wxMouseState & state
Definition: TrackPanelMouseEvent.h:38
ProjectHistory::Get
static ProjectHistory & Get(AudacityProject &project)
Definition: ProjectHistory.cpp:26