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

#include <WaveTrackView.h>

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

Public Types

using Display = WaveTrackViewConstants::Display
 
- Public Types inherited from TrackView
enum  : unsigned { DefaultHeight = 150 }
 
using Refinement = std::vector< std::pair< wxCoord, std::shared_ptr< TrackView > > >
 
- Public Types inherited from ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >
using DataType = ClientData
 
using DataPointer = Pointer< ClientData >
 
using DataFactory = std::function< DataPointer(Host &) >
 Type of function from which RegisteredFactory is constructed; it builds attachments. More...
 

Public Member Functions

 WaveTrackView (const std::shared_ptr< Track > &pTrack, size_t channel)
 Construct a view of one channel. More...
 
 ~WaveTrackView () override
 
size_t GetChannel () const
 
void CopyTo (Track &track) const override
 Copy state, for undo/redo purposes. More...
 
std::shared_ptr< TrackVRulerControlsDoGetVRulerControls () 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...
 
std::vector< WaveTrackSubView::TypeGetDisplays () const
 
void SetDisplay (Display display, bool exclusive=true)
 
const WaveTrackSubViewPlacementsSavePlacements () const
 
void RestorePlacements (const WaveTrackSubViewPlacements &placements)
 
bool ToggleSubView (Display id)
 
std::vector< std::shared_ptr< WaveTrackSubView > > GetAllSubViews ()
 
wxCoord GetLastHeight () const
 
bool GetMultiView () const
 
void SetMultiView (bool value)
 
std::weak_ptr< WaveClipGetSelectedClip ()
 
Refinement GetSubViews (const wxRect *rect=nullptr)
 
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
 
bool CutSelectedText (AudacityProject &project)
 
bool CopySelectedText (AudacityProject &project)
 
bool PasteText (AudacityProject &project)
 
bool SelectAllText (AudacityProject &project)
 
- Public Member Functions inherited from CommonTrackView
std::shared_ptr< TrackPanelCellContextMenuDelegate () override
 
std::vector< UIHandlePtrHitTest (const TrackPanelMouseState &, const AudacityProject *pProject) final override
 
void TimeShiftHitTest ()
 
virtual int GetMinimizedHeight () const override
 
 TrackView (const std::shared_ptr< Track > &pTrack)
 
- Public Member Functions inherited from TrackView
 TrackView (const std::shared_ptr< Track > &pTrack)
 
virtual ~TrackView ()=0
 
void CopyTo (Track &track) const override
 Copy state, for undo/redo purposes. More...
 
bool GetMinimized () const
 
void SetMinimized (bool minimized)
 
int GetCumulativeHeightBefore () const
 
int GetExpandedHeight () const
 
virtual int GetMinimizedHeight () const =0
 
int GetHeight () const
 
void SetCumulativeHeightBefore (int y)
 Set cached value dependent on position within the track list. More...
 
void SetExpandedHeight (int height)
 
std::shared_ptr< TrackVRulerControlsGetVRulerControls ()
 
std::shared_ptr< const TrackVRulerControlsGetVRulerControls () const
 
virtual std::shared_ptr< CommonTrackCellGetAffordanceControls ()
 
void WriteXMLAttributes (XMLWriter &) const override
 Serialize persistent attributes. More...
 
bool HandleXMLAttribute (const std::string_view &attr, const XMLAttributeValueView &valueView) override
 Deserialize an attribute, returning true if recognized. More...
 
virtual Refinement GetSubViews (const wxRect &rect)
 
virtual bool IsSpectral () const
 
virtual void DoSetMinimized (bool isMinimized)
 
- Public Member Functions inherited from CommonTrackCell
 CommonTrackCell (const std::shared_ptr< Track > &pTrack)
 
 ~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 &) PROHIBITED
 
TrackPanelCelloperator= (const TrackPanelCell &) PROHIBITED
 
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 ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >
 ~Site ()
 
 Site ()
 
 Site (const Site &other)
 
Siteoperator= (const Site &other)
 
 Site (Site &&other)
 
Siteoperator= (Site &&other)
 
size_t size () const
 How many attachment pointers are in the Site. More...
 
template<typename Subclass = ClientData>
Subclass & Get (const RegisteredFactory &key)
 Get reference to an attachment, creating on demand if not present, down-cast it to Subclass. More...
 
template<typename Subclass = const ClientData>
auto Get (const RegisteredFactory &key) const -> std::enable_if_t< std::is_const< Subclass >::value, Subclass & >
 Get reference to an attachment, creating on demand if not present, down-cast it to Subclass. More...
 
template<typename Subclass = ClientData>
Subclass * Find (const RegisteredFactory &key)
 Get a (bare) pointer to an attachment, or null, down-cast it to Subclass *; will not create on demand. More...
 
template<typename Subclass = const ClientData>
auto Find (const RegisteredFactory &key) const -> std::enable_if_t< std::is_const< Subclass >::value, Subclass * >
 Get a (bare) pointer to an attachment, or null, down-cast it to Subclass *; will not create on demand. More...
 
template<typename ReplacementPointer >
void Assign (const RegisteredFactory &key, ReplacementPointer &&replacement)
 Reassign Site's pointer to ClientData. More...
 

Static Public Member Functions

static WaveTrackViewGet (WaveTrack &track)
 
static const WaveTrackViewGet (const WaveTrack &track)
 
static WaveTrackViewFind (WaveTrack *pTrack)
 
static const WaveTrackViewFind (const WaveTrack *pTrack)
 
static std::pair< bool, std::vector< UIHandlePtr > > DoDetailedHitTest (const TrackPanelMouseState &state, const AudacityProject *pProject, int currentTool, bool bMultiTool, const std::shared_ptr< WaveTrack > &wt, CommonTrackView &view)
 
static bool ClipDetailsVisible (const WaveClip &clip, const ZoomInfo &zoomInfo, const wxRect &viewRect)
 
static wxRect ClipHitTestArea (const WaveClip &clip, const ZoomInfo &zoomInfo, const wxRect &viewRect)
 
static bool HitTest (const WaveClip &clip, const ZoomInfo &zoomInfo, const wxRect &rect, const wxPoint &pos)
 
- Static Public Member Functions inherited from CommonTrackView
static void GetEnvelopeValues (const Envelope &env, double aligned_time, double sampleDur, double *buffer, int bufferLen, int leftOffset, const ZoomInfo &zoomInfo)
 Get many envelope points for pixel columns at once, but don't assume uniform time per pixel. More...
 
