Audacity  3.0.3
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
TrackView Class Referenceabstract

#include <TrackView.h>

Inheritance diagram for TrackView:
Collaboration diagram for TrackView:

Public Types

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 Member Functions

 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
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
bool HandleXMLAttribute (const wxChar *attr, const wxChar *value) override
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
virtual void Reparent (const std::shared_ptr< Track > &parent)
- 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 std::vector< UIHandlePtrHitTest (const TrackPanelMouseState &state, const AudacityProject *pProject)=0
virtual std::shared_ptr< TrackPanelCellContextMenuDelegate ()
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 void Draw (TrackPanelDrawingContext &context, const wxRect &rect, unsigned iPass)
virtual wxRect DrawingArea (TrackPanelDrawingContext &context, const wxRect &rect, const wxRect &panelRect, unsigned iPass)

Static Public Member Functions

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)

Protected Member Functions

virtual std::shared_ptr< TrackVRulerControlsDoGetVRulerControls ()=0
- 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 Attributes

std::shared_ptr< TrackVRulerControlsmpVRulerControls

Private Member Functions

 TrackView (const TrackView &)=delete
TrackViewoperator= (const TrackView &)=delete
void DoSetY (int y)
void DoSetHeight (int h)

Private Attributes

bool mMinimized { false }
int mY { 0 }
int mHeight { DefaultHeight }

Detailed Description

Definition at line 22 of file TrackView.h.

Member Typedef Documentation

◆ Refinement

using TrackView::Refinement = std::vector< std::pair< wxCoord, std::shared_ptr< TrackView > > >

Definition at line 97 of file TrackView.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum : unsigned

Definition at line 29 of file TrackView.h.

29 : unsigned { DefaultHeight = 150 };

Constructor & Destructor Documentation

◆ TrackView() [1/2]

TrackView::TrackView ( const TrackView )

◆ TrackView() [2/2]

TrackView::TrackView ( const std::shared_ptr< Track > &  pTrack)

Definition at line 19 of file TrackView.cpp.

20  : CommonTrackCell{ pTrack }
21 {
23 }

◆ ~TrackView()

TrackView::~TrackView ( )
pure virtual

Definition at line 25 of file TrackView.cpp.

26 {
27 }

Member Function Documentation

◆ CopyTo()

void TrackView::CopyTo ( Track track) const

Reimplemented from CommonTrackCell.

Definition at line 52 of file TrackView.cpp.

53 {
54  auto &other = Get( track );
56  other.mMinimized = mMinimized;
58  // Let mY remain 0 -- TrackPositioner corrects it later
59  other.mY = 0;
60  other.mHeight = mHeight;
61 }

References Get(), mHeight, and mMinimized.

Referenced by LabelTrackView::CopyTo(), and WaveTrackView::CopyTo().

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

◆ DoGetVRulerControls()

virtual std::shared_ptr<TrackVRulerControls> TrackView::DoGetVRulerControls ( )
protectedpure virtual

Implemented in TimeTrackView, WaveTrackView, WaveformView, SpectrumView, NoteTrackView, and LabelTrackView.

Referenced by GetVRulerControls().

Here is the caller graph for this function:

◆ DoSetHeight()

void TrackView::DoSetHeight ( int  h)

Definition at line 163 of file TrackView.cpp.

164 {
165  mHeight = h;
166 }

References mHeight.

Referenced by SetExpandedHeight().

Here is the caller graph for this function:

◆ DoSetMinimized()

void TrackView::DoSetMinimized ( bool  isMinimized)

Reimplemented in WaveTrackView, WaveformView, and SpectrumView.

Definition at line 126 of file TrackView.cpp.

127 {
128  mMinimized = isMinimized;
129 }

References mMinimized.

Referenced by WaveTrackView::BuildSubViews(), SpectrumView::DoSetMinimized(), WaveformView::DoSetMinimized(), WaveTrackView::DoSetMinimized(), and SetMinimized().

