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)
 Construct from a track. 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...
 
- 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 }
154 , mClipNameFont{ wxFontInfo{} }
155{
156 if (auto trackList = pTrack->GetOwner()) {
157 if (auto pProject = trackList->GetOwner()) {
160 if(auto project = trackList->GetOwner())
161 {
162 auto& viewInfo = ViewInfo::Get(*project);
164 viewInfo.selectedRegion.Subscribe(
165 *this,
167 }
168 }
169 }
170}
const auto project
Subscription Subscribe(Callback callback)
Connect a callback to the Publisher; later-connected are called earlier.
Definition: Observer.h:199
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(), project, and Observer::Publisher< Message, NotifyAll >::Subscribe().

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

485{
486 if (!mTextEditHelper
487 || !mTextEditHelper->CaptureKey(event.GetKeyCode(), event.GetModifiers()))
488 // Handle the event if it can be processed by the text editor (if any)
489 event.Skip();
491}
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 509 of file WaveTrackAffordanceControls.cpp.

510{
511 if (mTextEditHelper && mTextEditHelper->OnChar(event.GetUnicodeKey(), project))
514}

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

274{
275 if (iPass == TrackArtist::PassBackground) {
276 const auto track = FindTrack().get();
277 if (!track)
278 return;
279 const auto artist = TrackArtist::Get(context);
280 const auto &pendingTracks = *artist->pPendingTracks;
281
282 // Color the background of the affordance rectangle (only one per track)
283 // as for the topmost channel
285 rect, **track->Channels().begin(),
286 artist->clipAffordanceBackgroundSelBrush,
287 artist->clipAffordanceBackgroundBrush,
288 true, true);
289
290 mVisibleIntervals.clear();
291
292 auto &waveTrack = static_cast<WaveTrack&>(
293 pendingTracks.SubstitutePendingChangedTrack(*track));
294 const auto& zoomInfo = *artist->pZoomInfo;
295 {
296 wxDCClipper dcClipper(context.dc, rect);
297
298 context.dc.SetTextBackground(wxTransparentColor);
299 context.dc.SetTextForeground(theTheme.Colour(clrClipNameText));
300 context.dc.SetFont(mClipNameFont);
301
302 auto px = context.lastState.m_x;
303 auto py = context.lastState.m_y;
304
305 const auto overflowHandle = mOverflowButtonHandle.lock();
306 const auto &intervals = waveTrack.Intervals();
307 for(auto it = intervals.begin(); it != intervals.end(); ++it)
308 {
309 auto interval = *it;
310 const auto& clip = *interval;
311 const auto clipRect = ClipParameters::GetClipRect(
312 clip, zoomInfo, rect);
313
314 if(!WaveChannelView::ClipDetailsVisible(clip, zoomInfo, rect))
315 {
316 TrackArt::DrawClipFolded(context.dc, clipRect);
317 continue;
318 }
319
320 const auto selected = GetSelectedInterval() == it;
321 const auto highlightAffordance =
322 !overflowHandle && (selected || clipRect.Contains(px, py));
323 auto affordanceRect = TrackArt::DrawClipAffordance(
324 context.dc, clipRect, highlightAffordance, selected);
325
326 if (
327 const auto overflowButtonRect =
328 LowlitClipButton::DrawOnClip<ClipButtonId::Overflow>(
329 { clip, zoomInfo, rect }, context.dc))
330 affordanceRect.width -= overflowButtonRect->width;
331 if (
332 const auto speedButtonRect =
333 LowlitClipButton::DrawOnClip<ClipButtonId::Speed>(
334 { clip, zoomInfo, rect }, context.dc))
335 affordanceRect.width -= speedButtonRect->width;
336 if (
337 const auto pitchButtonRect =
338 LowlitClipButton::DrawOnClip<ClipButtonId::Pitch>(
339 { clip, zoomInfo, rect }, context.dc))
340 affordanceRect.width -= pitchButtonRect->width;
341
342 if (mTextEditHelper && mEditedInterval == it)
343 {
344 if (!mTextEditHelper->Draw(context.dc, affordanceRect))
345 {
346 mTextEditHelper->Cancel(nullptr);
348 context.dc, affordanceRect, interval->GetName());
349 }
350 }
352 context.dc, affordanceRect, interval->GetName()))
353 mVisibleIntervals.push_back(it);
354 }
355 }
356 }
357}
THEME_API Theme theTheme
Definition: Theme.cpp:82
std::shared_ptr< Track > FindTrack()
wxColour & Colour(int iIndex)
static TrackArtist * Get(TrackPanelDrawingContext &)
Definition: TrackArtist.cpp:81
static bool ClipDetailsVisible(const ClipTimes &clip, const ZoomInfo &zoomInfo, const wxRect &viewRect)
std::vector< IntervalIterator > mVisibleIntervals
std::weak_ptr< ClipOverflowButtonHandle > mOverflowButtonHandle
IntervalIterator GetSelectedInterval() const
A Track that contains audio waveform data.
Definition: WaveTrack.h:203
AUDACITY_DLL_API void DrawBackgroundWithSelection(TrackPanelDrawingContext &context, const wxRect &rect, const Channel &channel, const wxBrush &selBrush, const wxBrush &unselBrush, bool useSelection=true, bool useBeatsAlternateColor=false)
Helper: draws background with selection rect.
Definition: TrackArt.cpp:648
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 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 566 of file WaveTrackAffordanceControls.cpp.