- Static Public Member Functions inherited from TrackView
static int GetTrackHeight (const Track *pTrack)
 
static int GetChannelGroupHeight (const Track *pTrack)
 
static int GetCumulativeHeight (const Track *pTrack)
 
static int GetTotalHeight (const TrackList &list)
 
static TrackViewGet (Track &)
 
static const TrackViewGet (const Track &)
 
static TrackViewFind (Track *)
 
static const TrackViewFind (const Track *)
 
- 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)
 
- Static Public Member Functions inherited from ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >
static size_t slots ()
 How many static factories have been registered with this specialization of Site. More...
 

Static Public Attributes

static constexpr int kChannelSeparatorThickness { 8 }
 

Private Member Functions

 WaveTrackView (const WaveTrackView &)=delete
 
WaveTrackViewoperator= (const WaveTrackView &)=delete
 
void BuildSubViews () const
 
void DoSetDisplay (Display display, bool exclusive=true)
 
bool SelectNextClip (ViewInfo &viewInfo, AudacityProject *project, bool forward)
 
void Draw (TrackPanelDrawingContext &context, const wxRect &rect, unsigned iPass) override
 
std::vector< UIHandlePtrDetailedHitTest (const TrackPanelMouseState &state, const AudacityProject *pProject, int currentTool, bool bMultiTool) override
 
Refinement GetSubViews (const wxRect &rect) override
 
std::shared_ptr< CommonTrackCellGetAffordanceControls () override
 
void DoSetMinimized (bool minimized) override
 
WaveTrackSubViewPlacementsDoGetPlacements ()
 
const WaveTrackSubViewPlacementsDoGetPlacements () const
 
bool & DoGetMultiView ()
 
bool DoGetMultiView () const
 
std::shared_ptr< CommonTrackCellDoGetAffordance (const std::shared_ptr< Track > &track)
 

Private Attributes

wxCoord mLastHeight {}
 
std::shared_ptr< CommonTrackCellmpAffordanceCellControl
 
std::weak_ptr< TrackPanelCellmKeyEventDelegate
 
std::weak_ptr< WaveTrackAffordanceHandlemAffordanceHandle
 
const size_t mChannel
 

Additional Inherited Members

- Public Attributes inherited from CommonTrackView
std::weak_ptr< TimeShiftHandlemTimeShiftHandle
 
virtual std::vector< UIHandlePtrDetailedHitTest (const TrackPanelMouseState &, const AudacityProject *pProject, int currentTool, bool bMultiTool)=0
 
virtual std::shared_ptr< TrackVRulerControlsDoGetVRulerControls ()=0
 
- 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
 
- Protected Member Functions inherited from ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >
template<typename Function >
void ForEach (const Function &function)
 Invoke function on each ClientData object that has been created in this. More...
 
template<typename Function >
void ForEach (const Function &function) const
 Invoke function on each ClientData object that has been created in this. More...
 
template<typename Function >
ClientData * FindIf (const Function &function)
 Return pointer to first attachment in this that is not null and satisfies a predicate, or nullptr. More...
 
template<typename Function >
const ClientData * FindIf (const Function &function) const
 Return pointer to first attachment in this that is not null and satisfies a predicate, or nullptr. More...
 
void BuildAll ()
 For each RegisteredFactory, if the corresponding attachment is absent in this, build and store it. More...
 
- Protected Attributes inherited from CommonTrackView
std::weak_ptr< SelectHandlemSelectHandle
 
- Protected Attributes inherited from TrackView
std::shared_ptr< TrackVRulerControlsmpVRulerControls
 

Detailed Description

Definition at line 98 of file WaveTrackView.h.

Member Typedef Documentation

◆ Display

Definition at line 108 of file WaveTrackView.h.

Constructor & Destructor Documentation

◆ WaveTrackView() [1/2]

WaveTrackView::WaveTrackView ( const WaveTrackView )
privatedelete

◆ WaveTrackView() [2/2]

WaveTrackView::WaveTrackView ( const std::shared_ptr< Track > &  pTrack,
size_t  channel 
)

Construct a view of one channel.

Parameters
channelwhich channel of a possibly wide wave track

Definition at line 922 of file WaveTrackView.cpp.

924 : CommonTrackView{ pTrack }
925 , mChannel{ channel }
926{
927}
const size_t mChannel

◆ ~WaveTrackView()

WaveTrackView::~WaveTrackView ( )
override

Definition at line 941 of file WaveTrackView.cpp.

942{
943}

Member Function Documentation

◆ BuildSubViews()

void WaveTrackView::BuildSubViews ( ) const
private

Definition at line 1737 of file WaveTrackView.cpp.

1738{
1739 if ( WaveTrackSubViews::size() == 0) {
1740 // On-demand steps that can't happen in the constructor
1741 auto pThis = const_cast<WaveTrackView*>( this );
1742 pThis->BuildAll();
1743 bool minimized = GetMinimized();
1744 pThis->WaveTrackSubViews::ForEach( [&]( WaveTrackSubView &subView ){
1745 subView.DoSetMinimized( minimized );
1746 } );
1747
1748 auto &placements = pThis->DoGetPlacements();
1749 if (placements.empty()) {
1750 placements.resize( WaveTrackSubViews::size() );
1751
1752 auto pTrack = pThis->FindTrack();
1753 auto display = TracksPrefs::ViewModeChoice();
1754 bool multi = (display == WaveTrackViewConstants::MultiView);
1755 if ( multi ) {
1756 pThis->SetMultiView( true );
1758 }
1759
1760 pThis->DoSetDisplay( display, !multi );
1761 }
1762 }
1763}
size_t size() const
How many attachment pointers are in the Site.
Definition: ClientData.h:251
void BuildAll()
For each RegisteredFactory, if the corresponding attachment is absent in this, build and store it.
Definition: ClientData.h:441
virtual void DoSetMinimized(bool isMinimized)
Definition: TrackView.cpp:141
bool GetMinimized() const
Definition: TrackView.h:52
static WaveTrackViewConstants::Display ViewModeChoice()
@ MultiView
"Multi" is special, not really a view type on par with the others.
static Display Default()
Return a preferred type.

References ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >::BuildAll(), WaveTrackSubViewType::Default(), TrackView::DoSetMinimized(), TrackView::GetMinimized(), WaveTrackViewConstants::MultiView, ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >::size(), and TracksPrefs::ViewModeChoice().

