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

#include <WaveTrackView.h>

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

Public Types

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

Public Member Functions

 WaveTrackSubView (WaveTrackView &waveTrackView)
 
virtual const TypeSubViewType () const =0
 
virtual void CopyToSubView (WaveTrackSubView *destSubView) const
 
std::pair< bool, std::vector< UIHandlePtr > > DoDetailedHitTest (const TrackPanelMouseState &state, const AudacityProject *pProject, int currentTool, bool bMultiTool, const std::shared_ptr< WaveTrack > &wt)
 
- 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
 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 ()
 

Protected Member Functions

std::weak_ptr< WaveTrackViewGetWaveTrackView () const
 
std::vector< MenuItemGetMenuItems (const wxRect &rect, const wxPoint *pPosition, AudacityProject *pProject) override
 Return a list of items for DoContextMenu() (empties for separators) More...
 
- Protected Member Functions inherited from CommonTrackView
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
 

Static Protected Member Functions

static void DrawBoldBoundaries (TrackPanelDrawingContext &context, const WaveTrack *track, const wxRect &rect)
 

Protected Attributes

const size_t mChannel
 
- Protected Attributes inherited from CommonTrackView
std::weak_ptr< SelectHandlemSelectHandle
 
- Protected Attributes inherited from TrackView
std::shared_ptr< TrackVRulerControlsmpVRulerControls
 

Private Attributes

std::weak_ptr< SubViewCloseHandlemCloseHandle
 
std::weak_ptr< TrackPanelResizeHandlemResizeHandle
 
std::weak_ptr< SubViewAdjustHandlemAdjustHandle
 
std::weak_ptr< SubViewRearrangeHandlemRearrangeHandle
 
std::weak_ptr< WaveClipTrimHandlemClipTrimHandle
 
std::weak_ptr< CutlineHandlemCutlineHandle
 
std::weak_ptr< WaveTrackViewmwWaveTrackView
 

Additional Inherited Members

- Static Public Member Functions inherited from CommonTrackView
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 inherited from CommonTrackView
std::weak_ptr< TimeShiftHandlemTimeShiftHandle
 

Detailed Description

Definition at line 39 of file WaveTrackView.h.

Member Typedef Documentation

◆ Display

Definition at line 43 of file WaveTrackView.h.

◆ Type

Definition at line 44 of file WaveTrackView.h.

Constructor & Destructor Documentation

◆ WaveTrackSubView()

WaveTrackSubView::WaveTrackSubView ( WaveTrackView waveTrackView)
explicit

Definition at line 929 of file WaveTrackView.cpp.

930 : CommonTrackView(waveTrackView.FindTrack())
931 , mChannel(waveTrackView.GetChannel())
932{
933 mwWaveTrackView = std::static_pointer_cast<WaveTrackView>(
934 waveTrackView.shared_from_this() );
935}
std::shared_ptr< Track > FindTrack()
std::weak_ptr< WaveTrackView > mwWaveTrackView
Definition: WaveTrackView.h:84
const size_t mChannel
Definition: WaveTrackView.h:75
size_t GetChannel() const

References mwWaveTrackView.

Member Function Documentation

◆ CopyToSubView()

void WaveTrackSubView::CopyToSubView ( WaveTrackSubView destSubView) const
virtual

Reimplemented in SpectrumView.

Definition at line 937 of file WaveTrackView.cpp.

937 {
938
939}

◆ DoDetailedHitTest()

std::pair< bool, std::vector< UIHandlePtr > > WaveTrackSubView::DoDetailedHitTest ( const TrackPanelMouseState state,
const AudacityProject pProject,
int  currentTool,
bool  bMultiTool,
const std::shared_ptr< WaveTrack > &  wt 
)

Definition at line 744 of file WaveTrackView.cpp.