Here is the caller graph for this function:

◆ DoSetY()

void TrackView::DoSetY ( int  y)

Definition at line 144 of file TrackView.cpp.

145 {
146  mY = y;
147 }

References mY.

◆ Get() [1/2]

const TrackView & TrackView::Get ( const Track track)

Definition at line 72 of file TrackView.cpp.

73 {
74  return Get( const_cast< Track& >( track ) );
75 }

References Get().

Here is the call graph for this function:

◆ Get() [2/2]

TrackView & TrackView::Get ( Track track)

Definition at line 63 of file TrackView.cpp.

64 {
65  auto pView = std::static_pointer_cast<TrackView>( track.GetTrackView() );
66  if (!pView)
67  // create on demand
68  track.SetTrackView( pView = DoGetView::Call( track ) );
69  return *pView;
70 }

References AttachedVirtualFunction< Tag, Return, This, Arguments >::Call(), Track::GetTrackView(), and Track::SetTrackView().

Referenced by SetTrackVisualsCommand::ApplyInner(), TrackPanelResizeHandle::Cancel(), anonymous_namespace{TrackPanel.cpp}::Subgroup::Children(), anonymous_namespace{TrackPanel.cpp}::ChannelGroup::Children(), TrackPanelResizeHandle::Click(), LabelDefaultClickHandle::Click(), MinimizeButtonHandle::CommitChanges(), LabelTrackView::CopyTo(), WaveTrackView::CopyTo(), CopyTo(), ProjectAudioManager::DoRecord(), anonymous_namespace{ViewMenus.cpp}::DoZoomFitV(), TrackPanelResizeHandle::Drag(), anonymous_namespace{TrackPanel.cpp}::ChannelGroup::Draw(), anonymous_namespace{TrackPanel.cpp}::DrawTrackName(), anonymous_namespace{TrackPanel.cpp}::FindAdjustedChannelHeights(), Get(), LabelTrackView::Get(), WaveTrackView::Get(), GetCumulativeHeight(), TrackPanel::GetFocusedCell(), WaveTrackSubView::GetMenuItems(), GetTrackHeight(), TrackInfo::MinimizeSyncLockDrawFunction(), ViewActions::Handler::OnCollapseAllTracks(), ViewActions::Handler::OnExpandAllTracks(), WaveTrackMenuTable::OnMergeStereo(), AudacityPrintout::OnPrintPage(), ScreenshotBigDialog::OnShortTracks(), SelectHandle::TimerHandler::OnTimer(), TrackPanel::OnTrackMenu(), anonymous_namespace{TrackView.cpp}::TrackPositioner::OnUpdate(), SpectralDataManager::ProcessTracks(), TrackPanel::RefreshTrack(), ScreenshotBigDialog::SizeTracks(), WaveTrackMenuTable::SplitStereo(), MinimizeButtonHandle::Tip(), and TrackPanel::UpdateTrackVRuler().

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

◆ GetAffordanceControls()

std::shared_ptr< CommonTrackCell > TrackView::GetAffordanceControls ( )

Reimplemented in WaveTrackView, and NoteTrackView.

Definition at line 168 of file TrackView.cpp.

169 {
170  return {};
171 }

◆ GetChannelGroupHeight()

int TrackView::GetChannelGroupHeight ( const Track pTrack)

Definition at line 34 of file TrackView.cpp.

35 {
36  return pTrack ? TrackList::Channels( pTrack ).sum( GetTrackHeight ) : 0;
37 }

References TrackList::Channels(), and GetTrackHeight().

Referenced by TrackSelectHandle::CalculateRearrangingThresholds(), and TrackPanel::VerticalScroll().

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

◆ GetCumulativeHeight()

int TrackView::GetCumulativeHeight ( const Track pTrack)

Definition at line 39 of file TrackView.cpp.

40 {
41  if ( !pTrack )
42  return 0;
43  auto &view = Get( *pTrack );
44  return view.GetCumulativeHeightBefore() + view.GetHeight();
45 }

References Get().

Referenced by GetTotalHeight(), and anonymous_namespace{TrackView.cpp}::TrackPositioner::OnUpdate().

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

◆ GetCumulativeHeightBefore()

int TrackView::GetCumulativeHeightBefore ( ) const
cached sum of GetHeight() of all preceding tracks

Definition at line 53 of file TrackView.h.

53 { return mY; }

◆ GetExpandedHeight()

int TrackView::GetExpandedHeight ( ) const
height of the track when expanded

See other comments for GetHeight

Definition at line 57 of file TrackView.h.

57 { return mHeight; }

Referenced by WriteXMLAttributes().

Here is the caller graph for this function:

◆ GetHeight()

int TrackView::GetHeight ( ) const
height of the track as it now appears, expanded or collapsed

Total "height" of channels of a track includes padding areas above and below it, and is pixel-accurate for the channel group. The "heights" of channels within a group determine the proportions of heights of the track data shown – but the actual total pixel heights may differ when other fixed-height adornments and paddings are added, according to other rules for allocation of height.

Definition at line 149 of file TrackView.cpp.

150 {
151  if ( GetMinimized() )
152  return GetMinimizedHeight();
154  return mHeight;
155 }

References GetMinimized(), GetMinimizedHeight(), and mHeight.

Referenced by TrackPanelResizeHandle::Click(), anonymous_namespace{TrackPanel.cpp}::DrawTrackName(), and GetTrackHeight().

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

◆ GetMinimized()

bool TrackView::GetMinimized ( ) const

Definition at line 49 of file TrackView.h.

49 { return mMinimized; }

Referenced by WaveTrackView::BuildSubViews(), TrackPanelResizeHandle::Click(), MinimizeButtonHandle::CommitChanges(), anonymous_namespace{ViewMenus.cpp}::DoZoomFitV(), GetHeight(), TrackInfo::MinimizeSyncLockDrawFunction(), WaveTrackMenuTable::OnMergeStereo(), MinimizeButtonHandle::Tip(), and WriteXMLAttributes().

Here is the caller graph for this function:

◆ GetMinimizedHeight()

virtual int TrackView::GetMinimizedHeight ( ) const
pure virtual
height of the track when collapsed

See other comments for GetHeight

Implemented in CommonTrackView.

Referenced by GetHeight().

Here is the caller graph for this function:

◆ GetSubViews()

auto TrackView::GetSubViews ( const wxRect &  rect)

Reimplemented in WaveTrackView.

Definition at line 116 of file TrackView.cpp.

117 {
118  return { { rect.GetTop(), shared_from_this() } };
119 }

Referenced by anonymous_namespace{TrackPanel.cpp}::ChannelGroup::Children().

Here is the caller graph for this function:

◆ GetTotalHeight()

int TrackView::GetTotalHeight ( const TrackList list)

Definition at line 47 of file TrackView.cpp.

48 {
49  return GetCumulativeHeight( *list.Any().rbegin() );
50 }

References TrackList::Any(), and GetCumulativeHeight().

Referenced by ProjectWindow::FixScrollbars(), and AudacityPrintout::OnPrintPage().

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

◆ GetTrackHeight()

int TrackView::GetTrackHeight ( const Track pTrack)

Definition at line 29 of file TrackView.cpp.

30 {
31  return pTrack ? Get( *pTrack ).GetHeight() : 0;
32 }

References Get(), and GetHeight().

Referenced by anonymous_namespace{ViewMenus.cpp}::DoZoomFitV(), GetChannelGroupHeight(), TrackPanel::OnEnsureVisible(), and TrackPanel::RefreshTrack().

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

◆ GetVRulerControls() [1/2]

std::shared_ptr< TrackVRulerControls > TrackView::GetVRulerControls ( )

Definition at line 131 of file TrackView.cpp.

132 {
133  if (!mpVRulerControls)
134  // create on demand
136  return mpVRulerControls;
137 }

References DoGetVRulerControls(), and mpVRulerControls.

Referenced by TrackVRulerControls::Get(), and GetVRulerControls().

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

◆ GetVRulerControls() [2/2]

std::shared_ptr< const TrackVRulerControls > TrackView::GetVRulerControls ( ) const

Definition at line 139 of file TrackView.cpp.

140 {
141  return const_cast< TrackView* >( this )->GetVRulerControls();
142 }

References GetVRulerControls().

Here is the call graph for this function:

◆ HandleXMLAttribute()

bool TrackView::HandleXMLAttribute ( const wxChar *  attr,
const wxChar *  value 

Reimplemented from CommonTrackCell.

Definition at line 94 of file TrackView.cpp.

95 {
96  wxString strValue( value );
97  long nValue;
98  if (!wxStrcmp(attr, wxT("height")) &&
99  XMLValueChecker::IsGoodInt(strValue) && strValue.ToLong(&nValue)) {
100  // Bug 2803: Extreme values for track height (caused by integer overflow)
101  // will stall Audacity as it tries to create an enormous vertical ruler.
102  // So clamp to reasonable values.
103  nValue = std::max( 40l, std::min( nValue, 1000l ));
104  SetExpandedHeight(nValue);
105  return true;
106  }
107  else if (!wxStrcmp(attr, wxT("minimized")) &&
108  XMLValueChecker::IsGoodInt(strValue) && strValue.ToLong(&nValue)) {
109  SetMinimized(nValue != 0);
110  return true;
111  }
112  else
113  return false;
114 }

References XMLValueChecker::IsGoodInt(), min(), SetExpandedHeight(), and SetMinimized().

Here is the call graph for this function:

◆ IsSpectral()

bool TrackView::IsSpectral ( ) const

Reimplemented in SpectrumView.

Definition at line 121 of file TrackView.cpp.

122 {
123  return false;
124 }

Referenced by anonymous_namespace{BrushHandle.cpp}::isSpectralSelectionView(), and anonymous_namespace{SelectHandle.cpp}::isSpectralSelectionView().

Here is the caller graph for this function:

◆ operator=()

TrackView& TrackView::operator= ( const TrackView )

◆ SetCumulativeHeightBefore()

void TrackView::SetCumulativeHeightBefore ( int  y)

Set cached value dependent on position within the track list.

Definition at line 75 of file TrackView.h.

75 { DoSetY( y ); }

◆ SetExpandedHeight()

void TrackView::SetExpandedHeight ( int  height)

Sets height for expanded state. Does not expand a track if it is now collapsed. See other comments for GetHeight

Definition at line 157 of file TrackView.cpp.

158 {
159  DoSetHeight(h);
160  FindTrack()->AdjustPositions();
161 }

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

Referenced by SetTrackVisualsCommand::ApplyInner(), TrackPanelResizeHandle::Click(), anonymous_namespace{ViewMenus.cpp}::DoZoomFitV(), HandleXMLAttribute(), ScreenshotBigDialog::SizeTracks(), and WaveTrackMenuTable::SplitStereo().

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

◆ SetMinimized()

void TrackView::SetMinimized ( bool  minimized)

Definition at line 77 of file TrackView.cpp.

78 {
79  // Do special changes appropriate to subclass
80  DoSetMinimized(isMinimized);
82  // Update positions and heights starting from the first track in the group
83  auto leader = *TrackList::Channels( FindTrack().get() ).begin();
84  if ( leader )
85  leader->AdjustPositions();
86 }

References TrackList::Channels(), DoSetMinimized(), and CommonTrackPanelCell::FindTrack().

Referenced by MinimizeButtonHandle::CommitChanges(), ProjectAudioManager::DoRecord(), HandleXMLAttribute(), ViewActions::Handler::OnCollapseAllTracks(), and ViewActions::Handler::OnExpandAllTracks().

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

◆ WriteXMLAttributes()

void TrackView::WriteXMLAttributes ( XMLWriter xmlFile) const

Reimplemented from CommonTrackCell.

Definition at line 88 of file TrackView.cpp.

89 {
90  xmlFile.WriteAttr(wxT("height"), GetExpandedHeight());
91  xmlFile.WriteAttr(wxT("minimized"), GetMinimized());
92 }

References GetExpandedHeight(), GetMinimized(), and XMLWriter::WriteAttr().

Here is the call graph for this function:

Member Data Documentation

◆ mHeight

int TrackView::mHeight { DefaultHeight }

Definition at line 125 of file TrackView.h.

Referenced by CopyTo(), DoSetHeight(), and GetHeight().

◆ mMinimized

bool TrackView::mMinimized { false }

Definition at line 123 of file TrackView.h.

Referenced by CopyTo(), and DoSetMinimized().

◆ mpVRulerControls

std::shared_ptr<TrackVRulerControls> TrackView::mpVRulerControls

Definition at line 120 of file TrackView.h.

Referenced by GetVRulerControls().

◆ mY

int TrackView::mY { 0 }

Definition at line 124 of file TrackView.h.

Referenced by DoSetY().

The documentation for this class was generated from the following files:
void DoSetHeight(int h)
Definition: TrackView.cpp:163
@ DefaultHeight
Definition: TrackView.h:29
bool mMinimized
Definition: TrackView.h:123
static TrackView & Get(Track &)
Definition: TrackView.cpp:63
void SetMinimized(bool minimized)
Definition: TrackView.cpp:77
static bool IsGoodInt(const wxString &strInt)
Check that the supplied string can be converted to a long (32bit) integer.
Definition: XMLTagHandler.cpp:157
static Return Call(This &obj, Arguments &&...arguments)
Invoke the method – but only after static initialization time.
Definition: AttachedVirtualFunction.h:223
bool GetMinimized() const
Definition: TrackView.h:49
static int GetCumulativeHeight(const Track *pTrack)
Definition: TrackView.cpp:39
void SetTrackView(const std::shared_ptr< CommonTrackCell > &pView)
Definition: Track.cpp:149
std::shared_ptr< Track > FindTrack()
Definition: CommonTrackPanelCell.h:46
static auto Channels(TrackType *pTrack) -> TrackIterRange< TrackType >
Definition: Track.h:1484
void SetExpandedHeight(int height)
Definition: TrackView.cpp:157
static int GetTrackHeight(const Track *pTrack)
Definition: TrackView.cpp:29
int mY
Definition: TrackView.h:124
std::shared_ptr< TrackVRulerControls > mpVRulerControls
Definition: TrackView.h:120
const std::shared_ptr< CommonTrackCell > & GetTrackView()
Definition: Track.cpp:144
std::shared_ptr< TrackVRulerControls > GetVRulerControls()
Definition: TrackView.cpp:131
virtual void DoSetMinimized(bool isMinimized)
Definition: TrackView.cpp:126
int GetExpandedHeight() const
Definition: TrackView.h:57
int min(int a, int b)
Definition: CompareAudioCommand.cpp:106
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:239
Definition: TrackView.h:24
void DoSetY(int y)
Definition: TrackView.cpp:144
void WriteAttr(const wxString &name, const Identifier &value)
Definition: XMLWriter.h:34
auto Any() -> TrackIterRange< TrackType >
Definition: Track.h:1371
virtual int GetMinimizedHeight() const =0
int mHeight
Definition: TrackView.h:125
int GetHeight() const
Definition: TrackView.cpp:149
Definition: CommonTrackPanelCell.h:99
virtual std::shared_ptr< TrackVRulerControls > DoGetVRulerControls()=0