Referenced by DoSetMinimized(), GetAllSubViews(), GetDisplays(), and SetDisplay().

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

◆ CaptureKey()

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

Reimplemented from TrackPanelCell.

Definition at line 1281 of file WaveTrackView.cpp.

1282{
1283 unsigned result{ RefreshCode::RefreshNone };
1284 auto pTrack = static_cast<WaveTrack*>(FindTrack().get());
1285 for (auto pChannel : TrackList::Channels(pTrack)) {
1286 event.Skip(false);
1287 auto &waveTrackView = WaveTrackView::Get(*pChannel);
1288 // Give sub-views first chance to handle the event
1289 for (auto &subView : waveTrackView.GetSubViews()) {
1290 // Event defaults in skipped state which must be turned off explicitly
1291 wxASSERT(!event.GetSkipped());
1292 result |= subView.second->CaptureKey(event, viewInfo, pParent, project);
1293 if (!event.GetSkipped()) {
1294 // sub view wants it
1295 mKeyEventDelegate = subView.second;
1296 return result;
1297 }
1298 else
1299 event.Skip(false);
1300 }
1301
1302 if (auto affordance = waveTrackView.GetAffordanceControls()) {
1303 result |= affordance->CaptureKey(event, viewInfo, pParent, project);
1304 if (!event.GetSkipped()) {
1305 mKeyEventDelegate = affordance;
1306 return result;
1307 }
1308 }
1309
1310 event.Skip(false);
1311 }
1312 switch (event.GetKeyCode())
1313 {
1314 case WXK_TAB:
1315 break;
1316 default:
1318 event, viewInfo, pParent, project);
1319 break;
1320 };
1321 if (!event.GetSkipped()) {
1322 mKeyEventDelegate = shared_from_this();
1323 }
1324
1325 return result;
1326}
std::shared_ptr< Track > FindTrack()
static auto Channels(TrackType *pTrack) -> TrackIterRange< TrackType >
Definition: Track.h:1114
virtual unsigned CaptureKey(wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent, AudacityProject *project)
A Track that contains audio waveform data.
Definition: WaveTrack.h:54
std::weak_ptr< TrackPanelCell > mKeyEventDelegate
static WaveTrackView & Get(WaveTrack &track)

References TrackPanelCell::CaptureKey(), TrackList::Channels(), CommonTrackPanelCell::FindTrack(), Get(), mKeyEventDelegate, and RefreshCode::RefreshNone.

Here is the call graph for this function:

◆ Char()

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

Reimplemented from TrackPanelCell.

Definition at line 1352 of file WaveTrackView.cpp.

1353{
1354 unsigned result{ RefreshCode::RefreshNone };
1355 if (auto delegate = mKeyEventDelegate.lock()) {
1356 if (auto pWaveTrackView = dynamic_cast<WaveTrackView*>(delegate.get()))
1357 result |= pWaveTrackView->CommonTrackView::Char(
1358 event, viewInfo, pParent, project);
1359 else
1360 result |= delegate->Char(event, viewInfo, pParent, project);
1361 }
1362 else
1363 event.Skip();
1364
1365 return result;
1366}

References mKeyEventDelegate, and RefreshCode::RefreshNone.

◆ ClipDetailsVisible()

bool WaveTrackView::ClipDetailsVisible ( const WaveClip clip,
const ZoomInfo zoomInfo,
const wxRect &  viewRect 
)
static

Definition at line 1411 of file WaveTrackView.cpp.

1412{
1413 //Do not fold clips to line at sample zoom level, as
1414 //it may become impossible to 'unfold' it when clip is trimmed
1415 //to a single sample
1416 bool showSamples{ false };
1417 auto clipRect = ClipParameters::GetClipRect(clip, zoomInfo, viewRect, &showSamples);
1418 return showSamples || clipRect.width >= kClipDetailedViewMinimumWidth;
1419}
constexpr int kClipDetailedViewMinimumWidth
static wxRect GetClipRect(const WaveClip &clip, const ZoomInfo &zoomInfo, const wxRect &viewRect, bool *outShowSamples=nullptr)

References ClipParameters::GetClipRect(), and kClipDetailedViewMinimumWidth.

Referenced by WaveTrackAffordanceHandle::Click(), DoDetailedHitTest(), WaveTrackAffordanceControls::Draw(), anonymous_namespace{SpectrumView.cpp}::DrawClipSpectrum(), anonymous_namespace{WaveformView.cpp}::DrawClipWaveform(), and WaveClipTrimHandle::HitAnywhere().

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

◆ ClipHitTestArea()

wxRect WaveTrackView::ClipHitTestArea ( const WaveClip clip,
const ZoomInfo zoomInfo,
const wxRect &  viewRect 
)
static

Definition at line 1421 of file WaveTrackView.cpp.

1422{
1423 bool showSamples{ false };
1424 auto clipRect = ClipParameters::GetClipRect(clip, zoomInfo, viewRect, &showSamples);
1425 if (showSamples || clipRect.width >= kClipDetailedViewMinimumWidth)
1426 return clipRect;
1427
1428 return clipRect.Inflate(2, 0);
1429}

References ClipParameters::GetClipRect(), and kClipDetailedViewMinimumWidth.

Referenced by HitTest().

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

◆ CopySelectedText()

bool WaveTrackView::CopySelectedText ( AudacityProject project)

Definition at line 1396 of file WaveTrackView.cpp.

1397{
1398 for (auto channel : TrackList::Channels(FindTrack().get()))
1399 {
1400 auto& view = TrackView::Get(*channel);
1401 if (auto affordance
1402 = std::dynamic_pointer_cast<WaveTrackAffordanceControls>(view.GetAffordanceControls()))
1403 {
1404 if (affordance->OnTextCopy(project))
1405 return true;
1406 }
1407 }
1408 return false;
1409}
static TrackView & Get(Track &)
Definition: TrackView.cpp:69

References TrackList::Channels(), CommonTrackPanelCell::FindTrack(), and TrackView::Get().

Here is the call graph for this function:

◆ CopyTo()

void WaveTrackView::CopyTo ( Track track) const
overridevirtual

Copy state, for undo/redo purposes.

Reimplemented from TrackAttachment.

Definition at line 945 of file WaveTrackView.cpp.

