Audacity 3.2.0
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected 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)
 
 ~WaveTrackView () override
 
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 }
 

Protected Member Functions

std::shared_ptr< CommonTrackCellGetAffordanceControls () override
 
void DoSetMinimized (bool minimized) override
 
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

WaveTrackSubViewPlacements mPlacements
 
wxCoord mLastHeight {}
 
bool mMultiView { false }
 
- Protected Attributes inherited from CommonTrackView
std::weak_ptr< SelectHandlemSelectHandle
 
- Protected Attributes inherited from TrackView
std::shared_ptr< TrackVRulerControlsmpVRulerControls
 

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< CommonTrackCellDoGetAffordance (const std::shared_ptr< Track > &track)
 

Private Attributes

std::shared_ptr< CommonTrackCellmpAffordanceCellControl
 
std::weak_ptr< TrackPanelCellmKeyEventDelegate
 
std::weak_ptr< WaveTrackAffordanceHandlemAffordanceHandle
 

Additional Inherited Members

- Public Attributes inherited from CommonTrackView
std::weak_ptr< TimeShiftHandlemTimeShiftHandle
 

Detailed Description

Definition at line 95 of file WaveTrackView.h.

Member Typedef Documentation

◆ Display

Definition at line 105 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)
explicit

Definition at line 875 of file WaveTrackView.cpp.

876 : CommonTrackView{ pTrack }
877{
878}

◆ ~WaveTrackView()

WaveTrackView::~WaveTrackView ( )
override

Definition at line 891 of file WaveTrackView.cpp.

892{
893}

Member Function Documentation

◆ BuildSubViews()

void WaveTrackView::BuildSubViews ( ) const
private

Definition at line 1682 of file WaveTrackView.cpp.

1683{
1684 if ( WaveTrackSubViews::size() == 0) {
1685 // On-demand steps that can't happen in the constructor
1686 auto pThis = const_cast<WaveTrackView*>( this );
1687 pThis->BuildAll();
1688 bool minimized = GetMinimized();
1689 pThis->WaveTrackSubViews::ForEach( [&]( WaveTrackSubView &subView ){
1690 subView.DoSetMinimized( minimized );
1691 } );
1692
1693 if ( pThis->mPlacements.empty() ) {
1694 pThis->mPlacements.resize( WaveTrackSubViews::size() );
1695
1696 auto pTrack = pThis->FindTrack();
1697 auto display = TracksPrefs::ViewModeChoice();
1698 bool multi = (display == WaveTrackViewConstants::MultiView);
1699 if ( multi ) {
1700 pThis->SetMultiView( true );
1702 }
1703
1704 pThis->DoSetDisplay( display, !multi );
1705 }
1706 }
1707}
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 1227 of file WaveTrackView.cpp.

1228{
1229 unsigned result{ RefreshCode::RefreshNone };
1230 auto pTrack = static_cast<WaveTrack*>(FindTrack().get());
1231 for (auto pChannel : TrackList::Channels(pTrack)) {
1232 event.Skip(false);
1233 auto &waveTrackView = WaveTrackView::Get(*pChannel);
1234 // Give sub-views first chance to handle the event
1235 for (auto &subView : waveTrackView.GetSubViews()) {
1236 // Event defaults in skipped state which must be turned off explicitly
1237 wxASSERT(!event.GetSkipped());
1238 result |= subView.second->CaptureKey(event, viewInfo, pParent, project);
1239 if (!event.GetSkipped()) {
1240 // sub view wants it
1241 mKeyEventDelegate = subView.second;
1242 return result;
1243 }
1244 else
1245 event.Skip(false);
1246 }
1247
1248 if (auto affordance = waveTrackView.GetAffordanceControls()) {
1249 result |= affordance->CaptureKey(event, viewInfo, pParent, project);
1250 if (!event.GetSkipped()) {
1251 mKeyEventDelegate = affordance;
1252 return result;
1253 }
1254 }
1255
1256 event.Skip(false);
1257 }
1258 switch (event.GetKeyCode())
1259 {
1260 case WXK_TAB:
1261 break;
1262 default:
1264 event, viewInfo, pParent, project);
1265 break;
1266 };
1267 if (!event.GetSkipped()) {
1268 mKeyEventDelegate = shared_from_this();
1269 }
1270
1271 return result;
1272}
std::shared_ptr< Track > FindTrack()
static auto Channels(TrackType *pTrack) -> TrackIterRange< TrackType >
Definition: Track.h:1544
virtual unsigned CaptureKey(wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent, AudacityProject *project)
A Track that contains audio waveform data.
Definition: WaveTrack.h:51
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 1298 of file WaveTrackView.cpp.