748{
750 state, pProject, currentTool, bMultiTool, wt, *this );
751 if ( results.first )
752 return results;
753
754 auto pWaveTrackView = mwWaveTrackView.lock();
755 if ( pWaveTrackView && !state.state.HasModifiers() ) {
756 if ( auto pHandle = SubViewCloseHandle::HitTest(
758 *pWaveTrackView, *this, state ) )
759 results.second.push_back( pHandle );
760
761 auto channels = TrackList::Channels(wt.get());
762 if(channels.size() > 1) {
763 // Only one cell is tested and we need to know
764 // which one and it's relative location to the border.
765 auto subviews = pWaveTrackView->GetSubViews();
766 auto currentSubview = std::find_if(subviews.begin(), subviews.end(),
767 [self = shared_from_this()](const auto& p){
768 return self == p.second;
769 });
770 if (currentSubview != subviews.end())
771 {
772 auto currentSubviewIndex = std::distance(subviews.begin(), currentSubview);
773
774 const auto py = state.state.GetY();
775 const auto topBorderHit = std::abs(py - state.rect.GetTop())
777 const auto bottomBorderHit = std::abs(py - state.rect.GetBottom())
779
780 auto currentChannel = channels.find(wt.get());
781 auto currentChannelIndex = std::distance(channels.begin(), currentChannel);
782
783 if (//for not-last-view check the bottom border hit
784 ((currentChannelIndex != channels.size() - 1)
785 && (currentSubviewIndex == static_cast<int>(subviews.size()) - 1)
786 && bottomBorderHit)
787 ||
788 //or for not-first-view check the top border hit
789 ((currentChannelIndex != 0) && currentSubviewIndex == 0 && topBorderHit))
790 {
791 //depending on which border hit test succeeded on we
792 //need to choose a proper target for resizing
793 auto it = bottomBorderHit ? currentChannel : currentChannel.advance(-1);
794 auto result = std::make_shared<TrackPanelResizeHandle>((*it)->shared_from_this(), py);
795 result = AssignUIHandlePtr(mResizeHandle, result);
796 results.second.push_back(result);
797 }
798 }
799 }
800
801 if ( auto pHandle = SubViewAdjustHandle::HitTest(
803 *pWaveTrackView, *this, state ) )
804 results.second.push_back( pHandle );
805 if ( auto pHandle = SubViewRearrangeHandle::HitTest(
807 *pWaveTrackView, *this, state ) )
808 results.second.push_back( pHandle );
809 if (auto pHandle = WaveClipTrimHandle::HitTest(
811 *pWaveTrackView, pProject, state))
812 results.second.push_back(pHandle);
813 }
814 if (auto result = CutlineHandle::HitTest(
815 mCutlineHandle, state.state, state.rect,
816 pProject, wt ))
817 // This overriding test applies in all tools
818 results.second.push_back(result);
819
820 return results;
821}
std::shared_ptr< Subclass > AssignUIHandlePtr(std::weak_ptr< Subclass > &holder, const std::shared_ptr< Subclass > &pNew)
Definition: UIHandle.h:151
static UIHandlePtr HitTest(std::weak_ptr< CutlineHandle > &holder, const wxMouseState &state, const wxRect &rect, const AudacityProject *pProject, const std::shared_ptr< WaveTrack > &pTrack)
static UIHandlePtr HitTest(std::weak_ptr< SubViewAdjustHandle > &holder, WaveTrackView &view, WaveTrackSubView &subView, const TrackPanelMouseState &state)
static UIHandlePtr HitTest(std::weak_ptr< SubViewCloseHandle > &holder, WaveTrackView &view, WaveTrackSubView &subView, const TrackPanelMouseState &state)
static UIHandlePtr HitTest(std::weak_ptr< SubViewRearrangeHandle > &holder, WaveTrackView &view, WaveTrackSubView &subView, const TrackPanelMouseState &state)
static auto Channels(TrackType *pTrack) -> TrackIterRange< TrackType >
Definition: Track.h:1114
static UIHandlePtr HitTest(std::weak_ptr< WaveClipTrimHandle > &holder, WaveTrackView &view, const AudacityProject *pProject, const TrackPanelMouseState &state)
std::weak_ptr< TrackPanelResizeHandle > mResizeHandle
Definition: WaveTrackView.h:79
std::weak_ptr< SubViewAdjustHandle > mAdjustHandle
Definition: WaveTrackView.h:80
std::weak_ptr< SubViewRearrangeHandle > mRearrangeHandle
Definition: WaveTrackView.h:81
std::weak_ptr< WaveClipTrimHandle > mClipTrimHandle
Definition: WaveTrackView.h:82
std::weak_ptr< CutlineHandle > mCutlineHandle
Definition: WaveTrackView.h:83
std::weak_ptr< SubViewCloseHandle > mCloseHandle
Definition: WaveTrackView.h:78
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 constexpr int kChannelSeparatorThickness