946{
947 TrackView::CopyTo( track );
948 auto &other = TrackView::Get( track );
949
950 if ( const auto pOther = dynamic_cast< WaveTrackView* >( &other ) ) {
951 // only these fields are important to preserve in undo/redo history
952 pOther->RestorePlacements( SavePlacements() );
953 pOther->DoGetMultiView() = DoGetMultiView();
954
955 auto srcSubViewsPtrs = const_cast<WaveTrackView*>( this )->GetAllSubViews();
956 auto destSubViewsPtrs = const_cast<WaveTrackView*>( pOther )->GetAllSubViews();
957 wxASSERT(srcSubViewsPtrs.size() == destSubViewsPtrs.size());
958
959 for(auto i = 0; i != srcSubViewsPtrs.size(); i++){
960 srcSubViewsPtrs[i]->CopyToSubView(destSubViewsPtrs[i].get());
961 }
962 }
963}
void CopyTo(Track &track) const override
Copy state, for undo/redo purposes.
Definition: TrackView.cpp:52
std::vector< std::shared_ptr< WaveTrackSubView > > GetAllSubViews()
const WaveTrackSubViewPlacements & SavePlacements() const
bool & DoGetMultiView()

References TrackView::CopyTo(), DoGetMultiView(), TrackView::Get(), GetAllSubViews(), and SavePlacements().

Here is the call graph for this function:

◆ CutSelectedText()

bool WaveTrackView::CutSelectedText ( AudacityProject project)

Definition at line 1381 of file WaveTrackView.cpp.

1382{
1383 for (auto channel : TrackList::Channels(FindTrack().get()))
1384 {
1385 auto& view = TrackView::Get(*channel);
1386 if (auto affordance
1387 = std::dynamic_pointer_cast<WaveTrackAffordanceControls>(view.GetAffordanceControls()))
1388 {
1389 if (affordance->OnTextCut(project))
1390 return true;
1391 }
1392 }
1393 return false;
1394}

References TrackList::Channels(), CommonTrackPanelCell::FindTrack(), and TrackView::Get().

Here is the call graph for this function:

◆ DetailedHitTest()

std::vector< UIHandlePtr > WaveTrackView::DetailedHitTest ( const TrackPanelMouseState state,
const AudacityProject pProject,
int  currentTool,
bool  bMultiTool 
)
overrideprivatevirtual

Implements CommonTrackView.

Definition at line 965 of file WaveTrackView.cpp.

968{
969 // should not come here any more, delegation to sub-view instead
970 wxASSERT( false );
971 return {};
972}

◆ DoDetailedHitTest()

std::pair< bool, std::vector< UIHandlePtr > > WaveTrackView::DoDetailedHitTest ( const TrackPanelMouseState state,
const AudacityProject pProject,
int  currentTool,
bool  bMultiTool,
const std::shared_ptr< WaveTrack > &  wt,
CommonTrackView view 
)
static

Definition at line 975 of file WaveTrackView.cpp.

980{
981 // common hit-testing for different sub-view types, to help implement their
982 // DetailedHitTest()
983
984 // This is the only override of Track::DetailedHitTest that still
985 // depends on the state of the Tools toolbar.
986 // If that toolbar were eliminated, this could simplify to a sequence of
987 // hit test routines describable by a table.
988
989 std::vector<UIHandlePtr> results;
990
991 const auto& viewInfo = ViewInfo::Get(*pProject);
992
993 for (auto& clip : pTrack->GetClips())
994 {
995 if (!WaveTrackView::ClipDetailsVisible(*clip, viewInfo, st.rect)
996 && HitTest(*clip, viewInfo, st.rect, st.state.GetPosition()))
997 {
998 auto &waveTrackView = WaveTrackView::Get(*pTrack);
999 results.push_back(
1001 waveTrackView.mAffordanceHandle,
1002 std::make_shared<WaveTrackAffordanceHandle>(pTrack, clip)
1003 )
1004 );
1005 }
1006 }
1007
1008 if (bMultiTool && st.state.CmdDown()) {
1009 // Ctrl modifier key in multi-tool overrides everything else
1010 // (But this does not do the time shift constrained to the vertical only,
1011 // which is what happens when you hold Ctrl in the Time Shift tool mode)
1012 auto result = TimeShiftHandle::HitAnywhere(
1013 view.mTimeShiftHandle, pTrack, false);
1014 if (result)
1015 results.push_back(result);
1016 return { true, results };
1017 }
1018
1019 return { false, results };
1020}
std::shared_ptr< Subclass > AssignUIHandlePtr(std::weak_ptr< Subclass > &holder, const std::shared_ptr< Subclass > &pNew)
Definition: UIHandle.h:151
std::weak_ptr< TimeShiftHandle > mTimeShiftHandle
static UIHandlePtr HitAnywhere(std::weak_ptr< TimeShiftHandle > &holder, const std::shared_ptr< Track > &pTrack, bool gripHit)
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:235
static bool HitTest(const WaveClip &clip, const ZoomInfo &zoomInfo, const wxRect &rect, const wxPoint &pos)
static bool ClipDetailsVisible(const WaveClip &clip, const ZoomInfo &zoomInfo, const wxRect &viewRect)

References AssignUIHandlePtr(), ClipDetailsVisible(), ViewInfo::Get(), Get(), TimeShiftHandle::HitAnywhere(), HitTest(), CommonTrackView::mTimeShiftHandle, TrackPanelMouseState::rect, and TrackPanelMouseState::state.

Referenced by WaveTrackSubView::DoDetailedHitTest().

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

◆ DoGetAffordance()

std::shared_ptr< CommonTrackCell > WaveTrackView::DoGetAffordance ( const std::shared_ptr< Track > &  track)
private

Definition at line 1500 of file WaveTrackView.cpp.

1501{
1502 if (mpAffordanceCellControl == nullptr)
1503 mpAffordanceCellControl = std::make_shared<WaveTrackAffordanceControls>(track);
1505}
std::shared_ptr< CommonTrackCell > mpAffordanceCellControl

References mpAffordanceCellControl.

Referenced by GetAffordanceControls().

Here is the caller graph for this function:

◆ DoGetMultiView() [1/2]

bool & WaveTrackView::DoGetMultiView ( )
private

Definition at line 94 of file WaveTrackView.cpp.

95{
96 auto &waveTrack = *std::dynamic_pointer_cast<WaveTrack>(FindTrack());
97 return PlacementArray::Get(waveTrack).mMultiView;
98}
Services * Get()
Fetch the global instance, or nullptr if none is yet installed.
Definition: BasicUI.cpp:196

References CommonTrackPanelCell::FindTrack(), and BasicUI::Get().

Referenced by CopyTo(), and DoGetMultiView().

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