1299{
1300 unsigned result{ RefreshCode::RefreshNone };
1301 if (auto delegate = mKeyEventDelegate.lock()) {
1302 if (auto pWaveTrackView = dynamic_cast<WaveTrackView*>(delegate.get()))
1303 result |= pWaveTrackView->CommonTrackView::Char(
1304 event, viewInfo, pParent, project);
1305 else
1306 result |= delegate->Char(event, viewInfo, pParent, project);
1307 }
1308 else
1309 event.Skip();
1310
1311 return result;
1312}

References mKeyEventDelegate, and RefreshCode::RefreshNone.

◆ ClipDetailsVisible()

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

Definition at line 1357 of file WaveTrackView.cpp.

1358{
1359 //Do not fold clips to line at sample zoom level, as
1360 //it may become impossible to 'unfold' it when clip is trimmed
1361 //to a single sample
1362 bool showSamples{ false };
1363 auto clipRect = ClipParameters::GetClipRect(clip, zoomInfo, viewRect, &showSamples);
1364 return showSamples || clipRect.width >= kClipDetailedViewMinimumWidth;
1365}
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 1367 of file WaveTrackView.cpp.

1368{
1369 bool showSamples{ false };
1370 auto clipRect = ClipParameters::GetClipRect(clip, zoomInfo, viewRect, &showSamples);
1371 if (showSamples || clipRect.width >= kClipDetailedViewMinimumWidth)
1372 return clipRect;
1373
1374 return clipRect.Inflate(2, 0);
1375}

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 1342 of file WaveTrackView.cpp.

1343{
1344 for (auto channel : TrackList::Channels(FindTrack().get()))
1345 {
1346 auto& view = TrackView::Get(*channel);
1347 if (auto affordance
1348 = std::dynamic_pointer_cast<WaveTrackAffordanceControls>(view.GetAffordanceControls()))
1349 {
1350 if (affordance->OnTextCopy(project))
1351 return true;
1352 }
1353 }
1354 return false;
1355}
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 895 of file WaveTrackView.cpp.

896{
897 TrackView::CopyTo( track );
898 auto &other = TrackView::Get( track );
899
900 if ( const auto pOther = dynamic_cast< WaveTrackView* >( &other ) ) {
901 // only these fields are important to preserve in undo/redo history
902 pOther->RestorePlacements( SavePlacements() );
903 pOther->mMultiView = mMultiView;
904
905 auto srcSubViewsPtrs = const_cast<WaveTrackView*>( this )->GetAllSubViews();
906 auto destSubViewsPtrs = const_cast<WaveTrackView*>( pOther )->GetAllSubViews();
907 wxASSERT(srcSubViewsPtrs.size() == destSubViewsPtrs.size());
908
909 for(auto i = 0; i != srcSubViewsPtrs.size(); i++){
910 srcSubViewsPtrs[i]->CopyToSubView(destSubViewsPtrs[i].get());
911 }
912 }
913}
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

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

Here is the call graph for this function:

◆ CutSelectedText()

bool WaveTrackView::CutSelectedText ( AudacityProject project)

Definition at line 1327 of file WaveTrackView.cpp.

1328{
1329 for (auto channel : TrackList::Channels(FindTrack().get()))
1330 {
1331 auto& view = TrackView::Get(*channel);
1332 if (auto affordance
1333 = std::dynamic_pointer_cast<WaveTrackAffordanceControls>(view.GetAffordanceControls()))
1334 {
1335 if (affordance->OnTextCut(project))
1336 return true;
1337 }
1338 }
1339 return false;
1340}

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 915 of file WaveTrackView.cpp.

918{
919 // should not come here any more, delegation to sub-view instead
920 wxASSERT( false );
921 return {};
922}