567{
568 using namespace RefreshCode;
569 if (mTextEditHelper)
570 {
571 if (auto trackList = FindTrack()->GetOwner())
572 {
573 mTextEditHelper->Finish(trackList->GetOwner());
574 }
576 return RefreshCell;
577 }
578 return RefreshNone;
579}
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 709 of file WaveTrackAffordanceControls.cpp.

712{
714}
std::vector< CommonTrackPanelCell::MenuItem > GetWaveClipMenuItems()

References WaveClipUIUtilities::GetWaveClipMenuItems().

Here is the call graph for this function:

◆ GetSelectedInterval()

auto WaveTrackAffordanceControls::GetSelectedInterval ( ) const

Definition at line 403 of file WaveTrackAffordanceControls.cpp.

404{
405 if (auto handle = mAffordanceHandle.lock())
406 {
407 return handle->Clicked() ? mFocusInterval : IntervalIterator{};
408 }
409 return {};
410}
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 172 of file WaveTrackAffordanceControls.cpp.

173{
174 std::vector<UIHandlePtr> results;
175
176 const auto px = state.state.m_x;
177 const auto py = state.state.m_y;
178 const wxPoint mousePoint { px, py };
179
180 const auto rect = state.rect;
181
182 auto track = std::static_pointer_cast<WaveTrack>(FindTrack());
183 if (!track)
184 return {};
185
186 {
189 track,
190 pProject,
191 state);
192
193 if (handle)
194 results.push_back(handle);
195 }
196
197 if (mTextEditHelper && mTextEditHelper->GetBBox().Contains(px, py))
198 {
199 results.push_back(
202 std::make_shared<WaveClipTitleEditHandle>(
203 mTextEditHelper, track)
204 )
205 );
206 }
207
208 auto &waveTrack = static_cast<WaveTrack&>(
210 auto& zoomInfo = ViewInfo::Get(*pProject);
211 const auto &intervals = waveTrack.Intervals();
212 for(auto it = intervals.begin(); it != intervals.end(); ++it)
213 {
214 if (it == mEditedInterval)
215 continue;
216
217 const auto clip = (*it);
218 if (LowlitClipButton::HitTest<ClipButtonId::Overflow>(
219 { *clip, zoomInfo, rect }, mousePoint))
220 {
221 results.push_back(AssignUIHandlePtr(
222 mOverflowButtonHandle, std::make_shared<ClipOverflowButtonHandle>(
223 track, *it, weak_from_this())));
224 mFocusInterval = it;
225 break;
226 }
227 else if (LowlitClipButton::HitTest<ClipButtonId::Pitch>(
228 { *clip, zoomInfo, rect }, mousePoint))
229 {
230 results.push_back(AssignUIHandlePtr(
232 std::make_shared<ClipPitchAndSpeedButtonHandle>(
234 mFocusInterval = it;
235 break;
236 }
237 else if (LowlitClipButton::HitTest<ClipButtonId::Speed>(
238 { *clip, zoomInfo, rect }, mousePoint))
239 {
240 results.push_back(AssignUIHandlePtr(
242 std::make_shared<ClipPitchAndSpeedButtonHandle>(
244 mFocusInterval = it;
245 break;
246 }
248 *clip, zoomInfo, state.rect, mousePoint))
249 {
250 results.push_back(AssignUIHandlePtr(
252 std::make_shared<WaveTrackAffordanceHandle>(track, clip)));
253 mFocusInterval = it;
254 break;
255 }
256 }
257
258 const auto& settings = ProjectSettings::Get(*pProject);
259 const auto currentTool = settings.GetTool();
260 if (currentTool == ToolCodes::multiTool || currentTool == ToolCodes::selectTool)
261 {
262 results.push_back(
264 mSelectHandle, state, pProject,
265 WaveChannelView::GetFirst(*track).shared_from_this()
266 )
267 );
268 }
269
270 return results;
271}
static Settings & settings()
Definition: TrackInfo.cpp:51
std::shared_ptr< Subclass > AssignUIHandlePtr(std::weak_ptr< Subclass > &holder, const std::shared_ptr< Subclass > &pNew)
Definition: UIHandle.h:164
Track & SubstitutePendingChangedTrack(Track &track) const
static PendingTracks & Get(AudacityProject &project)
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 ClipTimes &clip, const ZoomInfo &zoomInfo, const wxRect &rect, const wxPoint &pos)
static WaveChannelView & GetFirst(WaveTrack &wt)
Get the view of the first channel.
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(), PendingTracks::Get(), ProjectSettings::Get(), WaveChannelView::GetFirst(), 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, TrackPanelMouseState::state, and PendingTracks::SubstitutePendingChangedTrack().

Here is the call graph for this function:

◆ IsIntervalVisible()

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

Definition at line 359 of file WaveTrackAffordanceControls.cpp.

360{
361 return std::find(mVisibleIntervals.begin(),
362 mVisibleIntervals.end(),
363 it) != mVisibleIntervals.end();
364}

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

495{
496 auto keyCode = event.GetKeyCode();
497
498 if (mTextEditHelper)
499 {
500 if (!mTextEditHelper->OnKeyDown(keyCode, event.GetModifiers(), project)
502 event.Skip();
503
505 }
507}
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 516 of file WaveTrackAffordanceControls.cpp.

517{
518 return ExitTextEditing();
519}

References ExitTextEditing().

Here is the call graph for this function:

◆ MakeTextEditHelper()

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

Definition at line 701 of file WaveTrackAffordanceControls.cpp.

702{
703 auto helper = std::make_shared<TextEditHelper>(shared_from_this(), text, mClipNameFont);
704 helper->SetTextColor(theTheme.Colour(clrClipNameText));
705 helper->SetTextSelectionColor(theTheme.Colour(clrClipNameTextSelection));
706 return helper;
707}

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

622{
623 auto& viewInfo = ViewInfo::Get(*project);
624 if (mTextEditHelper)
625 {
626 if (auto interval = *mEditedInterval)
627 {
628 auto affordanceRect = ClipParameters::GetClipRect(*interval, viewInfo, event.rect);
629 if (!affordanceRect.Contains(event.event.GetPosition()))
630 return ExitTextEditing();
631 }
632 }
633 else if (auto interval = *mFocusInterval)
634 {
635 if (event.event.LeftDClick())
636 {
637 auto affordanceRect = ClipParameters::GetClipRect(*interval, viewInfo, event.rect);
638 if (affordanceRect.Contains(event.event.GetPosition()) &&
640 {
641 event.event.Skip(false);
643 }
644 }
645 }
647}
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 674 of file WaveTrackAffordanceControls.cpp.

676{
677 const auto [track, it] = SelectedIntervalOfFocusedTrack(project);
678
679 if (track != FindTrack())
680 return;
681
682 auto interval = *it;
683
684 if (!interval || !interval->HasPitchOrSpeed())
685 return;
686
688 [track = track, interval = interval](const ProgressReporter& progress) {
689 track->ApplyPitchAndSpeed(
690 { { interval->GetPlayStartTime(), interval->GetPlayEndTime() } },
691 progress);
692 },
693 XO("Applying..."));
694
696 XO("Rendered time-stretched audio"), XO("Render"));
697
699}
XO("Cut/Copy/Paste")
std::function< void(double)> ProgressReporter
Definition: Track.h:48
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)
void SelectClip(AudacityProject &project, const WaveTrack::Interval &clip)
std::pair< std::shared_ptr< WaveTrack >, ChannelGroup::IntervalIterator< WaveTrack::Interval > > SelectedIntervalOfFocusedTrack(AudacityProject &project, bool wholeInterval=true)

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

Here is the call graph for this function:

◆ OnSelectionChange()

void WaveTrackAffordanceControls::OnSelectionChange ( NotifyingSelectedRegionMessage  )
private

Definition at line 561 of file WaveTrackAffordanceControls.cpp.

562{
564}

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

546{
547}

◆ OnTextCopy()

bool WaveTrackAffordanceControls::OnTextCopy ( AudacityProject project)

Definition at line 581 of file WaveTrackAffordanceControls.cpp.

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

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

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

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

536{
538}

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

522{
523 if (auto interval = *mEditedInterval)
524 {
525 if (text != interval->GetName()) {
526 interval->SetName(text);
527
528 ProjectHistory::Get(*project).PushState(XO("Modified Clip Name"),
529 XO("Clip Name Edit"));
530 }
531 }
533}

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

541{
542 //Nothing to do
543}

◆ OnTextPaste()

bool WaveTrackAffordanceControls::OnTextPaste ( AudacityProject project)

Definition at line 601 of file WaveTrackAffordanceControls.cpp.

602{
603 if (mTextEditHelper)
604 {
605 mTextEditHelper->PasteSelectedText(project);
606 return true;
607 }
608 return false;
609}

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

612{
613 if (mTextEditHelper)
614 {
615 mTextEditHelper->SelectAll();
616 return true;
617 }
618 return false;
619}

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

556{
559}
const Type mType
Definition: Track.h:837
@ SELECTION_CHANGE
Posted when the set of selected tracks changes.
Definition: Track.h:806

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

550{
551 mTextEditHelper.reset();
552 mEditedInterval = {};
553}

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

367{
368 bool useDialog{ false };
369 gPrefs->Read(wxT("/GUI/DialogForNameNewLabel"), &useDialog, false);
370
371 auto interval = *it;
372 if(!interval)
373 return false;
374
375 if (useDialog)
376 {
378 auto oldName = interval->GetName();
379 Command.mName = oldName;
380 auto result = Command.PromptUser(project);
381 if (result && Command.mName != oldName)
382 {
383 interval->SetName(Command.mName);
384 ProjectHistory::Get(project).PushState(XO("Modified Clip Name"),
385 XO("Clip Name Edit"));
386 }
387 }
388 else if(it != mEditedInterval)
389 {
390 if(!IsIntervalVisible(it))
391 return false;
392
393 if (mTextEditHelper)
394 mTextEditHelper->Finish(&project);
395
396 mEditedInterval = it;
397 mTextEditHelper = MakeTextEditHelper(interval->GetName());
398 }
399
400 return true;
401}
wxT("CloseDown"))
audacity::BasicSettings * gPrefs
Definition: Prefs.cpp:68
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(), 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 649 of file WaveTrackAffordanceControls.cpp.

650{
651 auto [track, it] = SelectedIntervalOfFocusedTrack(project);
652 if(track != FindTrack())
653 return;
655}

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

659{
660 constexpr auto wholeInterval = false;
661 auto [track, it] = SelectedIntervalOfFocusedTrack(project, wholeInterval);
662
663 if (track != FindTrack())
664 return;
665
666 auto interval = *it;
667
668 if (!interval)
669 return;
670
672}
static PitchAndSpeedDialog & Get(AudacityProject &project)
PitchAndSpeedDialog & SetFocus(const std::optional< PitchAndSpeedDialogGroup > &group)
PitchAndSpeedDialog & Retarget(const std::shared_ptr< WaveTrack > &track, const WaveTrack::IntervalHolder &wideClip)

References CommonTrackPanelCell::FindTrack(), PitchAndSpeedDialog::Get(), project, PitchAndSpeedDialog::Retarget(), anonymous_namespace{WaveTrackAffordanceControls.cpp}::SelectedIntervalOfFocusedTrack(), and PitchAndSpeedDialog::SetFocus().

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: