Audacity 3.2.0
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
CommonTrackView Class Referenceabstract

#include <CommonTrackView.h>

Inheritance diagram for CommonTrackView:
[legend]
Collaboration diagram for CommonTrackView:
[legend]

Public Member Functions

std::shared_ptr< TrackPanelCellContextMenuDelegate () override
 
std::vector< UIHandlePtrHitTest (const TrackPanelMouseState &, const AudacityProject *pProject) final override
 
void TimeShiftHitTest ()
 
virtual int GetMinimizedHeight () const override
 
 TrackView (const std::shared_ptr< Track > &pTrack)
 
- Public Member Functions inherited from TrackView
 TrackView (const std::shared_ptr< Track > &pTrack)
 
virtual ~TrackView ()=0
 
void CopyTo (Track &track) const override
 Copy state, for undo/redo purposes. More...
 
bool GetMinimized () const
 
void SetMinimized (bool minimized)
 
int GetCumulativeHeightBefore () const
 
int GetExpandedHeight () const
 
virtual int GetMinimizedHeight () const =0
 
int GetHeight () const
 
void SetCumulativeHeightBefore (int y)
 Set cached value dependent on position within the track list. More...
 
void SetExpandedHeight (int height)
 
std::shared_ptr< TrackVRulerControlsGetVRulerControls ()
 
std::shared_ptr< const TrackVRulerControlsGetVRulerControls () const
 
virtual std::shared_ptr< CommonTrackCellGetAffordanceControls ()
 
void WriteXMLAttributes (XMLWriter &) const override
 Serialize persistent attributes. More...
 
bool HandleXMLAttribute (const std::string_view &attr, const XMLAttributeValueView &valueView) override
 Deserialize an attribute, returning true if recognized. More...
 
virtual Refinement GetSubViews (const wxRect &rect)
 
virtual bool IsSpectral () const
 
virtual void DoSetMinimized (bool isMinimized)
 
- Public Member Functions inherited from CommonTrackCell
 CommonTrackCell (const std::shared_ptr< Track > &pTrack)
 
 ~CommonTrackCell ()
 
std::shared_ptr< TrackDoFindTrack () override
 
void Reparent (const std::shared_ptr< Track > &parent) override
 Object may be shared among tracks but hold a special back-pointer to one of them; reassign it. More...
 
- Public Member Functions inherited from CommonTrackPanelCell
 CommonTrackPanelCell ()
 
virtual ~CommonTrackPanelCell ()=0
 
HitTestPreview DefaultPreview (const TrackPanelMouseState &, const AudacityProject *) override
 
std::shared_ptr< TrackFindTrack ()
 
std::shared_ptr< const TrackFindTrack () const
 
virtual std::vector< MenuItemGetMenuItems (const wxRect &rect, const wxPoint *pPosition, AudacityProject *pProject)
 Return a list of items for DoContextMenu() (empties for separators) More...
 
- Public Member Functions inherited from TrackPanelCell
 TrackPanelCell ()=default
 
 TrackPanelCell (const TrackPanelCell &) PROHIBITED
 
TrackPanelCelloperator= (const TrackPanelCell &) PROHIBITED
 
virtual ~TrackPanelCell ()=0
 
virtual HitTestPreview DefaultPreview (const TrackPanelMouseState &state, const AudacityProject *pProject)
 
virtual std::vector< UIHandlePtrHitTest (const TrackPanelMouseState &state, const AudacityProject *pProject)=0
 
virtual unsigned HandleWheelRotation (const TrackPanelMouseEvent &event, AudacityProject *pProject)
 
virtual std::shared_ptr< TrackPanelCellContextMenuDelegate ()
 
virtual unsigned DoContextMenu (const wxRect &rect, wxWindow *pParent, const wxPoint *pPosition, AudacityProject *pProject)
 
virtual unsigned CaptureKey (wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent, AudacityProject *project)
 
virtual unsigned KeyDown (wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent, AudacityProject *project)
 
virtual unsigned KeyUp (wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent, AudacityProject *project)
 
virtual unsigned Char (wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent, AudacityProject *project)
 
virtual unsigned LoseFocus (AudacityProject *project)
 