◆ 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 925 of file WaveTrackView.cpp.

930{
931 // common hit-testing for different sub-view types, to help implement their
932 // DetailedHitTest()
933
934 // This is the only override of Track::DetailedHitTest that still
935 // depends on the state of the Tools toolbar.
936 // If that toolbar were eliminated, this could simplify to a sequence of
937 // hit test routines describable by a table.
938
939 std::vector<UIHandlePtr> results;
940
941 const auto& viewInfo = ViewInfo::Get(*pProject);
942
943 for (auto& clip : pTrack->GetClips())
944 {
945 if (!WaveTrackView::ClipDetailsVisible(*clip, viewInfo, st.rect)
946 && HitTest(*clip, viewInfo, st.rect, st.state.GetPosition()))
947 {
948 auto &waveTrackView = WaveTrackView::Get(*pTrack);
949 results.push_back(
951 waveTrackView.mAffordanceHandle,
952 std::make_shared<WaveTrackAffordanceHandle>(pTrack, clip)
953 )
954 );
955 }
956 }
957
958 if (bMultiTool && st.state.CmdDown()) {
959 // Ctrl modifier key in multi-tool overrides everything else
960 // (But this does not do the time shift constrained to the vertical only,
961 // which is what happens when you hold Ctrl in the Time Shift tool mode)
962 auto result = TimeShiftHandle::HitAnywhere(
963 view.mTimeShiftHandle, pTrack, false);
964 if (result)
965 results.push_back(result);
966 return { true, results };
967 }
968
969 return { false, results };
970}
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 1446 of file WaveTrackView.cpp.

1447{
1448 if (mpAffordanceCellControl == nullptr)
1449 mpAffordanceCellControl = std::make_shared<WaveTrackAffordanceControls>(track);
1451}
std::shared_ptr< CommonTrackCell > mpAffordanceCellControl

References mpAffordanceCellControl.

Referenced by GetAffordanceControls().

Here is the caller graph for this function:

◆ DoGetVRulerControls()

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

Implements TrackView.

Definition at line 1460 of file WaveTrackView.cpp.

1461{
1462 // This should never be called because of delegation to the spectrum or
1463 // waveform sub-view
1464 wxASSERT( false );
1465 return {};
1466}

◆ DoSetDisplay()

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

Definition at line 1058 of file WaveTrackView.cpp.

1059{
1060 // Some generality here anticipating more than two views.
1061 // The order of sub-views in the array is not specified, so make it definite
1062 // by sorting by the view type constants.
1063 size_t ii = 0;
1064 std::vector< std::pair< WaveTrackViewConstants::Display, size_t > > pairs;
1065 WaveTrackSubViews::ForEach( [&pairs, &ii]( WaveTrackSubView &subView ){
1066 pairs.push_back( { subView.SubViewType().id, ii++ } );
1067 } );
1068 std::sort( pairs.begin(), pairs.end() );
1069
1070 int jj = 1;
1071 for ( const auto &pair : pairs ) {
1072 auto &placement = mPlacements[ pair.second ];
1073 if (pair.first == display) {
1074 // 0 for first view
1075 placement = { 0, 1.0 };
1076 }
1077 else if( exclusive )
1078 // -1 for not displayed
1079 placement = { -1, 0.0 };
1080 else
1081 // positions other than the first.
1082 // (Note that the fractions in the placement don't need to be
1083 // denominated to 1. Just make them all equal to get an equal
1084 // partitioning of the sub-views.)
1085 placement = { jj++, 1.0 };
1086 }
1087}
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
WaveTrackSubViewPlacements mPlacements

References ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >::ForEach(), mPlacements, 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)
overrideprotectedvirtual

Reimplemented from TrackView.

Definition at line 1435 of file WaveTrackView.cpp.

1436{
1437 BuildSubViews();
1438
1439 // May come here. Invoke also on sub-views.
1440 TrackView::DoSetMinimized( minimized );
1441 WaveTrackSubViews::ForEach( [minimized](WaveTrackSubView &subView){
1442 subView.DoSetMinimized( minimized );
1443 } );
1444}
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 1709 of file WaveTrackView.cpp.

1712{
1713 // Should not come here, drawing is now delegated to sub-views
1714 wxASSERT( false );
1715
1716 CommonTrackView::Draw( context, rect, iPass );
1717}
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 870 of file WaveTrackView.cpp.

871{
872 return Find( const_cast<WaveTrack*>( pTrack ) );
873}
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 865 of file WaveTrackView.cpp.

866{
867 return static_cast< WaveTrackView* >( TrackView::Find( pTrack ) );
868}
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 860 of file WaveTrackView.cpp.

861{
862 return Get( const_cast<WaveTrack&>( track ) );
863}

References Get().

Here is the call graph for this function:

◆ Get() [2/2]

WaveTrackView & WaveTrackView::Get ( WaveTrack track)
static

Definition at line 855 of file WaveTrackView.cpp.

856{
857 return static_cast< WaveTrackView& >( TrackView::Get( track ) );
858}

References TrackView::Get().

Referenced by Append(), SetTrackVisualsCommand::ApplyInner(), CaptureKey(), WaveformPrefs::Commit(), DoDetailedHitTest(), for(), Get(), anonymous_namespace{EditMenus.cpp}::OnCopy(), anonymous_namespace{EditMenus.cpp}::OnCut(), WaveTrackMenuTable::OnMergeStereo(), WaveTrackMenuTable::OnMultiView(), anonymous_namespace{EditMenus.cpp}::OnPaste(), 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 ( )
overrideprotectedvirtual

Reimplemented from TrackView.

Definition at line 1425 of file WaveTrackView.cpp.

1426{
1427 auto track = FindTrack();
1428 if (!track->IsAlignedWithLeader())
1429 {
1430 return DoGetAffordance(track);
1431 }
1432 return {};
1433}
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 1413 of file WaveTrackView.cpp.

1414{
1415 BuildSubViews();
1416
1417 std::vector< std::shared_ptr< WaveTrackSubView > > results;
1419 results.push_back( std::static_pointer_cast<WaveTrackSubView>(
1420 subView.shared_from_this() ) );
1421 } );
1422 return results;
1423}

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:

◆ GetDisplays()

auto WaveTrackView::GetDisplays ( ) const

Definition at line 972 of file WaveTrackView.cpp.

974{
976
977 // Collect the display types of visible views and sort them by position
978 using Pair = std::pair< int, WaveTrackSubView::Type >;
979 std::vector< Pair > pairs;
980 size_t ii = 0;
981 WaveTrackSubViews::ForEach( [&]( const WaveTrackSubView &subView ){
982 auto &placement = mPlacements[ii];
983 if ( placement.fraction > 0 )
984 pairs.emplace_back( placement.index, subView.SubViewType() );
985 ++ii;
986 } );
987 std::sort( pairs.begin(), pairs.end() );
988 std::vector< WaveTrackSubView::Type > results;
989 for ( const auto &pair : pairs )
990 results.push_back( pair.second );
991 return results;
992}
std::pair< const char *, const char * > Pair

References BuildSubViews(), ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >::ForEach(), mPlacements, 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 150 of file WaveTrackView.h.

