Audacity  3.0.3
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 CommonTrackPanelCell
using Hook = std::function< unsigned(const TrackPanelMouseEvent &evt, AudacityProject *pProject) >
 
- 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
 
std::shared_ptr< TrackVRulerControlsDoGetVRulerControls () override
 
void Reparent (const std::shared_ptr< Track > &parent) override
 
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
 
- 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
 
bool GetMinimized () const
 
void SetMinimized (bool minimized)
 
int GetCumulativeHeightBefore () const
 
int GetExpandedHeight () const
 
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
 
void WriteXMLAttributes (XMLWriter &) const override
 
bool HandleXMLAttribute (const wxChar *attr, const wxChar *value) override
 
virtual bool IsSpectral () const
 
- Public Member Functions inherited from CommonTrackCell
 CommonTrackCell (const std::shared_ptr< Track > &pTrack)
 
 ~CommonTrackCell ()
 
std::shared_ptr< TrackDoFindTrack () override
 
- 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 unsigned KeyUp (wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent, AudacityProject *project)
 
- Public Member Functions inherited from TrackPanelNode
 TrackPanelNode ()
 
virtual ~TrackPanelNode ()=0
 
- Public Member Functions inherited from TrackPanelDrawable
virtual ~TrackPanelDrawable ()=0
 
virtual wxRect DrawingArea (TrackPanelDrawingContext &context, const wxRect &rect, const wxRect &panelRect, unsigned iPass)
 
- Public Member Functions inherited from 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 -> typename std::enable_if< std::is_const< Subclass >::value, Subclass & >::type
 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 -> typename std::enable_if< std::is_const< Subclass >::value, Subclass * >::type
 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 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 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 Public Member Functions inherited from CommonTrackPanelCell
static Hook InstallMouseWheelHook (const Hook &hook)
 
- Static Public Member Functions inherited from TrackPanelDrawable
static wxRect MaximizeWidth (const wxRect &rect, const wxRect &panelRect)
 
static wxRect MaximizeHeight (const wxRect &rect, const wxRect &panelRect)
 
- 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
 
- Protected Member Functions inherited from CommonTrackPanelCell
unsigned DoContextMenu (const wxRect &rect, wxWindow *pParent, const wxPoint *pPosition, AudacityProject *pProject) override
 
unsigned HandleWheelRotation (const TrackPanelMouseEvent &event, AudacityProject *pProject) override
 
- 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)
 
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
 

Additional Inherited Members

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

Detailed Description

Definition at line 83 of file WaveTrackView.h.

Member Typedef Documentation

◆ Display

Definition at line 93 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 890 of file WaveTrackView.cpp.

891  : CommonTrackView{ pTrack }
892 {
893 }

◆ ~WaveTrackView()

WaveTrackView::~WaveTrackView ( )
override

Definition at line 906 of file WaveTrackView.cpp.

907 {
908 }

Member Function Documentation

◆ BuildSubViews()

void WaveTrackView::BuildSubViews ( ) const
private

Definition at line 1467 of file WaveTrackView.cpp.

1468 {
1469  if ( WaveTrackSubViews::size() == 0) {
1470  // On-demand steps that can't happen in the constructor
1471  auto pThis = const_cast<WaveTrackView*>( this );
1472  pThis->BuildAll();
1473  bool minimized = GetMinimized();
1474  pThis->WaveTrackSubViews::ForEach( [&]( WaveTrackSubView &subView ){
1475  subView.DoSetMinimized( minimized );
1476  } );
1477 
1478  if ( pThis->mPlacements.empty() ) {
1479  pThis->mPlacements.resize( WaveTrackSubViews::size() );
1480 
1481  auto pTrack = pThis->FindTrack();
1482  auto display = TracksPrefs::ViewModeChoice();
1483  bool multi = (display == WaveTrackViewConstants::MultiView);
1484  if ( multi ) {
1485  pThis->SetMultiView( true );
1486  display = WaveTrackSubViewType::Default();
1487  }
1488 
1489  pThis->DoSetDisplay( display, !multi );
1490  }
1491  }
1492 }

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

1153 {
1154  unsigned result{ RefreshCode::RefreshNone };
1155  if (auto affordance = GetAffordanceControls())
1156  result |= affordance->CaptureKey(event, viewInfo, pParent, project);
1157 
1158  if(event.GetSkipped())
1159  result |= CommonTrackView::CaptureKey(event, viewInfo, pParent, project);
1160 
1161  return result;
1162 }