◆ DoGetMultiView() [2/2]

bool WaveTrackView::DoGetMultiView ( ) const
private

Definition at line 100 of file WaveTrackView.cpp.

101{
102 return const_cast<WaveTrackView&>(*this).DoGetMultiView();
103}

References DoGetMultiView().

Here is the call graph for this function:

◆ DoGetPlacements() [1/2]

WaveTrackSubViewPlacements & WaveTrackView::DoGetPlacements ( )
private

Definition at line 83 of file WaveTrackView.cpp.

84{
85 auto &waveTrack = *std::dynamic_pointer_cast<WaveTrack>(FindTrack());
86 return PlacementArray::Get(waveTrack).mPlacements;
87}

References CommonTrackPanelCell::FindTrack(), and BasicUI::Get().

Referenced by DoGetPlacements(), DoSetDisplay(), GetDisplays(), and ToggleSubView().

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

◆ DoGetPlacements() [2/2]

const WaveTrackSubViewPlacements & WaveTrackView::DoGetPlacements ( ) const
private

Definition at line 89 of file WaveTrackView.cpp.

90{
91 return const_cast<WaveTrackView&>(*this).DoGetPlacements();
92}
WaveTrackSubViewPlacements & DoGetPlacements()

References DoGetPlacements().

Here is the call graph for this function:

◆ DoGetVRulerControls()

std::shared_ptr< TrackVRulerControls > WaveTrackView::DoGetVRulerControls ( )
overridevirtual

Implements TrackView.

Definition at line 1515 of file WaveTrackView.cpp.

1516{
1517 // This should never be called because of delegation to the spectrum or
1518 // waveform sub-view
1519 wxASSERT( false );
1520 return {};
1521}

◆ DoSetDisplay()

void WaveTrackView::DoSetDisplay ( Display  display,
bool  exclusive = true 
)
private

Definition at line 1110 of file WaveTrackView.cpp.

1111{
1112 // Some generality here anticipating more than two views.
1113 // The order of sub-views in the array is not specified, so make it definite
1114 // by sorting by the view type constants.
1115 size_t ii = 0;
1116 std::vector< std::pair< WaveTrackViewConstants::Display, size_t > > pairs;
1117 WaveTrackSubViews::ForEach( [&pairs, &ii]( WaveTrackSubView &subView ){
1118 pairs.push_back( { subView.SubViewType().id, ii++ } );
1119 } );
1120 std::sort( pairs.begin(), pairs.end() );
1121
1122 int jj = 1;
1123 auto &placements = DoGetPlacements();
1124 for ( const auto &pair : pairs ) {
1125 auto &placement = placements[ pair.second ];
1126 if (pair.first == display) {
1127 // 0 for first view
1128 placement = { 0, 1.0 };
1129 }
1130 else if( exclusive )
1131 // -1 for not displayed
1132 placement = { -1, 0.0 };
1133 else
1134 // positions other than the first.
1135 // (Note that the fractions in the placement don't need to be
1136 // denominated to 1. Just make them all equal to get an equal
1137 // partitioning of the sub-views.)
1138 placement = { jj++, 1.0 };
1139 }
1140}
void ForEach(const Function &function)
Invoke function on each ClientData object that has been created in this.
Definition: ClientData.h:380
virtual const Type & SubViewType() const =0

References DoGetPlacements(), ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >::ForEach(), and WaveTrackSubView::SubViewType().

Referenced by SetDisplay().

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

◆ DoSetMinimized()

void WaveTrackView::DoSetMinimized ( bool  minimized)
overrideprivatevirtual

Reimplemented from TrackView.

Definition at line 1489 of file WaveTrackView.cpp.

1490{
1491 BuildSubViews();
1492
1493 // May come here. Invoke also on sub-views.
1494 TrackView::DoSetMinimized( minimized );
1495 WaveTrackSubViews::ForEach( [minimized](WaveTrackSubView &subView){
1496 subView.DoSetMinimized( minimized );
1497 } );
1498}
void BuildSubViews() const

References BuildSubViews(), TrackView::DoSetMinimized(), and ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >::ForEach().

Here is the call graph for this function:

◆ Draw()

void WaveTrackView::Draw ( TrackPanelDrawingContext context,
const wxRect &  rect,
unsigned  iPass 
)
overrideprivatevirtual

Reimplemented from TrackPanelDrawable.

Definition at line 1765 of file WaveTrackView.cpp.

1768{
1769 // Should not come here, drawing is now delegated to sub-views
1770 wxASSERT( false );
1771
1772 CommonTrackView::Draw( context, rect, iPass );
1773}
virtual void Draw(TrackPanelDrawingContext &context, const wxRect &rect, unsigned iPass)

References TrackPanelDrawable::Draw().

Here is the call graph for this function:

◆ Find() [1/2]

const WaveTrackView * WaveTrackView::Find ( const WaveTrack pTrack)
static

Definition at line 917 of file WaveTrackView.cpp.

918{
919 return Find( const_cast<WaveTrack*>( pTrack ) );
920}
static WaveTrackView * Find(WaveTrack *pTrack)

References Find().

Here is the call graph for this function:

◆ Find() [2/2]

WaveTrackView * WaveTrackView::Find ( WaveTrack pTrack)
static

Definition at line 912 of file WaveTrackView.cpp.

913{
914 return static_cast< WaveTrackView* >( TrackView::Find( pTrack ) );
915}
static TrackView * Find(Track *)
Definition: TrackView.cpp:79

References TrackView::Find().

Referenced by Find(), NyquistEffect::Init(), and NyquistEffect::ProcessOne().

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

◆ Get() [1/2]

const WaveTrackView & WaveTrackView::Get ( const WaveTrack track)
static

Definition at line 907 of file WaveTrackView.cpp.

908{
909 return Get( const_cast<WaveTrack&>( track ) );
910}

References Get().

Here is the call graph for this function:

◆ Get() [2/2]

WaveTrackView & WaveTrackView::Get ( WaveTrack track)
static

Definition at line 902 of file WaveTrackView.cpp.

903{
904 return static_cast< WaveTrackView& >( TrackView::Get( track ) );
905}

References TrackView::Get().