150{ 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 152 of file WaveTrackView.h.

152{ return mMultiView; }

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 1673 of file WaveTrackView.cpp.

1674{
1675 if (auto affordance = std::dynamic_pointer_cast<WaveTrackAffordanceControls>(GetAffordanceControls()))
1676 {
1677 return affordance->GetSelectedClip();
1678 }
1679 return {};
1680}
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 1154 of file WaveTrackView.cpp.

1155{
1156 return GetSubViews(&rect);
1157}
Refinement GetSubViews(const wxRect *rect=nullptr)

◆ GetSubViews() [2/2]

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

Definition at line 1159 of file WaveTrackView.cpp.

1160{
1161 BuildSubViews();
1162
1163 // Collect the visible views in the right sequence
1164 struct Item {
1165 int index; float fraction; std::shared_ptr< TrackView > pView;
1166 };
1167 std::vector< Item > items;
1168 size_t ii = 0;
1169 float total = 0;
1171 auto& placement = mPlacements[ii];
1172 auto index = placement.index;
1173 auto fraction = placement.fraction;
1174 if (index >= 0 && fraction > 0.0)
1175 total += fraction,
1176 items.push_back({ index, fraction, subView.shared_from_this() });
1177 ++ii;
1178 });
1179 std::sort(items.begin(), items.end(), [](const Item& a, const Item& b) {
1180 return a.index < b.index;
1181 });
1182
1183 // Remove views we don't need
1184 auto begin = items.begin(), end = items.end(),
1185 newEnd = std::remove_if(begin, end,
1186 [](const Item& item) { return !item.pView; });
1187 items.erase(newEnd, end);
1188
1189 Refinement results;
1190
1191 if (rect != nullptr)
1192 {
1193 // Assign coordinates, redenominating to the total height,
1194 // storing integer values
1195 results.reserve(items.size());
1196 const auto top = rect->GetTop();
1197 const auto height = rect->GetHeight();
1198 float partial = 0;
1199 wxCoord lastCoord = 0;
1200 for (const auto& item : items) {
1201 wxCoord newCoord = top + (partial / total) * height;
1202 results.emplace_back(newCoord, item.pView);
1203 partial += item.fraction;
1204 }
1205
1206 // Cache for the use of sub-view dragging
1207 mLastHeight = height;
1208 }
1209 else
1210 {
1211 std::transform(items.begin(), items.end(), std::back_inserter(results), [](const auto& item) {
1212 return std::make_pair(0, item.pView);
1213 });
1214 }
1215
1216 return results;
1217}
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 1377 of file WaveTrackView.cpp.

1378{
1379 return ClipHitTestArea(clip, viewInfo, viewRect).Contains(pos);
1380}
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 1274 of file WaveTrackView.cpp.

1275{
1276 unsigned result{ RefreshCode::RefreshNone };
1277 if (auto delegate = mKeyEventDelegate.lock()) {
1278 if (auto pWaveTrackView = dynamic_cast<WaveTrackView*>(delegate.get()))
1279 {
1280 if (event.GetKeyCode() == WXK_TAB)
1281 {
1282 SelectNextClip(viewInfo, project, event.GetModifiers() != wxMOD_SHIFT);
1283 result |= RefreshCode::RefreshCell;
1284 }
1285 else
1286 result |= pWaveTrackView->CommonTrackView::KeyDown(
1287 event, viewInfo, pParent, project);
1288 }
1289 else
1290 result |= delegate->KeyDown(event, viewInfo, pParent, project);
1291 }
1292 else
1293 event.Skip();
1294
1295 return result;
1296}
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 1314 of file WaveTrackView.cpp.

1315{
1316 unsigned result = RefreshCode::RefreshNone;
1317 if (auto delegate = mKeyEventDelegate.lock()) {
1318 if (auto waveTrackView = dynamic_cast<WaveTrackView*>(delegate.get()))
1319 result = waveTrackView->CommonTrackView::LoseFocus(project);
1320 else
1321 result = delegate->LoseFocus(project);
1322 mKeyEventDelegate.reset();
1323 }
1324 return result;
1325}

References mKeyEventDelegate, and RefreshCode::RefreshNone.

◆ operator=()

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

◆ PasteText()

bool WaveTrackView::PasteText ( AudacityProject project)

Definition at line 1382 of file WaveTrackView.cpp.

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

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 1662 of file WaveTrackView.cpp.

1663{
1664 // BuildSubViews(); // not really needed
1665 CommonTrackView::Reparent( parent );
1666 WaveTrackSubViews::ForEach( [&parent](WaveTrackSubView &subView){
1667 subView.Reparent( parent );
1668 } );
1670 mpAffordanceCellControl->Reparent(parent);
1671}
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 138 of file WaveTrackView.h.