References TrackPanelCell::CaptureKey(), GetAffordanceControls(), 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 1176 of file WaveTrackView.cpp.

1177 {
1178  unsigned result{ RefreshCode::RefreshNone };
1179  if (auto affordance = GetAffordanceControls())
1180  result |= affordance->Char(event, viewInfo, pParent, project);
1181 
1182  if(event.GetSkipped())
1183  result |= CommonTrackView::Char(event, viewInfo, pParent, project);
1184 
1185  return result;
1186 }

References TrackPanelCell::Char(), GetAffordanceControls(), and RefreshCode::RefreshNone.

Here is the call graph for this function:

◆ CopyTo()

void WaveTrackView::CopyTo ( Track track) const
overridevirtual

Reimplemented from CommonTrackCell.

Definition at line 910 of file WaveTrackView.cpp.

911 {
912  TrackView::CopyTo( track );
913  auto &other = TrackView::Get( track );
914 
915  if ( const auto pOther = dynamic_cast< WaveTrackView* >( &other ) ) {
916  // only these fields are important to preserve in undo/redo history
917  pOther->RestorePlacements( SavePlacements() );
918  pOther->mMultiView = mMultiView;
919 
920  auto srcSubViewsPtrs = const_cast<WaveTrackView*>( this )->GetAllSubViews();
921  auto destSubViewsPtrs = const_cast<WaveTrackView*>( pOther )->GetAllSubViews();
922  wxASSERT(srcSubViewsPtrs.size() == destSubViewsPtrs.size());
923 
924  for(auto i = 0; i != srcSubViewsPtrs.size(); i++){
925  srcSubViewsPtrs[i]->CopyToSubView(destSubViewsPtrs[i].get());
926  }
927  }
928 }

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

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

933 {
934  // should not come here any more, delegation to sub-view instead
935  wxASSERT( false );
936  return {};
937 }

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

945 {
946  // common hit-testing for different sub-view types, to help implement their
947  // DetailedHitTest()
948 
949  // This is the only override of Track::DetailedHitTest that still
950  // depends on the state of the Tools toolbar.
951  // If that toolbar were eliminated, this could simplify to a sequence of
952  // hit test routines describable by a table.
953 
954  UIHandlePtr result;
955  std::vector<UIHandlePtr> results;
956 
957  if (bMultiTool && st.state.CmdDown()) {
958  // Ctrl modifier key in multi-tool overrides everything else
959  // (But this does not do the time shift constrained to the vertical only,
960  // which is what happens when you hold Ctrl in the Time Shift tool mode)
962  view.mTimeShiftHandle, pTrack, false);
963  if (result)
964  results.push_back(result);
965  return { true, results };
966  }
967  return { false, results };
968 }

References TimeShiftHandle::HitAnywhere(), CommonTrackView::mTimeShiftHandle, and TrackPanelMouseState::state.

Here is the call graph for this function:

◆ DoGetAffordance()

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

Definition at line 1222 of file WaveTrackView.cpp.

1223 {
1224  if (mpAffordanceCellControl == nullptr)
1225  mpAffordanceCellControl = std::make_shared<WaveTrackAffordanceControls>(track);
1226  return mpAffordanceCellControl;
1227 }

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

1237 {
1238  // This should never be called because of delegation to the spectrum or
1239  // waveform sub-view
1240  wxASSERT( false );
1241  return {};
1242 }

◆ DoSetDisplay()

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

Definition at line 1056 of file WaveTrackView.cpp.

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

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

1212 {
1213  BuildSubViews();
1214 
1215  // May come here. Invoke also on sub-views.
1216  TrackView::DoSetMinimized( minimized );
1217  WaveTrackSubViews::ForEach( [minimized](WaveTrackSubView &subView){
1218  subView.DoSetMinimized( minimized );
1219  } );
1220 }

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

1497 {
1498  // Should not come here, drawing is now delegated to sub-views
1499  wxASSERT( false );
1500 
1501  CommonTrackView::Draw( context, rect, iPass );
1502 }

References TrackPanelDrawable::Draw().

Here is the call graph for this function:

◆ Get() [1/2]

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

Definition at line 885 of file WaveTrackView.cpp.

886 {
887  return Get( const_cast<WaveTrack&>( track ) );
888 }

References BasicUI::Get().

Here is the call graph for this function:

◆ Get() [2/2]

WaveTrackView & WaveTrackView::Get ( WaveTrack track)
static

Definition at line 880 of file WaveTrackView.cpp.

881 {
882  return static_cast< WaveTrackView& >( TrackView::Get( track ) );
883 }

References TrackView::Get().

Referenced by Append(), SetTrackVisualsCommand::ApplyInner(), WaveformPrefs::Commit(), anonymous_namespace{SelectMenus.cpp}::DoNextPeakFrequency(), for(), NyquistEffect::Init(), WaveTrackMenuTable::OnMergeStereo(), WaveTrackMenuTable::OnMultiView(), WaveTrackMenuTable::OnSetDisplay(), Effect::Preview(), NyquistEffect::ProcessOne(), SpectrumPrefs::Rollback(), and anonymous_namespace{WaveTrackView.cpp}::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 1201 of file WaveTrackView.cpp.

1202 {
1203  auto track = FindTrack();
1204  if (!track->IsAlignedWithLeader())
1205  {
1206  return DoGetAffordance(track);
1207  }
1208  return {};
1209 }

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

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

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

1190 {
1191  BuildSubViews();
1192 
1193  std::vector< std::shared_ptr< WaveTrackSubView > > results;
1195  results.push_back( std::static_pointer_cast<WaveTrackSubView>(
1196  subView.shared_from_this() ) );
1197  } );
1198  return results;
1199 }

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

Referenced by CopyTo().

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

◆ GetDisplays()

auto WaveTrackView::GetDisplays ( ) const

Definition at line 970 of file WaveTrackView.cpp.

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

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

Referenced by anonymous_namespace{SelectMenus.cpp}::DoNextPeakFrequency(), NyquistEffect::Init(), NyquistEffect::ProcessOne(), and 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 136 of file WaveTrackView.h.

136 { return mLastHeight; }

Referenced by anonymous_namespace{WaveTrackView.cpp}::SubViewAdjustHandle::HitTest(), and anonymous_namespace{WaveTrackView.cpp}::SubViewRearrangeHandle::HitTest().

Here is the caller graph for this function:

◆ GetMultiView()

bool WaveTrackView::GetMultiView ( ) const
inline

Definition at line 138 of file WaveTrackView.h.

138 { return mMultiView; }

Referenced by anonymous_namespace{WaveTrackView.cpp}::SubViewAdjustHandle::HitTest(), and anonymous_namespace{WaveTrackView.cpp}::SubViewRearrangeHandle::HitTest().

Here is the caller graph for this function:

◆ GetSelectedClip()

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

Definition at line 1458 of file WaveTrackView.cpp.

1459 {
1460  if (auto affordance = std::dynamic_pointer_cast<WaveTrackAffordanceControls>(GetAffordanceControls()))
1461  {
1462  return affordance->GetSelectedClip();
1463  }
1464  return {};
1465 }

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

1088 {
1089  return GetSubViews(&rect);
1090 }

◆ GetSubViews() [2/2]

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

Definition at line 1092 of file WaveTrackView.cpp.

1093 {
1094  BuildSubViews();
1095 
1096  // Collect the visible views in the right sequence
1097  struct Item {
1098  int index; float fraction; std::shared_ptr< TrackView > pView;
1099  };
1100  std::vector< Item > items;
1101  size_t ii = 0;
1102  float total = 0;
1104  auto& placement = mPlacements[ii];
1105  auto index = placement.index;
1106  auto fraction = placement.fraction;
1107  if (index >= 0 && fraction > 0.0)
1108  total += fraction,
1109  items.push_back({ index, fraction, subView.shared_from_this() });
1110  ++ii;
1111  });
1112  std::sort(items.begin(), items.end(), [](const Item& a, const Item& b) {
1113  return a.index < b.index;
1114  });
1115 
1116  // Remove views we don't need
1117  auto begin = items.begin(), end = items.end(),
1118  newEnd = std::remove_if(begin, end,
1119  [](const Item& item) { return !item.pView; });
1120  items.erase(newEnd, end);
1121 
1122  Refinement results;
1123 
1124  if (rect != nullptr)
1125  {
1126  // Assign coordinates, redenominating to the total height,
1127  // storing integer values
1128  results.reserve(items.size());
1129  const auto top = rect->GetTop();
1130  const auto height = rect->GetHeight();
1131  float partial = 0;
1132  wxCoord lastCoord = 0;
1133  for (const auto& item : items) {
1134  wxCoord newCoord = top + (partial / total) * height;
1135  results.emplace_back(newCoord, item.pView);
1136  partial += item.fraction;
1137  }
1138 
1139  // Cache for the use of sub-view dragging
1140  mLastHeight = height;
1141  }
1142  else
1143  {
1144  std::transform(items.begin(), items.end(), std::back_inserter(results), [](const auto& item) {
1145  return std::make_pair(0, item.pView);
1146  });
1147  }
1148 
1149  return results;
1150 }

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

Here is the call graph for this function:

◆ KeyDown()

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

Reimplemented from TrackPanelCell.

Definition at line 1164 of file WaveTrackView.cpp.

1165 {
1166  unsigned result{ RefreshCode::RefreshNone };
1167  if (auto affordance = GetAffordanceControls())
1168  result |= affordance->KeyDown(event, viewInfo, pParent, project);
1169 
1170  if(event.GetSkipped())
1171  result |= CommonTrackView::KeyDown(event, viewInfo, pParent, project);
1172 
1173  return result;
1174 }

References GetAffordanceControls(), TrackPanelCell::KeyDown(), and RefreshCode::RefreshNone.

Here is the call graph for this function:

◆ operator=()

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

◆ Reparent()

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

Reimplemented from CommonTrackCell.

Definition at line 1447 of file WaveTrackView.cpp.

1448 {
1449  // BuildSubViews(); // not really needed
1450  CommonTrackView::Reparent( parent );
1451  WaveTrackSubViews::ForEach( [&parent](WaveTrackSubView &subView){
1452  subView.Reparent( parent );
1453  } );
1455  mpAffordanceCellControl->Reparent(parent);
1456 }

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 124 of file WaveTrackView.h.

125  { mPlacements = placements; }

Referenced by SpectrumPrefs::Rollback(), and anonymous_namespace{WaveTrackView.cpp}::SubViewAdjuster::UpdateViews().

Here is the caller graph for this function:

◆ SavePlacements()

const WaveTrackSubViewPlacements& WaveTrackView::SavePlacements ( ) const
inline

Definition at line 122 of file WaveTrackView.h.

123  { return mPlacements; }

Referenced by CopyTo().

Here is the caller graph for this function:

◆ SetDisplay()

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

Definition at line 992 of file WaveTrackView.cpp.

993 {
994  BuildSubViews();
995  DoSetDisplay( display, exclusive );
996 }

References BuildSubViews(), and DoSetDisplay().

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

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 139 of file WaveTrackView.h.

139 { mMultiView = value; }

◆ ToggleSubView()

bool WaveTrackView::ToggleSubView ( Display  id)

Definition at line 998 of file WaveTrackView.cpp.

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

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

Definition at line 91 of file WaveTrackView.h.

Referenced by WaveTrackAffordanceControls::HitTest().

◆ mLastHeight

wxCoord WaveTrackView::mLastHeight {}
mutableprotected

Definition at line 190 of file WaveTrackView.h.

◆ mMultiView

bool WaveTrackView::mMultiView { false }
protected

Definition at line 192 of file WaveTrackView.h.

Referenced by CopyTo().

◆ mpAffordanceCellControl

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

Definition at line 197 of file WaveTrackView.h.

Referenced by DoGetAffordance(), and Reparent().

◆ mPlacements

WaveTrackSubViewPlacements WaveTrackView::mPlacements
protected

Definition at line 189 of file WaveTrackView.h.

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


The documentation for this class was generated from the following files:
WaveTrackView::mPlacements
WaveTrackSubViewPlacements mPlacements
Definition: WaveTrackView.h:189
WaveTrackView::BuildSubViews
void BuildSubViews() const
Definition: WaveTrackView.cpp:1467
WaveTrack
A Track that contains audio waveform data.
Definition: WaveTrack.h:69
CommonTrackView
Definition: CommonTrackView.h:20
ClientData::Site::ForEach
void ForEach(const Function &function)
Invoke function on each ClientData object that has been created in this.
Definition: ClientData.h:380
WaveTrackSubView::SubViewType
virtual const Type & SubViewType() const =0
WaveTrackView
Definition: WaveTrackView.h:86
WaveTrackView::GetAffordanceControls
std::shared_ptr< CommonTrackCell > GetAffordanceControls() override
Definition: WaveTrackView.cpp:1201
TrackView::Get
static TrackView & Get(Track &)
Definition: TrackView.cpp:63
RefreshCode::RefreshNone
@ RefreshNone
Definition: RefreshCode.h:21
TrackView::GetMinimized
bool GetMinimized() const
Definition: TrackView.h:49
WaveTrackView::DoSetDisplay
void DoSetDisplay(Display display, bool exclusive=true)
Definition: WaveTrackView.cpp:1056
WaveTrackView::GetAllSubViews
std::vector< std::shared_ptr< WaveTrackSubView > > GetAllSubViews()
Definition: WaveTrackView.cpp:1189
CommonTrackView::mTimeShiftHandle
std::weak_ptr< TimeShiftHandle > mTimeShiftHandle
Definition: CommonTrackView.h:48
ClientData::Site::FindIf
ClientData * FindIf(const Function &function)
Return pointer to first attachment in this that is not null and satisfies a predicate,...
Definition: ClientData.h:412
WaveTrackSubViewType::id
Display id
Definition: WaveTrackViewConstants.h:96
WaveTrackSubViewType::Default
static Display Default()
Return a preferred type.
Definition: WaveTrackViewConstants.cpp:97
TrackPanelCell::KeyDown
virtual unsigned KeyDown(wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent, AudacityProject *project)
Definition: TrackPanelCell.cpp:62
CommonTrackPanelCell::FindTrack
std::shared_ptr< Track > FindTrack()
Definition: CommonTrackPanelCell.h:46
TrackView::Refinement
std::vector< std::pair< wxCoord, std::shared_ptr< TrackView > > > Refinement
Definition: TrackView.h:99
ClientData::Site::size
size_t size() const
How many attachment pointers are in the Site.
Definition: ClientData.h:251
WaveTrackView::DoGetAffordance
std::shared_ptr< CommonTrackCell > DoGetAffordance(const std::shared_ptr< Track > &track)
Definition: WaveTrackView.cpp:1222
WaveTrackSubView
Definition: WaveTrackView.h:29
TracksPrefs::ViewModeChoice
static WaveTrackViewConstants::Display ViewModeChoice()
Definition: TracksPrefs.cpp:168
WaveTrackView::mMultiView
bool mMultiView
Definition: WaveTrackView.h:192
UIHandlePtr
std::shared_ptr< UIHandle > UIHandlePtr
Definition: CellularPanel.h:28
anonymous_namespace{ProjectFileManager.cpp}::Pair
std::pair< const char *, const char * > Pair
Definition: ProjectFileManager.cpp:106
TrackView::DoSetMinimized
virtual void DoSetMinimized(bool isMinimized)
Definition: TrackView.cpp:126
WaveTrackView::SavePlacements
const WaveTrackSubViewPlacements & SavePlacements() const
Definition: WaveTrackView.h:122
TrackPanelCell::CaptureKey
virtual unsigned CaptureKey(wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent, AudacityProject *project)
Definition: TrackPanelCell.cpp:55
WaveTrackView::GetDisplays
std::vector< WaveTrackSubView::Type > GetDisplays() const
Definition: WaveTrackView.cpp:970
WaveTrackView::mpAffordanceCellControl
std::shared_ptr< CommonTrackCell > mpAffordanceCellControl
Definition: WaveTrackView.h:197
WaveTrackView::Get
static WaveTrackView & Get(WaveTrack &track)
Definition: WaveTrackView.cpp:880
ClientData::Site::BuildAll
void BuildAll()
For each RegisteredFactory, if the corresponding attachment is absent in this, build and store it.
Definition: ClientData.h:441
TrackView::CopyTo
void CopyTo(Track &track) const override
Definition: TrackView.cpp:52
WaveTrackView::GetSubViews
Refinement GetSubViews(const wxRect *rect=nullptr)
Definition: WaveTrackView.cpp:1092
CommonTrackCell::Reparent
virtual void Reparent(const std::shared_ptr< Track > &parent)
Definition: CommonTrackPanelCell.cpp:133
WaveTrackView::mLastHeight
wxCoord mLastHeight
Definition: WaveTrackView.h:190
TimeShiftHandle::HitAnywhere
static UIHandlePtr HitAnywhere(std::weak_ptr< TimeShiftHandle > &holder, const std::shared_ptr< Track > &pTrack, bool gripHit)
Definition: TimeShiftHandle.cpp:80
WaveTrackViewConstants::MultiView
@ MultiView
"Multi" is special, not really a view type on par with the others.
Definition: WaveTrackViewConstants.h:20
TrackPanelCell::Char
virtual unsigned Char(wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent, AudacityProject *project)
Definition: TrackPanelCell.cpp:76
TrackPanelDrawable::Draw
virtual void Draw(TrackPanelDrawingContext &context, const wxRect &rect, unsigned iPass)
Definition: TrackPanelDrawable.cpp:17