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

Implements some hit-testing shared by many ChannelView subtypes. More...

#include <CommonChannelView.h>

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

Public Member Functions

std::shared_ptr< TrackPanelCellContextMenuDelegate () override
 
std::vector< UIHandlePtrHitTest (const TrackPanelMouseState &, const AudacityProject *pProject) final
 
void TimeShiftHitTest ()
 
virtual int GetMinimizedHeight () const override
 
 ChannelView (const std::shared_ptr< Channel > &pChannel)
 
- Public Member Functions inherited from ChannelView
 ChannelView (const std::shared_ptr< Channel > &pChannel)
 
virtual ~ChannelView ()=0
 
void Reparent (const std::shared_ptr< Track > &parent, size_t iChannel) override
 Object may be shared among tracks but hold a special back-pointer to one of them; reassign it. More...
 
void CopyTo (Track &track, size_t iChannel) 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< ChannelVRulerControlsGetVRulerControls ()
 
std::shared_ptr< const ChannelVRulerControlsGetVRulerControls () const
 
virtual std::shared_ptr< CommonTrackCellGetAffordanceControls ()
 
void WriteXMLAttributes (XMLWriter &writer, size_t iChannel) const override
 Serialize persistent attributes. More...
 
bool HandleXMLAttribute (const std::string_view &attr, const XMLAttributeValueView &valueView, size_t iChannel) 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 CommonChannelCell
 CommonChannelCell (const std::shared_ptr< Channel > &pChannel)
 Construct from a channel. More...
 
 ~CommonChannelCell ()
 
std::shared_ptr< TrackDoFindTrack () override
 
void Reparent (const std::shared_ptr< Track > &parent, size_t iChannel) override
 Object may be shared among tracks but hold a special back-pointer to one of them; reassign it. More...
 
template<typename Subtype = Channel>
auto FindChannel () -> std::shared_ptr< Subtype >
 May return null. More...
 
template<typename Subtype = const Channel>
auto FindChannel () const -> std::enable_if_t< std::is_const_v< Subtype >, std::shared_ptr< Subtype > >
 May return null. 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 &)=delete
 
TrackPanelCelloperator= (const TrackPanelCell &)=delete
 
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 ChannelAttachment
virtual ~ChannelAttachment ()
 
virtual void CopyTo (Track &track, size_t iChannel) const
 Copy state, for undo/redo purposes. More...
 
virtual void Reparent (const std::shared_ptr< Track > &parent, size_t iChannel)
 Object may be shared among tracks but hold a special back-pointer to one of them; reassign it. More...
 
virtual void WriteXMLAttributes (XMLWriter &writer, size_t iChannel) const
 Serialize persistent attributes. More...
 
virtual bool HandleXMLAttribute (const std::string_view &attr, const XMLAttributeValueView &valueView, size_t iChannel)
 Deserialize an attribute, returning true if recognized. More...
 

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 ChannelView
static ChannelViewGet (Channel &channel)
 
static const ChannelViewGet (const Channel &channel)
 
static ChannelViewFind (Channel *pChannel)
 
static const ChannelViewFind (const Channel *pChannel)
 
static int GetChannelGroupHeight (const Track *pTrack)
 
static int GetCumulativeHeight (const Channel *pChannel)
 
static int GetCumulativeHeight (const Track *pTrack)
 
static int GetTotalHeight (const TrackList &list)
 
- 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
 
- Public Attributes inherited from ChannelView
std::pair< int, int > vrulerSize
 

Protected Member Functions

virtual std::vector< UIHandlePtrDetailedHitTest (const TrackPanelMouseState &, const AudacityProject *pProject, int currentTool, bool bMultiTool)=0
 
- Protected Member Functions inherited from ChannelView
virtual std::shared_ptr< ChannelVRulerControlsDoGetVRulerControls ()=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 ChannelView
std::shared_ptr< ChannelVRulerControlsmpVRulerControls
 

Additional Inherited Members

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

Detailed Description

Implements some hit-testing shared by many ChannelView subtypes.

Definition at line 22 of file CommonChannelView.h.

Member Function Documentation

◆ ChannelView()

ChannelView::ChannelView ( const std::shared_ptr< Channel > &  pChannel)
explicit

Definition at line 50 of file ChannelView.cpp.

22 : CommonChannelCell{ pChannel }
23{
25}
static Return Call(This &obj, Arguments ...arguments)
Invoke the method – but only after static initialization time.
void DoSetHeight(int h)

◆ ContextMenuDelegate()

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

Reimplemented from TrackPanelCell.

Definition at line 77 of file CommonChannelView.cpp.

78{
79 const auto pTrack = FindTrack();
80 if (pTrack)
81 return TrackControls::Get(*pTrack).shared_from_this();
82 return nullptr;
83}
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 > CommonChannelView::DetailedHitTest ( const TrackPanelMouseState ,
const AudacityProject pProject,
int  currentTool,
bool  bMultiTool 
)
protectedpure virtual

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

Referenced by HitTest().

Here is the caller graph for this function:

◆ GetEnvelopeValues()

void CommonChannelView::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 108 of file CommonChannelView.cpp.

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

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 CommonChannelView::GetMinimizedHeight ( ) const
overridevirtual
Returns
height of the track when collapsed

See other comments for GetHeight

Implements ChannelView.

Definition at line 85 of file CommonChannelView.cpp.

86{
87 const auto height = CommonTrackInfo::MinimumTrackHeight();
88 auto pChannel = FindChannel().get();
89 if (!pChannel)
90 return height;
91 const auto pTrack =
92 dynamic_cast<const Track *>(&pChannel->GetChannelGroup());
93 if (!pTrack)
94 return 0;
95 if (const auto pList = pTrack->GetOwner())
96 if (const auto p = pList->GetOwner())
97 pChannel =
99
100 // Find index of the channel in its group and use that to round off correctly
101 const auto index = pChannel->GetChannelIndex();
102 const auto nChannels = pChannel->GetChannelGroup().Channels().size();
103 return (height * (index + 1) / nChannels) - (height * index / nChannels);
104}
size_t GetChannelIndex() const
Definition: Channel.cpp:25
auto FindChannel() -> std::shared_ptr< Subtype >
May return null.
static PendingTracks & Get(AudacityProject &project)
const Channel & SubstituteOriginalChannel(const Channel &channel) const
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:110
AUDACITY_DLL_API unsigned MinimumTrackHeight()

References CommonChannelCell::FindChannel(), PendingTracks::Get(), Channel::GetChannelIndex(), CommonTrackInfo::MinimumTrackHeight(), and PendingTracks::SubstituteOriginalChannel().

Here is the call graph for this function:

◆ HitTest()

std::vector< UIHandlePtr > CommonChannelView::HitTest ( const TrackPanelMouseState st,
const AudacityProject pProject 
)
finalvirtual

Implements TrackPanelCell.

Definition at line 30 of file CommonChannelView.cpp.

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

Member Data Documentation

◆ mSelectHandle

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

Definition at line 56 of file CommonChannelView.h.

Referenced by HitTest().

◆ mTimeShiftHandle

std::weak_ptr<TimeShiftHandle> CommonChannelView::mTimeShiftHandle

Definition at line 59 of file CommonChannelView.h.

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


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