139 { mPlacements = 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 136 of file WaveTrackView.h.

137 { return mPlacements; }

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 1397 of file WaveTrackView.cpp.

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

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 1105 of file WaveTrackView.cpp.

1106{
1107 //Iterates through clips in a looped manner
1108 auto waveTrack = std::dynamic_pointer_cast<WaveTrack>(FindTrack());
1109 if (!waveTrack)
1110 return false;
1111 auto clips = waveTrack->SortedClipArray();
1112 if (clips.empty())
1113 return false;
1114
1115 const WaveClip* clip{ };
1116 if (forward)
1117 {
1118 clip = NextClipLooped(viewInfo, clips.begin(), clips.end(), [&](const WaveClip* other) {
1119 return other->GetPlayStartTime() >= viewInfo.selectedRegion.t1();
1120 });
1121 }
1122 else
1123 {
1124 clip = NextClipLooped(viewInfo, clips.rbegin(), clips.rend(), [&](const WaveClip* other) {
1125 return other->GetPlayStartTime() <= viewInfo.selectedRegion.t0();
1126 });
1127 }
1128
1129 viewInfo.selectedRegion.setTimes(clip->GetPlayStartTime(), clip->GetPlayEndTime());
1130 ProjectHistory::Get(*project).ModifyState(false);
1131
1132 // create and send message to screen reader
1133 auto it = std::find(clips.begin(), clips.end(), clip);
1134 auto index = std::distance(clips.begin(), it);
1135
1136 auto message = XP(
1137 /* i18n-hint:
1138 string is the name of a clip
1139 first number is the position of that clip in a sequence of clips,
1140 second number counts the clips */
1141 "%s, %d of %d clip",
1142 "%s, %d of %d clips",
1143 2
1144 )(
1145 clip->GetName(),
1146 static_cast<int>(index + 1),
1147 static_cast<int>(clips.size())
1148 );
1149
1150 TrackFocus::Get(*project).MessageForScreenReader(message);
1151 return true;
1152}
#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:101
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 994 of file WaveTrackView.cpp.

995{
997 DoSetDisplay( display, exclusive );
998}
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 153 of file WaveTrackView.h.

153{ mMultiView = value; }

◆ ToggleSubView()

bool WaveTrackView::ToggleSubView ( Display  id)

Definition at line 1000 of file WaveTrackView.cpp.

1001{
1002 size_t ii = 0;
1003 size_t found = 0;
1004 if ( WaveTrackSubViews::FindIf( [&]( const WaveTrackSubView &subView ) {
1005 if ( subView.SubViewType().id == display ) {
1006 found = ii;
1007 return true;
1008 }
1009 ++ii;
1010 return false;
1011 } ) ) {
1012 auto &foundPlacement = mPlacements[found];
1013 if ( foundPlacement.fraction > 0.0 ) {
1014 // Toggle off
1015
1016 if (GetDisplays().size() < 2)
1017 // refuse to do it
1018 return false;
1019
1020 auto index = foundPlacement.index;
1021 foundPlacement = { -1, 0.0 };
1022 if (index >= 0) {
1023 for ( auto &placement : mPlacements ) {
1024 if ( placement.index > index )
1025 --placement.index;
1026 }
1027 }
1028
1029 return true;
1030 }
1031 else {
1032 // Toggle on
1033 float total = 0;
1034 int greatest = -1;
1035 unsigned nn = 0;
1036 for ( const auto &placement : mPlacements ) {
1037 if ( placement.fraction > 0.0 && placement.index >= 0 ) {
1038 total += placement.fraction;
1039 greatest = std::max( greatest, placement.index );
1040 ++nn;
1041 }
1042 }
1043 // Turn on the sub-view, putting it lowest, and with average of the
1044 // heights of the other sub-views
1045 foundPlacement = { greatest + 1, total / nn };
1046
1047 return true;
1048 }
1049 }
1050 else
1051 // unknown sub-view
1052 return false;
1053}
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 ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >::FindIf(), GetDisplays(), WaveTrackSubViewType::id, mPlacements, 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 232 of file WaveTrackView.h.

◆ mKeyEventDelegate

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

Definition at line 230 of file WaveTrackView.h.

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

◆ mLastHeight

wxCoord WaveTrackView::mLastHeight {}
mutableprotected

Definition at line 221 of file WaveTrackView.h.

◆ mMultiView

bool WaveTrackView::mMultiView { false }
protected

Definition at line 223 of file WaveTrackView.h.

Referenced by CopyTo().

◆ mpAffordanceCellControl

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

Definition at line 228 of file WaveTrackView.h.

Referenced by DoGetAffordance(), and Reparent().

◆ mPlacements

WaveTrackSubViewPlacements WaveTrackView::mPlacements
protected

Definition at line 220 of file WaveTrackView.h.

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


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