Referenced by Append(), SetTrackVisualsCommand::ApplyInner(), CaptureKey(), WaveformPrefs::Commit(), DoDetailedHitTest(), anonymous_namespace{EditMenus.cpp}::DoPasteText(), for(), Get(), anonymous_namespace{EditMenus.cpp}::OnCopy(), anonymous_namespace{EditMenus.cpp}::OnCut(), WaveTrackMenuTable::OnMergeStereo(), WaveTrackMenuTable::OnMultiView(), SelectActions::Handler::OnSelectAll(), WaveTrackMenuTable::OnSetDisplay(), SpectrumPrefs::Rollback(), SpectrumPrefs::SpectrumPrefs(), and SubViewAdjuster::UpdateViews().

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

◆ GetAffordanceControls()

std::shared_ptr< CommonTrackCell > WaveTrackView::GetAffordanceControls ( )
overrideprivatevirtual

Reimplemented from TrackView.

Definition at line 1479 of file WaveTrackView.cpp.

1480{
1481 auto track = FindTrack();
1482 if (!track->IsAlignedWithLeader())
1483 {
1484 return DoGetAffordance(track);
1485 }
1486 return {};
1487}
std::shared_ptr< CommonTrackCell > DoGetAffordance(const std::shared_ptr< Track > &track)

References DoGetAffordance(), and CommonTrackPanelCell::FindTrack().

Referenced by GetSelectedClip().

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

◆ GetAllSubViews()

std::vector< std::shared_ptr< WaveTrackSubView > > WaveTrackView::GetAllSubViews ( )

Definition at line 1467 of file WaveTrackView.cpp.

1468{
1469 BuildSubViews();
1470
1471 std::vector< std::shared_ptr< WaveTrackSubView > > results;
1473 results.push_back( std::static_pointer_cast<WaveTrackSubView>(
1474 subView.shared_from_this() ) );
1475 } );
1476 return results;
1477}

References BuildSubViews(), and ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >::ForEach().

Referenced by CopyTo(), and SubViewAdjuster::SubViewAdjuster().

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

◆ GetChannel()

size_t WaveTrackView::GetChannel ( ) const
inline

Definition at line 122 of file WaveTrackView.h.

122{ return mChannel; }

◆ GetDisplays()

auto WaveTrackView::GetDisplays ( ) const

Definition at line 1022 of file WaveTrackView.cpp.

1024{
1025 BuildSubViews();
1026
1027 // Collect the display types of visible views and sort them by position
1028 using Pair = std::pair< int, WaveTrackSubView::Type >;
1029 std::vector< Pair > pairs;
1030 size_t ii = 0;
1031 const auto &placements = DoGetPlacements();
1032 WaveTrackSubViews::ForEach( [&]( const WaveTrackSubView &subView ){
1033 auto &placement = placements[ii];
1034 if ( placement.fraction > 0 )
1035 pairs.emplace_back( placement.index, subView.SubViewType() );
1036 ++ii;
1037 } );
1038 std::sort( pairs.begin(), pairs.end() );
1039 std::vector< WaveTrackSubView::Type > results;
1040 for ( const auto &pair : pairs )
1041 results.push_back( pair.second );
1042 return results;
1043}
std::pair< const char *, const char * > Pair

References BuildSubViews(), DoGetPlacements(), ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >::ForEach(), and WaveTrackSubView::SubViewType().

Referenced by ToggleSubView().

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

◆ GetLastHeight()

wxCoord WaveTrackView::GetLastHeight ( ) const
inline

Definition at line 158 of file WaveTrackView.h.

158{ return mLastHeight; }
wxCoord mLastHeight

Referenced by SubViewAdjustHandle::HitTest(), and SubViewRearrangeHandle::HitTest().

Here is the caller graph for this function:

◆ GetMultiView()

bool WaveTrackView::GetMultiView ( ) const
inline

Definition at line 160 of file WaveTrackView.h.

160{ return DoGetMultiView(); }

Referenced by SubViewAdjustHandle::HitTest(), and SubViewRearrangeHandle::HitTest().

Here is the caller graph for this function:

◆ GetSelectedClip()

std::weak_ptr< WaveClip > WaveTrackView::GetSelectedClip ( )

Definition at line 1728 of file WaveTrackView.cpp.

1729{
1730 if (auto affordance = std::dynamic_pointer_cast<WaveTrackAffordanceControls>(GetAffordanceControls()))
1731 {
1732 return affordance->GetSelectedClip();
1733 }
1734 return {};
1735}
std::shared_ptr< CommonTrackCell > GetAffordanceControls() override

References GetAffordanceControls().

Here is the call graph for this function:

◆ GetSubViews() [1/2]

auto WaveTrackView::GetSubViews ( const wxRect &  rect)
overrideprivatevirtual

Reimplemented from TrackView.

Definition at line 1207 of file WaveTrackView.cpp.

1208{
1209 return GetSubViews(&rect);
1210}
Refinement GetSubViews(const wxRect *rect=nullptr)

◆ GetSubViews() [2/2]

auto WaveTrackView::GetSubViews ( const wxRect *  rect = nullptr)

Definition at line 1212 of file WaveTrackView.cpp.