- Public Member Functions inherited from TrackPanelNode
 TrackPanelNode ()
 
virtual ~TrackPanelNode ()=0
 
- Public Member Functions inherited from TrackPanelDrawable
virtual ~TrackPanelDrawable ()=0
 
virtual void Draw (TrackPanelDrawingContext &context, const wxRect &rect, unsigned iPass)
 
virtual wxRect DrawingArea (TrackPanelDrawingContext &context, const wxRect &rect, const wxRect &panelRect, unsigned iPass)
 
- Public Member Functions inherited from TrackAttachment
virtual ~TrackAttachment ()
 
virtual void CopyTo (Track &track) const
 Copy state, for undo/redo purposes. More...
 
virtual void Reparent (const std::shared_ptr< Track > &parent)
 Object may be shared among tracks but hold a special back-pointer to one of them; reassign it. More...
 
virtual void WriteXMLAttributes (XMLWriter &) const
 Serialize persistent attributes. More...
 
virtual bool HandleXMLAttribute (const std::string_view &attr, const XMLAttributeValueView &valueView)
 Deserialize an attribute, returning true if recognized. More...
 
- Public Member Functions inherited from ClientData::Base
virtual ~Base ()
 

Static Public Member Functions

static void GetEnvelopeValues (const Envelope &env, double aligned_time, double sampleDur, double *buffer, int bufferLen, int leftOffset, const ZoomInfo &zoomInfo)
 Get many envelope points for pixel columns at once, but don't assume uniform time per pixel. More...
 
- Static Public Member Functions inherited from TrackView
static int GetTrackHeight (const Track *pTrack)
 
static int GetChannelGroupHeight (const Track *pTrack)
 
static int GetCumulativeHeight (const Track *pTrack)
 
static int GetTotalHeight (const TrackList &list)
 
static TrackViewGet (Track &)
 
static const TrackViewGet (const Track &)
 
static TrackViewFind (Track *)
 
static const TrackViewFind (const Track *)
 
- Static Public Member Functions inherited from TrackPanelDrawable
static wxRect MaximizeWidth (const wxRect &rect, const wxRect &panelRect)
 
static wxRect MaximizeHeight (const wxRect &rect, const wxRect &panelRect)
 

Public Attributes

std::weak_ptr< TimeShiftHandlemTimeShiftHandle
 

Protected Member Functions

virtual std::vector< UIHandlePtrDetailedHitTest (const TrackPanelMouseState &, const AudacityProject *pProject, int currentTool, bool bMultiTool)=0
 
- Protected Member Functions inherited from TrackView
virtual std::shared_ptr< TrackVRulerControlsDoGetVRulerControls ()=0
 
- Protected Member Functions inherited from CommonTrackPanelCell
virtual std::shared_ptr< TrackDoFindTrack ()=0
 
unsigned DoContextMenu (const wxRect &rect, wxWindow *pParent, const wxPoint *pPosition, AudacityProject *pProject) override
 
unsigned HandleWheelRotation (const TrackPanelMouseEvent &event, AudacityProject *pProject) override
 

Protected Attributes

std::weak_ptr< SelectHandlemSelectHandle
 
- Protected Attributes inherited from TrackView
std::shared_ptr< TrackVRulerControlsmpVRulerControls
 

Additional Inherited Members

- Public Types inherited from TrackView
enum  : unsigned { DefaultHeight = 150 }
 
using Refinement = std::vector< std::pair< wxCoord, std::shared_ptr< TrackView > > >
 

Detailed Description

Definition at line 21 of file CommonTrackView.h.

Member Function Documentation

◆ ContextMenuDelegate()

std::shared_ptr< TrackPanelCell > CommonTrackView::ContextMenuDelegate ( )
overridevirtual

Reimplemented from TrackPanelCell.

Definition at line 76 of file CommonTrackView.cpp.

77{
78 return TrackControls::Get( *FindTrack() ).shared_from_this();
79}
std::shared_ptr< Track > FindTrack()
static TrackControls & Get(Track &track)

References CommonTrackPanelCell::FindTrack(), and TrackControls::Get().

Here is the call graph for this function:

◆ DetailedHitTest()

