Audacity  3.0.3
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | 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)
 
- 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 GetY () const
 
int GetActualHeight () const
 
int GetHeight () const
 
void SetY (int y)
 
void SetHeight (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
 
- Public Member Functions inherited from TrackPanelCell
 TrackPanelCell ()=default
 
 TrackPanelCell (const TrackPanelCell &) PROHIBITED
 
TrackPanelCelloperator= (const TrackPanelCell &) PROHIBITED
 
virtual ~TrackPanelCell ()=0
 
virtual unsigned DoContextMenu (const wxRect &rect, wxWindow *pParent, 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)
 
- 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...
 

Protected Member Functions

void DoSetMinimized (bool minimized) override
 
- Protected Member Functions inherited from TrackView
void DoSetY (int y)
 
void DoSetHeight (int h)
 
- Protected Member Functions inherited from CommonTrackPanelCell
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
 

Additional Inherited Members

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

Detailed Description

Definition at line 68 of file WaveTrackView.h.

Member Typedef Documentation

◆ Display

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

774  : CommonTrackView{ pTrack }
775 {
776 }

◆ ~WaveTrackView()

WaveTrackView::~WaveTrackView ( )
override

Definition at line 785 of file WaveTrackView.cpp.

786 {
787 }

Member Function Documentation

◆ BuildSubViews()

void WaveTrackView::BuildSubViews ( ) const
private

Definition at line 1257 of file WaveTrackView.cpp.

1258 {
1259  if ( WaveTrackSubViews::size() == 0) {
1260  // On-demand steps that can't happen in the constructor
1261  auto pThis = const_cast<WaveTrackView*>( this );
1262  pThis->BuildAll();
1263  bool minimized = GetMinimized();
1264  pThis->WaveTrackSubViews::ForEach( [&]( WaveTrackSubView &subView ){
1265  subView.DoSetMinimized( minimized );
1266  } );
1267 
1268  if ( pThis->mPlacements.empty() ) {
1269  pThis->mPlacements.resize( WaveTrackSubViews::size() );
1270 
1271  auto pTrack = pThis->FindTrack();
1272  auto display = TracksPrefs::ViewModeChoice();
1273  bool multi = (display == WaveTrackViewConstants::MultiView);
1274  if ( multi ) {
1275  pThis->SetMultiView( true );
1276  display = WaveTrackSubViewType::Default();
1277  }
1278 
1279  pThis->DoSetDisplay( display, !multi );
1280  }
1281  }
1282 }

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:

◆ CopyTo()

void WaveTrackView::CopyTo ( Track track) const
overridevirtual

Reimplemented from CommonTrackCell.

Definition at line 789 of file WaveTrackView.cpp.

790 {
791  TrackView::CopyTo( track );
792  auto &other = TrackView::Get( track );
793 
794  if ( const auto pOther = dynamic_cast< WaveTrackView* >( &other ) ) {
795  // only these fields are important to preserve in undo/redo history
796  pOther->RestorePlacements( SavePlacements() );
797  pOther->mMultiView = mMultiView;
798  }
799 }

References TrackView::CopyTo(), TrackView::Get(), 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 801 of file WaveTrackView.cpp.

804 {
805  // should not come here any more, delegation to sub-view instead
806  wxASSERT( false );
807  return {};
808 }

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

816 {
817  // common hit-testing for different sub-view types, to help implement their
818  // DetailedHitTest()
819 
820  // This is the only override of Track::DetailedHitTest that still
821  // depends on the state of the Tools toolbar.
822  // If that toolbar were eliminated, this could simplify to a sequence of
823  // hit test routines describable by a table.
824 
825  UIHandlePtr result;
826  std::vector<UIHandlePtr> results;
827 
828  if (bMultiTool && st.state.CmdDown()) {
829  // Ctrl modifier key in multi-tool overrides everything else
830  // (But this does not do the time shift constrained to the vertical only,
831  // which is what happens when you hold Ctrl in the Time Shift tool mode)
833  view.mTimeShiftHandle, pTrack, false);
834  if (result)
835  results.push_back(result);
836  return { true, results };
837  }
838  return { false, results };
839 }

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

