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

 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 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)
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 ()
- Public Member Functions inherited from ClientData::Base
virtual ~Base ()

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 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)

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 23 of file TrackView.h.

Member Typedef Documentation

◆ Refinement

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

Definition at line 102 of file TrackView.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum : unsigned

Definition at line 30 of file TrackView.h.

30 : 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

Copy state, for undo/redo purposes.

Reimplemented from TrackAttachment.

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 178 of file TrackView.cpp.

179 {
180  mHeight = h;
181 }

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 141 of file TrackView.cpp.

142 {
143  mMinimized = isMinimized;
144 }

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 159 of file TrackView.cpp.

160 {
161  mY = y;
162 }

References mY.

◆ Find() [1/2]

const TrackView * TrackView::Find ( const Track pTrack)

Definition at line 88 of file TrackView.cpp.

89 {
90  return Find( const_cast< Track* >( pTrack ) );
91 }

References Find().

Here is the call graph for this function:

◆ Find() [2/2]

TrackView * TrackView::Find ( Track pTrack)

Definition at line 79 of file TrackView.cpp.

80 {
81  if (!pTrack)
82  return nullptr;
83  auto &track = *pTrack;
84  // do not create on demand if it is null
85  return track.AttachedObjects::Find< TrackView >( key );
86 }

References key.

Referenced by Find(), and WaveTrackView::Find().

Here is the caller graph for this function:

◆ Get() [1/2]

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

Definition at line 74 of file TrackView.cpp.

75 {
76  return Get( const_cast< Track & >( track ) );
77 }

References Get().

Here is the call graph for this function:

◆ Get() [2/2]

TrackView & TrackView::Get ( Track track)

Definition at line 69 of file TrackView.cpp.

70 {
71  return track.AttachedObjects::Get< TrackView >( key );
72 }

References key.

Referenced by SetTrackVisualsCommand::ApplyInner(), TrackPanelResizeHandle::Cancel(), anonymous_namespace{TrackPanel.cpp}::Subgroup::Children(), anonymous_namespace{TrackPanel.cpp}::ChannelGroup::Children(), TrackPanelResizeHandle::Click(), LabelDefaultClickHandle::Click(), MinimizeButtonHandle::CommitChanges(), WaveTrackView::CopySelectedText(), LabelTrackView::CopyTo(), WaveTrackView::CopyTo(), CopyTo(), WaveTrackView::CutSelectedText(), 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(), anonymous_namespace{WaveTrackAffordanceControls.cpp}::FindAffordance(), SpectrumView::ForAll(), Get(), LabelTrackView::Get(), WaveTrackView::Get(), GetCumulativeHeight(), TrackPanel::GetFocusedCell(), GetTrackHeight(), NoteTrackAffordanceControls::HitTest(), WaveTrackAffordanceControls::HitTest(), 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(), WaveTrackView::PasteText(), SpectralDataManager::ProcessTracks(), TrackPanel::RefreshTrack(), WaveTrackView::SelectAllText(), ScreenshotBigDialog::SizeTracks(), WaveTrackMenuTable::SplitStereo(), MinimizeButtonHandle::Tip(), and TrackPanel::UpdateTrackVRuler().

Here is the caller graph for this function:

◆ GetAffordanceControls()

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

Reimplemented in WaveTrackView, and NoteTrackView.

Definition at line 183 of file TrackView.cpp.

184 {
185  return {};
186 }

◆ 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 56 of file TrackView.h.

56 { return mY; }

◆ GetExpandedHeight()

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

See other comments for GetHeight

Definition at line 60 of file TrackView.h.