virtual std::vector< UIHandlePtr > CommonTrackView::DetailedHitTest ( const TrackPanelMouseState ,
const AudacityProject pProject,
int  currentTool,
bool  bMultiTool 
)
protectedpure virtual

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

Referenced by HitTest().

Here is the caller graph for this function:

◆ GetEnvelopeValues()

void CommonTrackView::GetEnvelopeValues ( const Envelope env,
double  aligned_time,
double  sampleDur,
double *  buffer,
int  bufferLen,
int  leftOffset,
const ZoomInfo zoomInfo 
)
static

Get many envelope points for pixel columns at once, but don't assume uniform time per pixel.

Definition at line 95 of file CommonTrackView.cpp.

99{
100 // Getting many envelope values, corresponding to pixel columns, which may
101 // not be uniformly spaced in time when there is a fisheye.
102
103 double prevDiscreteTime=0.0, prevSampleVal=0.0, nextSampleVal=0.0;
104 for ( int xx = 0; xx < bufferLen; ++xx ) {
105 auto time = zoomInfo.PositionToTime( xx, -leftOffset );
106 if ( sampleDur <= 0 )
107 // Sample interval not defined (as for time track)
108 buffer[xx] = env.GetValue( time );
109 else {
110 // The level of zoom-in may resolve individual samples.
111 // If so, then instead of evaluating the envelope directly,
112 // we draw a piecewise curve with knees at each sample time.
113 // This actually makes clearer what happens as you drag envelope
114 // points and make discontinuities.
115 auto leftDiscreteTime = alignedTime +
116 sampleDur * floor( ( time - alignedTime ) / sampleDur );
117 if ( xx == 0 || leftDiscreteTime != prevDiscreteTime ) {
118 prevDiscreteTime = leftDiscreteTime;
119 prevSampleVal =
120 env.GetValue( prevDiscreteTime, sampleDur );
121 nextSampleVal =
122 env.GetValue( prevDiscreteTime + sampleDur, sampleDur );
123 }
124 auto ratio = ( time - leftDiscreteTime ) / sampleDur;
125 if ( env.GetExponential() )
126 buffer[ xx ] = exp(
127 ( 1.0 - ratio ) * log( prevSampleVal )
128 + ratio * log( nextSampleVal ) );
129 else
130 buffer[ xx ] =
131 ( 1.0 - ratio ) * prevSampleVal + ratio * nextSampleVal;
132 }
133 }
134}
double GetValue(double t, double sampleDur=0) const
Get envelope value at time t.
Definition: Envelope.cpp:828
bool GetExponential() const
Definition: Envelope.h:95
double PositionToTime(int64 position, int64 origin=0, bool ignoreFisheye=false) const
Definition: ZoomInfo.cpp:35

References Envelope::GetExponential(), Envelope::GetValue(), and ZoomInfo::PositionToTime().

Referenced by anonymous_namespace{WaveformView.cpp}::DrawClipWaveform(), and anonymous_namespace{TimeTrackView.cpp}::DrawHorzRulerAndCurve().

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

◆ GetMinimizedHeight()

int CommonTrackView::GetMinimizedHeight ( ) const
overridevirtual
Returns
height of the track when collapsed

See other comments for GetHeight

Implements TrackView.

Definition at line 81 of file CommonTrackView.cpp.