Here is the call graph for this function:

◆ DoGetVRulerControls()

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

Implements TrackView.

Definition at line 1040 of file WaveTrackView.cpp.

1041 {
1042  // This should never be called because of delegation to the spectrum or
1043  // waveform sub-view
1044  wxASSERT( false );
1045  return {};
1046 }

◆ DoSetDisplay()

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

Definition at line 927 of file WaveTrackView.cpp.

928 {
929  // Some generality here anticipating more than two views.
930  // The order of sub-views in the array is not specified, so make it definite
931  // by sorting by the view type constants.
932  size_t ii = 0;
933  std::vector< std::pair< WaveTrackViewConstants::Display, size_t > > pairs;
934  WaveTrackSubViews::ForEach( [&pairs, &ii]( WaveTrackSubView &subView ){
935  pairs.push_back( { subView.SubViewType().id, ii++ } );
936  } );
937  std::sort( pairs.begin(), pairs.end() );
938 
939  int jj = 1;
940  for ( const auto &pair : pairs ) {
941  auto &placement = mPlacements[ pair.second ];
942  if (pair.first == display) {
943  // 0 for first view
944  placement = { 0, 1.0 };
945  }
946  else if( exclusive )
947  // -1 for not displayed
948  placement = { -1, 0.0 };
949  else
950  // positions other than the first.
951  // (Note that the fractions in the placement don't need to be
952  // denominated to 1. Just make them all equal to get an equal
953  // partitioning of the sub-views.)
954  placement = { jj++, 1.0 };
955  }
956 }

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

1022 {
1023  BuildSubViews();
1024 
1025  // May come here. Invoke also on sub-views.
1026  TrackView::DoSetMinimized( minimized );
1027  WaveTrackSubViews::ForEach( [minimized](WaveTrackSubView &subView){
1028  subView.DoSetMinimized( minimized );
1029  } );
1030 }

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

1287 {
1288  // Should not come here, drawing is now delegated to sub-views
1289  wxASSERT( false );
1290 
1291  CommonTrackView::Draw( context, rect, iPass );
1292 }

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

769 {
770  return Get( const_cast<WaveTrack&>( track ) );
771 }

◆ Get() [2/2]

WaveTrackView & WaveTrackView::Get ( WaveTrack track)
static

Definition at line 763 of file WaveTrackView.cpp.

764 {
765  return static_cast< WaveTrackView& >( TrackView::Get( track ) );
766 }

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:

◆ GetAllSubViews()

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

Definition at line 1009 of file WaveTrackView.cpp.

1010 {
1011  BuildSubViews();
1012 
1013  std::vector< std::shared_ptr< WaveTrackSubView > > results;
1015  results.push_back( std::static_pointer_cast<WaveTrackSubView>(
1016  subView.shared_from_this() ) );
1017  } );
1018  return results;
1019 }

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

Here is the call graph for this function:

◆ GetDisplays()

auto WaveTrackView::GetDisplays ( ) const

Definition at line 841 of file WaveTrackView.cpp.

843 {
844  BuildSubViews();
845 
846  // Collect the display types of visible views and sort them by position
847  using Pair = std::pair< int, WaveTrackSubView::Type >;
848  std::vector< Pair > pairs;
849  size_t ii = 0;
850  WaveTrackSubViews::ForEach( [&]( const WaveTrackSubView &subView ){
851  auto &placement = mPlacements[ii];
852  if ( placement.fraction > 0 )
853  pairs.emplace_back( placement.index, subView.SubViewType() );
854  ++ii;
855  } );
856  std::sort( pairs.begin(), pairs.end() );
857  std::vector< WaveTrackSubView::Type > results;
858  for ( const auto &pair : pairs )
859  results.push_back( pair.second );
860  return results;
861 }

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