1213{
1214 BuildSubViews();
1215
1216 // Collect the visible views in the right sequence
1217 struct Item {
1218 int index; float fraction; std::shared_ptr< TrackView > pView;
1219 };
1220 std::vector< Item > items;
1221 size_t ii = 0;
1222 float total = 0;
1223 const auto &placements = DoGetPlacements();
1225 auto& placement = placements[ii];
1226 auto index = placement.index;
1227 auto fraction = placement.fraction;
1228 if (index >= 0 && fraction > 0.0)
1229 total += fraction,
1230 items.push_back({ index, fraction, subView.shared_from_this() });
1231 ++ii;
1232 });
1233 std::sort(items.begin(), items.end(), [](const Item& a, const Item& b) {
1234 return a.index < b.index;
1235 });
1236
1237 // Remove views we don't need
1238 auto begin = items.begin(), end = items.end(),
1239 newEnd = std::remove_if(begin, end,
1240 [](const Item& item) { return !item.pView; });
1241 items.erase(newEnd, end);
1242
1243 Refinement results;
1244
1245 if (rect != nullptr)
1246 {
1247 // Assign coordinates, redenominating to the total height,
1248 // storing integer values
1249 results.reserve(items.size());
1250 const auto top = rect->GetTop();
1251 const auto height = rect->GetHeight();
1252 float partial = 0;
1253 wxCoord lastCoord = 0;
1254 for (const auto& item : items) {
1255 wxCoord newCoord = top + (partial / total) * height;
1256 results.emplace_back(newCoord, item.pView);
1257 partial += item.fraction;
1258 }
1259
1260 // Cache for the use of sub-view dragging
1261 mLastHeight = height;
1262 }
1263 else
1264 {
1265 std::transform(items.begin(), items.end(), std::back_inserter(results), [](const auto& item) {
1266 return std::make_pair(0, item.pView);
1267 });
1268 }
1269
1270 return results;
1271}
std::vector< std::pair< wxCoord, std::shared_ptr< TrackView > > > Refinement
Definition: TrackView.h:104
auto end(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
Definition: PackedArray.h:159
auto begin(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
Definition: PackedArray.h:150

References PackedArray::begin(), PackedArray::end(), and ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >::ForEach().

Here is the call graph for this function:

◆ HitTest()

bool WaveTrackView::HitTest ( const WaveClip clip,
const ZoomInfo zoomInfo,
const wxRect &  rect,
const wxPoint &  pos 
)
static

Definition at line 1431 of file WaveTrackView.cpp.

1432{
1433 return ClipHitTestArea(clip, viewInfo, viewRect).Contains(pos);
1434}
static wxRect ClipHitTestArea(const WaveClip &clip, const ZoomInfo &zoomInfo, const wxRect &viewRect)

References ClipHitTestArea().

Referenced by DoDetailedHitTest(), WaveTrackAffordanceControls::HitTest(), WaveTrackShifter::HitTest(), and SubViewAdjustHandle::HitTest().

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

◆ KeyDown()

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

Reimplemented from TrackPanelCell.

Definition at line 1328 of file WaveTrackView.cpp.

1329{
1330 unsigned result{ RefreshCode::RefreshNone };
1331 if (auto delegate = mKeyEventDelegate.lock()) {
1332 if (auto pWaveTrackView = dynamic_cast<WaveTrackView*>(delegate.get()))
1333 {
1334 if (event.GetKeyCode() == WXK_TAB)
1335 {
1336 SelectNextClip(viewInfo, project, event.GetModifiers() != wxMOD_SHIFT);
1337 result |= RefreshCode::RefreshCell;
1338 }
1339 else
1340 result |= pWaveTrackView->CommonTrackView::KeyDown(
1341 event, viewInfo, pParent, project);
1342 }
1343 else
1344 result |= delegate->KeyDown(event, viewInfo, pParent, project);
1345 }
1346 else
1347 event.Skip();
1348
1349 return result;
1350}
bool SelectNextClip(ViewInfo &viewInfo, AudacityProject *project, bool forward)

References mKeyEventDelegate, RefreshCode::RefreshCell, RefreshCode::RefreshNone, and SelectNextClip().

Here is the call graph for this function:

◆ LoseFocus()

unsigned WaveTrackView::LoseFocus ( AudacityProject project)
overridevirtual

Reimplemented from TrackPanelCell.

Definition at line 1368 of file WaveTrackView.cpp.

1369{
1370 unsigned result = RefreshCode::RefreshNone;
1371 if (auto delegate = mKeyEventDelegate.lock()) {
1372 if (auto waveTrackView = dynamic_cast<WaveTrackView*>(delegate.get()))
1373 result = waveTrackView->CommonTrackView::LoseFocus(project);
1374 else
1375 result = delegate->LoseFocus(project);
1376 mKeyEventDelegate.reset();
1377 }
1378 return result;
1379}

References mKeyEventDelegate, and RefreshCode::RefreshNone.

◆ operator=()

WaveTrackView & WaveTrackView::operator= ( const WaveTrackView )
privatedelete

◆ PasteText()

bool WaveTrackView::PasteText ( AudacityProject project)

Definition at line 1436 of file WaveTrackView.cpp.

1437{
1438 for (auto channel : TrackList::Channels(FindTrack().get()))
1439 {
1440 auto& view = TrackView::Get(*channel);
1441 if (auto affordance
1442 = std::dynamic_pointer_cast<WaveTrackAffordanceControls>(view.GetAffordanceControls()))
1443 {
1444 if (affordance->OnTextPaste(project))
1445 return true;
1446 }
1447 }
1448 return false;
1449}

References TrackList::Channels(), CommonTrackPanelCell::FindTrack(), and TrackView::Get().

Here is the call graph for this function:

◆ Reparent()

void WaveTrackView::Reparent ( const std::shared_ptr< Track > &  parent)
overridevirtual

Object may be shared among tracks but hold a special back-pointer to one of them; reassign it.

default does nothing

Reimplemented from TrackAttachment.

Definition at line 1717 of file WaveTrackView.cpp.

1718{
1719 // BuildSubViews(); // not really needed
1720 CommonTrackView::Reparent( parent );
1721 WaveTrackSubViews::ForEach( [&parent](WaveTrackSubView &subView){
1722 subView.Reparent( parent );
1723 } );
1725 mpAffordanceCellControl->Reparent(parent);
1726}
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.

References ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >::ForEach(), mpAffordanceCellControl, and CommonTrackCell::Reparent().

Here is the call graph for this function:

◆ RestorePlacements()

void WaveTrackView::RestorePlacements ( const WaveTrackSubViewPlacements placements)
inline

Definition at line 146 of file WaveTrackView.h.

147 { DoGetPlacements() = placements; }

Referenced by SpectrumPrefs::Rollback(), and SubViewAdjuster::UpdateViews().

Here is the caller graph for this function:

◆ SavePlacements()

const WaveTrackSubViewPlacements & WaveTrackView::SavePlacements ( ) const
inline

Definition at line 144 of file WaveTrackView.h.

145 { return DoGetPlacements(); }

Referenced by CopyTo(), SpectrumPrefs::SpectrumPrefs(), and SubViewAdjuster::SubViewAdjuster().

Here is the caller graph for this function:

◆ SelectAllText()

bool WaveTrackView::SelectAllText ( AudacityProject project)

Definition at line 1451 of file WaveTrackView.cpp.

1452{
1453 for (auto channel : TrackList::Channels(FindTrack().get()))
1454 {
1455 auto& view = TrackView::Get(*channel);
1456 if (auto affordance
1457 = std::dynamic_pointer_cast<WaveTrackAffordanceControls>(view.GetAffordanceControls()))
1458 {
1459 if (affordance->OnTextSelect(project))
1460 return true;
1461 }
1462 }
1463 return false;
1464}

References TrackList::Channels(), CommonTrackPanelCell::FindTrack(), and TrackView::Get().

Here is the call graph for this function:

◆ SelectNextClip()

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

Definition at line 1158 of file WaveTrackView.cpp.

1159{
1160 //Iterates through clips in a looped manner
1161 auto waveTrack = std::dynamic_pointer_cast<WaveTrack>(FindTrack());
1162 if (!waveTrack)
1163 return false;
1164 auto clips = waveTrack->SortedClipArray();
1165 if (clips.empty())
1166 return false;
1167
1168 const WaveClip* clip{ };
1169 if (forward)
1170 {
1171 clip = NextClipLooped(viewInfo, clips.begin(), clips.end(), [&](const WaveClip* other) {
1172 return other->GetPlayStartTime() >= viewInfo.selectedRegion.t1();
1173 });
1174 }
1175 else
1176 {
1177 clip = NextClipLooped(viewInfo, clips.rbegin(), clips.rend(), [&](const WaveClip* other) {
1178 return other->GetPlayStartTime() <= viewInfo.selectedRegion.t0();
1179 });
1180 }
1181
1182 viewInfo.selectedRegion.setTimes(clip->GetPlayStartTime(), clip->GetPlayEndTime());
1183 ProjectHistory::Get(*project).ModifyState(false);
1184
1185 // create and send message to screen reader
1186 auto it = std::find(clips.begin(), clips.end(), clip);
1187 auto index = std::distance(clips.begin(), it);
1188
1189 auto message = XP(
1190 /* i18n-hint:
1191 string is the name of a clip
1192 first number is the position of that clip in a sequence of clips,
1193 second number counts the clips */
1194 "%s, %d of %d clip",
1195 "%s, %d of %d clips",
1196 2
1197 )(
1198 clip->GetName(),
1199 static_cast<int>(index + 1),
1200 static_cast<int>(clips.size())
1201 );
1202
1203 TrackFocus::Get(*project).MessageForScreenReader(message);
1204 return true;
1205}
#define XP(sing, plur, n)
Definition: Internat.h:94
bool setTimes(double t0, double t1)
Definition: ViewInfo.cpp:51
void ModifyState(bool bWantsAutoSave)
static ProjectHistory & Get(AudacityProject &project)
Track * Get()
NotifyingSelectedRegion selectedRegion
Definition: ViewInfo.h:219
This allows multiple clips to be a part of one WaveTrack.
Definition: WaveClip.h:98
const WaveClip * NextClipLooped(ViewInfo &viewInfo, Iter begin, Iter end, Comp comp)

References CommonTrackPanelCell::FindTrack(), TrackFocus::Get(), ProjectHistory::Get(), ProjectHistory::ModifyState(), anonymous_namespace{WaveTrackView.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:

◆ SetDisplay()

void WaveTrackView::SetDisplay ( Display  display,
bool  exclusive = true 
)

Definition at line 1045 of file WaveTrackView.cpp.

1046{
1047 BuildSubViews();
1048 DoSetDisplay( display, exclusive );
1049}
void DoSetDisplay(Display display, bool exclusive=true)

References BuildSubViews(), and DoSetDisplay().

Referenced by WaveformPrefs::Commit(), and WaveTrackMenuTable::OnSetDisplay().

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

◆ SetMultiView()

void WaveTrackView::SetMultiView ( bool  value)
inline

Definition at line 161 of file WaveTrackView.h.

161{ DoGetMultiView() = value; }

◆ ToggleSubView()

bool WaveTrackView::ToggleSubView ( Display  id)

Definition at line 1051 of file WaveTrackView.cpp.

1052{
1053 size_t ii = 0;
1054 size_t found = 0;
1055 if ( WaveTrackSubViews::FindIf( [&]( const WaveTrackSubView &subView ) {
1056 if ( subView.SubViewType().id == display ) {
1057 found = ii;
1058 return true;
1059 }
1060 ++ii;
1061 return false;
1062 } ) ) {
1063 auto &placements = DoGetPlacements();
1064 auto &foundPlacement = placements[found];
1065 if ( foundPlacement.fraction > 0.0 ) {
1066 // Toggle off
1067
1068 if (GetDisplays().size() < 2)
1069 // refuse to do it
1070 return false;
1071
1072 auto index = foundPlacement.index;
1073 foundPlacement = { -1, 0.0 };
1074 if (index >= 0) {
1075 for ( auto &placement : placements ) {
1076 if ( placement.index > index )
1077 --placement.index;
1078 }
1079 }
1080
1081 return true;
1082 }
1083 else {
1084 // Toggle on
1085 float total = 0;
1086 int greatest = -1;
1087 unsigned nn = 0;
1088 for ( const auto &placement : placements ) {
1089 if ( placement.fraction > 0.0 && placement.index >= 0 ) {
1090 total += placement.fraction;
1091 greatest = std::max( greatest, placement.index );
1092 ++nn;
1093 }
1094 }
1095 // Turn on the sub-view, putting it lowest, and with average of the
1096 // heights of the other sub-views
1097 foundPlacement = { greatest + 1, total / nn };
1098
1099 return true;
1100 }
1101 }
1102 else
1103 // unknown sub-view
1104 return false;
1105}
ClientData * FindIf(const Function &function)
Return pointer to first attachment in this that is not null and satisfies a predicate,...
Definition: ClientData.h:412
std::vector< WaveTrackSubView::Type > GetDisplays() const

References DoGetPlacements(), ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >::FindIf(), GetDisplays(), WaveTrackSubViewType::id, ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >::size(), and WaveTrackSubView::SubViewType().

Here is the call graph for this function:

Member Data Documentation

◆ kChannelSeparatorThickness

constexpr int WaveTrackView::kChannelSeparatorThickness { 8 }
staticconstexpr

◆ mAffordanceHandle

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

Definition at line 241 of file WaveTrackView.h.

◆ mChannel

const size_t WaveTrackView::mChannel
private

Definition at line 243 of file WaveTrackView.h.

◆ mKeyEventDelegate

std::weak_ptr<TrackPanelCell> WaveTrackView::mKeyEventDelegate
private

Definition at line 239 of file WaveTrackView.h.

Referenced by CaptureKey(), Char(), KeyDown(), and LoseFocus().

◆ mLastHeight

wxCoord WaveTrackView::mLastHeight {}
mutableprivate

Definition at line 230 of file WaveTrackView.h.

◆ mpAffordanceCellControl

std::shared_ptr<CommonTrackCell> WaveTrackView::mpAffordanceCellControl
private

Definition at line 237 of file WaveTrackView.h.

Referenced by DoGetAffordance(), and Reparent().


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