82{
83 auto height = TrackInfo::MinimumTrackHeight();
84 const auto pTrack = FindTrack();
85 auto channels = TrackList::Channels(pTrack->SubstituteOriginalTrack().get());
86 auto nChannels = channels.size();
87 auto begin = channels.begin();
88 auto index =
89 std::distance(begin, std::find(begin, channels.end(), pTrack.get()));
90 return (height * (index + 1) / nChannels) - (height * index / nChannels);
91}
static auto Channels(TrackType *pTrack) -> TrackIterRange< TrackType >
Definition: Track.h:1114
auto begin(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
Definition: PackedArray.h:150
AUDACITY_DLL_API unsigned MinimumTrackHeight()
Definition: TrackInfo.cpp:192

References PackedArray::begin(), TrackList::Channels(), CommonTrackPanelCell::FindTrack(), and TrackInfo::MinimumTrackHeight().

Here is the call graph for this function:

◆ HitTest()

std::vector< UIHandlePtr > CommonTrackView::HitTest ( const TrackPanelMouseState st,
const AudacityProject pProject 
)
finaloverridevirtual

Implements TrackPanelCell.

Definition at line 29 of file CommonTrackView.cpp.

32{
33 UIHandlePtr result;
34 using namespace ToolCodes;
35 std::vector<UIHandlePtr> results;
36 const auto &settings = ProjectSettings::Get( *pProject );
37 const auto currentTool = settings.GetTool();
38 const bool isMultiTool = ( currentTool == multiTool );
39
40 // In other tools, let subclasses determine detailed hits.
41 results =
42 DetailedHitTest( st, pProject, currentTool, isMultiTool );
43
44 // There are still some general cases.
45
46 #if 0
47 // Sliding applies in more than one track type.
48 if ( !isMultiTool && currentTool == slideTool ) {
50 mTimeShiftHandle, FindTrack(), false);
51 if (result)
52 results.push_back(result);
53 }
54 #endif
55
56 // Let the multi-tool right-click handler apply only in default of all
57 // other detailed hits.
58 if ( isMultiTool ) {
59 result = ZoomHandle::HitTest(
60 BackgroundCell::Get( *pProject ).mZoomHandle, st.state);
61 if (result)
62 results.push_back(result);
63 }
64
65 // Finally, default of all is adjustment of the selection box.
66 if ( isMultiTool || currentTool == selectTool ) {
67 result = SelectHandle::HitTest(
68 mSelectHandle, st, pProject, shared_from_this() );
69 if (result)
70 results.push_back(result);
71 }
72
73 return results;
74}
std::shared_ptr< UIHandle > UIHandlePtr
Definition: CellularPanel.h:28
static Settings & settings()
Definition: TrackInfo.cpp:83
static BackgroundCell & Get(AudacityProject &project)
std::weak_ptr< ZoomHandle > mZoomHandle
std::weak_ptr< TimeShiftHandle > mTimeShiftHandle
std::weak_ptr< SelectHandle > mSelectHandle
virtual std::vector< UIHandlePtr > DetailedHitTest(const TrackPanelMouseState &, const AudacityProject *pProject, int currentTool, bool bMultiTool)=0
static ProjectSettings & Get(AudacityProject &project)
static UIHandlePtr HitTest(std::weak_ptr< SelectHandle > &holder, const TrackPanelMouseState &state, const AudacityProject *pProject, const std::shared_ptr< TrackView > &pTrackView)
static UIHandlePtr HitAnywhere(std::weak_ptr< TimeShiftHandle > &holder, const std::shared_ptr< Track > &pTrack, bool gripHit)
static UIHandlePtr HitTest(std::weak_ptr< ZoomHandle > &holder, const wxMouseState &state)
Definition: ZoomHandle.cpp:73

References DetailedHitTest(), CommonTrackPanelCell::FindTrack(), ProjectSettings::Get(), BackgroundCell::Get(), TimeShiftHandle::HitAnywhere(), SelectHandle::HitTest(), ZoomHandle::HitTest(), mSelectHandle, mTimeShiftHandle, ToolCodes::multiTool, BackgroundCell::mZoomHandle, ToolCodes::selectTool, settings(), and TrackPanelMouseState::state.

Here is the call graph for this function:

◆ TimeShiftHitTest()

void CommonTrackView::TimeShiftHitTest ( )

◆ TrackView()

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

Definition at line 33 of file TrackView.cpp.

20 : CommonTrackCell{ pTrack }
21{
23}
static Return Call(This &obj, Arguments &&...arguments)
Invoke the method – but only after static initialization time.
void DoSetHeight(int h)
Definition: TrackView.cpp:178

Member Data Documentation

◆ mSelectHandle

std::weak_ptr<SelectHandle> CommonTrackView::mSelectHandle
protected

Definition at line 55 of file CommonTrackView.h.

Referenced by HitTest().

◆ mTimeShiftHandle

std::weak_ptr<TimeShiftHandle> CommonTrackView::mTimeShiftHandle

Definition at line 58 of file CommonTrackView.h.

Referenced by WaveTrackView::DoDetailedHitTest(), and HitTest().


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