119 { return mLastHeight; }

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

121 { return mMultiView; }

References mMultiView.

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

Here is the caller graph for this function:

◆ GetSubViews()

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

Reimplemented from TrackView.

Definition at line 958 of file WaveTrackView.cpp.

959 {
960  BuildSubViews();
961 
962  // Collect the visible views in the right sequence
963  struct Item {
964  int index; float fraction; std::shared_ptr< TrackView > pView;
965  };
966  std::vector< Item > items;
967  size_t ii = 0;
968  float total = 0;
970  auto &placement = mPlacements[ii];
971  auto index = placement.index;
972  auto fraction = placement.fraction;
973  if ( index >= 0 && fraction > 0.0 )
974  total += fraction,
975  items.push_back( { index, fraction, subView.shared_from_this() } );
976  ++ii;
977  } );
978  std::sort( items.begin(), items.end(), [](const Item &a, const Item &b){
979  return a.index < b.index;
980  } );
981 
982  // Remove views we don't need
983  auto begin = items.begin(), end = items.end(),
984  newEnd = std::remove_if( begin, end,
985  []( const Item &item ){ return !item.pView; } );
986  items.erase( newEnd, end );
987 
988  // Assign coordinates, redenominating to the total height,
989  // storing integer values
990  Refinement results;
991  results.reserve( items.size() );
992  const auto top = rect.GetTop();
993  const auto height = rect.GetHeight();
994  float partial = 0;
995  wxCoord lastCoord = 0;
996  for ( const auto &item : items ) {
997  wxCoord newCoord = top + (partial / total) * height;
998  results.emplace_back( newCoord, item.pView );
999  partial += item.fraction;
1000  }
1001 
1002  // Cache for the use of sub-view dragging
1003  mLastHeight = height;
1004 
1005  return results;
1006 }

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

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

1249 {
1250  // BuildSubViews(); // not really needed
1251  CommonTrackView::Reparent( parent );
1252  WaveTrackSubViews::ForEach( [&parent](WaveTrackSubView &subView){
1253  subView.Reparent( parent );
1254  } );
1255 }

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

Here is the call graph for this function:

◆ RestorePlacements()

void WaveTrackView::RestorePlacements ( const WaveTrackSubViewPlacements placements)
inline

Definition at line 107 of file WaveTrackView.h.

108  { mPlacements = placements; }

References mPlacements.

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

106  { return mPlacements; }

References mPlacements.

Referenced by CopyTo().

Here is the caller graph for this function:

◆ SetDisplay()

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

Definition at line 863 of file WaveTrackView.cpp.

864 {
865  BuildSubViews();
866  DoSetDisplay( display, exclusive );
867 }

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

122 { mMultiView = value; }

References mMultiView.

◆ ToggleSubView()

bool WaveTrackView::ToggleSubView ( Display  id)

Definition at line 869 of file WaveTrackView.cpp.

870 {
871  size_t ii = 0;
872  size_t found = 0;
873  if ( WaveTrackSubViews::FindIf( [&]( const WaveTrackSubView &subView ) {
874  if ( subView.SubViewType().id == display ) {
875  found = ii;
876  return true;
877  }
878  ++ii;
879  return false;
880  } ) ) {
881  auto &foundPlacement = mPlacements[found];
882  if ( foundPlacement.fraction > 0.0 ) {
883  // Toggle off
884 
885  if (GetDisplays().size() < 2)
886  // refuse to do it
887  return false;
888 
889  auto index = foundPlacement.index;
890  foundPlacement = { -1, 0.0 };
891  if (index >= 0) {
892  for ( auto &placement : mPlacements ) {
893  if ( placement.index > index )
894  --placement.index;
895  }
896  }
897 
898  return true;
899  }
900  else {
901  // Toggle on
902  float total = 0;
903  int greatest = -1;
904  unsigned nn = 0;
905  for ( const auto &placement : mPlacements ) {
906  if ( placement.fraction > 0.0 && placement.index >= 0 ) {
907  total += placement.fraction;
908  greatest = std::max( greatest, placement.index );
909  ++nn;
910  }
911  }
912  // Turn on the sub-view, putting it lowest, and with average of the
913  // heights of the other sub-views
914  foundPlacement = { greatest + 1, total / nn };
915 
916  return true;
917  }
918  }
919  else
920  // unknown sub-view
921  return false;
922 }

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

◆ mLastHeight

wxCoord WaveTrackView::mLastHeight {}
mutableprotected

Definition at line 149 of file WaveTrackView.h.

Referenced by GetLastHeight().

◆ mMultiView

bool WaveTrackView::mMultiView { false }
protected

Definition at line 151 of file WaveTrackView.h.

Referenced by CopyTo(), GetMultiView(), and SetMultiView().

◆ mPlacements

WaveTrackSubViewPlacements WaveTrackView::mPlacements
protected

The documentation for this class was generated from the following files:
WaveTrackView::mPlacements
WaveTrackSubViewPlacements mPlacements
Definition: WaveTrackView.h:148
WaveTrackView::BuildSubViews
void BuildSubViews() const
Definition: WaveTrackView.cpp:1257
WaveTrack
A Track that contains audio waveform data.
Definition: WaveTrack.h:68
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:71
TrackView::Get
static TrackView & Get(Track &)
Definition: TrackView.cpp:63
TrackView::GetMinimized
bool GetMinimized() const
Definition: TrackView.h:49
WaveTrackView::DoSetDisplay
void DoSetDisplay(Display display, bool exclusive=true)
Definition: WaveTrackView.cpp:927
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
TrackView::Refinement
std::vector< std::pair< wxCoord, std::shared_ptr< TrackView > > > Refinement
Definition: TrackView.h:73
ClientData::Site::size
size_t size() const
How many attachment pointers are in the Site.
Definition: ClientData.h:251
WaveTrackSubView
Definition: WaveTrackView.h:25
TracksPrefs::ViewModeChoice
static WaveTrackViewConstants::Display ViewModeChoice()
Definition: TracksPrefs.cpp:168
WaveTrackView::mMultiView
bool mMultiView
Definition: WaveTrackView.h:151
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:96
TrackView::DoSetMinimized
virtual void DoSetMinimized(bool isMinimized)
Definition: TrackView.cpp:122
WaveTrackView::SavePlacements
const WaveTrackSubViewPlacements & SavePlacements() const
Definition: WaveTrackView.h:105
WaveTrackView::GetDisplays
std::vector< WaveTrackSubView::Type > GetDisplays() const
Definition: WaveTrackView.cpp:841
WaveTrackView::Get
static WaveTrackView & Get(WaveTrack &track)
Definition: WaveTrackView.cpp:763
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
CommonTrackCell::Reparent
virtual void Reparent(const std::shared_ptr< Track > &parent)
Definition: CommonTrackPanelCell.cpp:64
WaveTrackView::mLastHeight
wxCoord mLastHeight
Definition: WaveTrackView.h:149
TimeShiftHandle::HitAnywhere
static UIHandlePtr HitAnywhere(std::weak_ptr< TimeShiftHandle > &holder, const std::shared_ptr< Track > &pTrack, bool gripHit)
Definition: TimeShiftHandle.cpp:65
WaveTrackViewConstants::MultiView
@ MultiView
"Multi" is special, not really a view type on par with the others.
Definition: WaveTrackViewConstants.h:20
TrackPanelDrawable::Draw
virtual void Draw(TrackPanelDrawingContext &context, const wxRect &rect, unsigned iPass)
Definition: TrackPanelDrawable.cpp:17