60 { 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 164 of file TrackView.cpp.

165 {
166  if ( GetMinimized() )
167  return GetMinimizedHeight();
169  return mHeight;
170 }

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 52 of file TrackView.h.

52 { 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 131 of file TrackView.cpp.

132 {
133  return { { rect.GetTop(), shared_from_this() } };
134 }

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 146 of file TrackView.cpp.

147 {
148  if (!mpVRulerControls)
149  // create on demand
151  return mpVRulerControls;
152 }

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 154 of file TrackView.cpp.

155 {
156  return const_cast< TrackView* >( this )->GetVRulerControls();
157 }

References GetVRulerControls().

Here is the call graph for this function:

◆ HandleXMLAttribute()

bool TrackView::HandleXMLAttribute ( const std::string_view &  attr,
const XMLAttributeValueView valueView 

Deserialize an attribute, returning true if recognized.

default recognizes no attributes, and returns false

Reimplemented from TrackAttachment.

Definition at line 110 of file TrackView.cpp.

112 {
113  long nValue;
115  if (attr == "height" && valueView.TryGet(nValue)) {
116  // Bug 2803: Extreme values for track height (caused by integer overflow)
117  // will stall Audacity as it tries to create an enormous vertical ruler.
118  // So clamp to reasonable values.
119  nValue = std::max( 40l, std::min( nValue, 1000l ));
120  SetExpandedHeight(nValue);
121  return true;
122  }
123  else if ( attr == "minimized" && valueView.TryGet(nValue)) {
124  SetMinimized(nValue != 0);
125  return true;
126  }
127  else
128  return false;
129 }

References min(), SetExpandedHeight(), SetMinimized(), and XMLAttributeValueView::TryGet().

Here is the call graph for this function:

◆ IsSpectral()

bool TrackView::IsSpectral ( ) const

Reimplemented in SpectrumView.

Definition at line 136 of file TrackView.cpp.

137 {
138  return false;
139 }

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 78 of file TrackView.h.

78 { 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 172 of file TrackView.cpp.

173 {
174  DoSetHeight(h);
175  FindTrack()->AdjustPositions();
176 }

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 93 of file TrackView.cpp.

94 {
95  // Do special changes appropriate to subclass
96  DoSetMinimized(isMinimized);
98  // Update positions and heights starting from the first track in the group
99  auto leader = *TrackList::Channels( FindTrack().get() ).begin();
100  if ( leader )
101  leader->AdjustPositions();
102 }

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 ) const

Serialize persistent attributes.

default does nothing

Reimplemented from TrackAttachment.

Definition at line 104 of file TrackView.cpp.

105 {
106  xmlFile.WriteAttr(wxT("height"), GetExpandedHeight());
107  xmlFile.WriteAttr(wxT("minimized"), GetMinimized());
108 }

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 130 of file TrackView.h.

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

◆ mMinimized

bool TrackView::mMinimized { false }

Definition at line 128 of file TrackView.h.

Referenced by CopyTo(), and DoSetMinimized().

◆ mpVRulerControls

std::shared_ptr<TrackVRulerControls> TrackView::mpVRulerControls

Definition at line 125 of file TrackView.h.

Referenced by GetVRulerControls().

◆ mY

int TrackView::mY { 0 }

Definition at line 129 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:178
@ DefaultHeight
Definition: TrackView.h:30
bool mMinimized
Definition: TrackView.h:128
static TrackView & Get(Track &)
Definition: TrackView.cpp:69
void SetMinimized(bool minimized)
Definition: TrackView.cpp:93
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:52
static int GetCumulativeHeight(const Track *pTrack)
Definition: TrackView.cpp:39
std::shared_ptr< Track > FindTrack()
Definition: CommonTrackPanelCell.h:47
static auto Channels(TrackType *pTrack) -> TrackIterRange< TrackType >
Definition: Track.h:1483
void SetExpandedHeight(int height)
Definition: TrackView.cpp:172
static TrackView * Find(Track *)
Definition: TrackView.cpp:79
static int GetTrackHeight(const Track *pTrack)
Definition: TrackView.cpp:29
bool TryGet(bool &value) const noexcept
Try to get a boolean value from the view.
Definition: XMLAttributeValueView.cpp:125
static const AttachedTrackObjects::RegisteredFactory key
Definition: TrackView.cpp:63
int mY
Definition: TrackView.h:129
std::shared_ptr< TrackVRulerControls > mpVRulerControls
Definition: TrackView.h:125
std::shared_ptr< TrackVRulerControls > GetVRulerControls()
Definition: TrackView.cpp:146
virtual void DoSetMinimized(bool isMinimized)
Definition: TrackView.cpp:141
int GetExpandedHeight() const
Definition: TrackView.h:60
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:224
Definition: TrackView.h:25
void DoSetY(int y)
Definition: TrackView.cpp:159
auto Any() -> TrackIterRange< TrackType >
Definition: Track.h:1379
virtual int GetMinimizedHeight() const =0
int mHeight
Definition: TrackView.h:130
int GetHeight() const
Definition: TrackView.cpp:164
Definition: CommonTrackPanelCell.h:100
virtual std::shared_ptr< TrackVRulerControls > DoGetVRulerControls()=0