References AssignUIHandlePtr(), TrackList::Channels(), WaveTrackView::DoDetailedHitTest(), CutlineHandle::HitTest(), SubViewAdjustHandle::HitTest(), SubViewCloseHandle::HitTest(), SubViewRearrangeHandle::HitTest(), WaveClipTrimHandle::HitTest(), WaveTrackView::kChannelSeparatorThickness, mAdjustHandle, mClipTrimHandle, mCloseHandle, mCutlineHandle, mRearrangeHandle, mResizeHandle, mwWaveTrackView, TrackPanelMouseState::rect, and TrackPanelMouseState::state.

Referenced by SpectrumView::DetailedHitTest(), and WaveformView::DetailedHitTest().

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

◆ DrawBoldBoundaries()

void WaveTrackSubView::DrawBoldBoundaries ( TrackPanelDrawingContext context,
const WaveTrack track,
const wxRect &  rect 
)
staticprotected

Definition at line 824 of file WaveTrackView.cpp.

827{
828 auto &dc = context.dc;
829 const auto artist = TrackArtist::Get( context );
830
831 const auto &zoomInfo = *artist->pZoomInfo;
832
833#ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING
834 auto target2 = dynamic_cast<CutlineHandle*>(context.target.get());
835#endif
836 for (const auto loc : WaveTrackLocations::Get(*track).Get()) {
837 bool highlightLoc = false;
838#ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING
839 highlightLoc =
840 target2 && target2->GetTrack().get() == track &&
841 target2->GetLocation() == loc;
842#endif
843 const int xx = zoomInfo.TimeToPosition(loc.pos);
844 if (xx >= 0 && xx < rect.width) {
845 dc.SetPen( highlightLoc ? AColor::uglyPen : *wxGREY_PEN );
846 AColor::Line(dc, (int) (rect.x + xx - 1), rect.y, (int) (rect.x + xx - 1), rect.y + rect.height);
847 if (loc.typ == WaveTrackLocation::locationCutLine) {
848 dc.SetPen( highlightLoc ? AColor::uglyPen : *wxRED_PEN );
849 }
850 else {
851#ifdef EXPERIMENTAL_DA
852 // JKC Black does not show up enough.
853 dc.SetPen(highlightLoc ? AColor::uglyPen : *wxWHITE_PEN);
854#else
855 dc.SetPen(highlightLoc ? AColor::uglyPen : *wxBLACK_PEN);
856#endif
857 }
858 AColor::Line(dc, (int) (rect.x + xx), rect.y, (int) (rect.x + xx), rect.y + rect.height);
859 dc.SetPen( highlightLoc ? AColor::uglyPen : *wxGREY_PEN );
860 AColor::Line(dc, (int) (rect.x + xx + 1), rect.y, (int) (rect.x + xx + 1), rect.y + rect.height);
861 }
862 }
863}
static void Line(wxDC &dc, wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
Definition: AColor.cpp:187
static wxPen uglyPen
Definition: AColor.h:141
std::shared_ptr< WaveTrack > GetTrack()
Definition: CutlineHandle.h:44
static TrackArtist * Get(TrackPanelDrawingContext &)
Definition: TrackArtist.cpp:69
const std::vector< Location > & Get() const

References TrackPanelDrawingContext::dc, WaveTrackLocations::Get(), TrackArtist::Get(), CutlineHandle::GetTrack(), AColor::Line(), WaveTrackLocation::locationCutLine, TrackPanelDrawingContext::target, and AColor::uglyPen.

Referenced by SpectrumView::DoDraw(), and WaveformView::DoDraw().

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

◆ GetMenuItems()

auto WaveTrackSubView::GetMenuItems ( const wxRect &  rect,
const wxPoint *  pPosition,
AudacityProject pProject 
)
overrideprotectedvirtual

Return a list of items for DoContextMenu() (empties for separators)

If the vector is empty (as in the default), there is no context menu.

Commands are invoked with temporary selection fields of CommandContext set to a point selected region at the mouse pick, and the cell's track.

A function may be given, but if it is null, then the command can be found by name in the CommandManager.

An item in the list with no command name marks a menu separator.

The menu item is enabled only if it contains a true flag, but if looked up in the command manager, it must also satisfy the command manager's conditions.

Reimplemented from CommonTrackPanelCell.

Definition at line 870 of file WaveTrackView.cpp.

873{
874 const WaveClip *pClip = nullptr;
875 auto pTrack = static_cast<WaveTrack*>( FindTrack().get() );
876 double time = 0.0;
877 if ( pTrack && pPosition ) {
878 auto &viewInfo = ViewInfo::Get(*pProject);
879 time = viewInfo.PositionToTime( pPosition->x, rect.x );
880 pClip = pTrack->GetClipAtTime( time );
881 }
882
883 if (pClip)
884 return {
885 { L"Cut", XO("Cut") },
886 { L"Copy", XO("Copy") },
887 { L"Paste", XO("Paste") },
888 {},
889 { L"Split", XO("Split Clip") },
890 { L"TrackMute", XO("Mute/Unmute Track") },
891 {},
892 { L"RenameClip", XO("Rename Clip...") },
893 };
894 else
895 return {
896 { L"Paste", XO("Paste") },
897 {},
898 { L"TrackMute", XO("Mute/Unmute Track") },
899 };
900}
XO("Cut/Copy/Paste")
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:235
This allows multiple clips to be a part of one WaveTrack.
Definition: WaveClip.h:98
A Track that contains audio waveform data.
Definition: WaveTrack.h:54

References anonymous_namespace{TrackPanel.cpp}::FindTrack(), ViewInfo::Get(), and XO().

Here is the call graph for this function:

◆ GetWaveTrackView()

std::weak_ptr< WaveTrackView > WaveTrackSubView::GetWaveTrackView ( ) const
protected

Definition at line 865 of file WaveTrackView.cpp.

866{
867 return mwWaveTrackView;
868}

References mwWaveTrackView.

Referenced by SpectrumView::Draw(), and WaveformView::Draw().

Here is the caller graph for this function:

◆ SubViewType()

virtual const Type & WaveTrackSubView::SubViewType ( ) const
pure virtual

Implemented in SpectrumView, and WaveformView.

Referenced by WaveTrackView::DoSetDisplay(), WaveTrackView::GetDisplays(), and WaveTrackView::ToggleSubView().

Here is the caller graph for this function:

Member Data Documentation

◆ mAdjustHandle

std::weak_ptr<SubViewAdjustHandle> WaveTrackSubView::mAdjustHandle
private

Definition at line 80 of file WaveTrackView.h.

Referenced by DoDetailedHitTest().

◆ mChannel

const size_t WaveTrackSubView::mChannel
protected

Definition at line 75 of file WaveTrackView.h.

Referenced by WaveformView::Draw().

◆ mClipTrimHandle

std::weak_ptr<WaveClipTrimHandle> WaveTrackSubView::mClipTrimHandle
private

Definition at line 82 of file WaveTrackView.h.

Referenced by DoDetailedHitTest().

◆ mCloseHandle

std::weak_ptr<SubViewCloseHandle> WaveTrackSubView::mCloseHandle
private

Definition at line 78 of file WaveTrackView.h.

Referenced by DoDetailedHitTest().

◆ mCutlineHandle

std::weak_ptr<CutlineHandle> WaveTrackSubView::mCutlineHandle
private

Definition at line 83 of file WaveTrackView.h.

Referenced by DoDetailedHitTest().

◆ mRearrangeHandle

std::weak_ptr<SubViewRearrangeHandle> WaveTrackSubView::mRearrangeHandle
private

Definition at line 81 of file WaveTrackView.h.

Referenced by DoDetailedHitTest().

◆ mResizeHandle

std::weak_ptr<TrackPanelResizeHandle> WaveTrackSubView::mResizeHandle
private

Definition at line 79 of file WaveTrackView.h.

Referenced by DoDetailedHitTest().

◆ mwWaveTrackView

std::weak_ptr<WaveTrackView> WaveTrackSubView::mwWaveTrackView
private

Definition at line 84 of file WaveTrackView.h.

Referenced by DoDetailedHitTest(), GetWaveTrackView(), and WaveTrackSubView().


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