Audacity 3.2.0
Public Types | Public Member Functions | Protected Member Functions | Static Protected Member Functions | 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)
 

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
 
- Protected Attributes inherited from CommonTrackView
std::weak_ptr< SelectHandlemSelectHandle
 
- Protected Attributes inherited from TrackView
std::shared_ptr< TrackVRulerControlsmpVRulerControls
 

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 880 of file WaveTrackView.cpp.

881 : CommonTrackView( waveTrackView.FindTrack() )
882{
883 mwWaveTrackView = std::static_pointer_cast<WaveTrackView>(
884 waveTrackView.shared_from_this() );
885}
std::shared_ptr< Track > FindTrack()
std::weak_ptr< WaveTrackView > mwWaveTrackView
Definition: WaveTrackView.h:81

References mwWaveTrackView.

Member Function Documentation

◆ CopyToSubView()

void WaveTrackSubView::CopyToSubView ( WaveTrackSubView destSubView) const
virtual

Reimplemented in SpectrumView.

Definition at line 887 of file WaveTrackView.cpp.

887 {
888
889}

◆ 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 697 of file WaveTrackView.cpp.

701{
703 state, pProject, currentTool, bMultiTool, wt, *this );
704 if ( results.first )
705 return results;
706
707 auto pWaveTrackView = mwWaveTrackView.lock();
708 if ( pWaveTrackView && !state.state.HasModifiers() ) {
709 if ( auto pHandle = SubViewCloseHandle::HitTest(
711 *pWaveTrackView, *this, state ) )
712 results.second.push_back( pHandle );
713
714 auto channels = TrackList::Channels(wt.get());
715 if(channels.size() > 1) {
716 // Only one cell is tested and we need to know
717 // which one and it's relative location to the border.
718 auto subviews = pWaveTrackView->GetSubViews();
719 auto currentSubview = std::find_if(subviews.begin(), subviews.end(),
720 [self = shared_from_this()](const auto& p){
721 return self == p.second;
722 });
723 if (currentSubview != subviews.end())
724 {
725 auto currentSubviewIndex = std::distance(subviews.begin(), currentSubview);
726
727 const auto py = state.state.GetY();
728 const auto topBorderHit = std::abs(py - state.rect.GetTop())
730 const auto bottomBorderHit = std::abs(py - state.rect.GetBottom())
732
733 auto currentChannel = channels.find(wt.get());
734 auto currentChannelIndex = std::distance(channels.begin(), currentChannel);
735
736 if (//for not-last-view check the bottom border hit
737 ((currentChannelIndex != channels.size() - 1)
738 && (currentSubviewIndex == static_cast<int>(subviews.size()) - 1)
739 && bottomBorderHit)
740 ||
741 //or for not-first-view check the top border hit
742 ((currentChannelIndex != 0) && currentSubviewIndex == 0 && topBorderHit))
743 {
744 //depending on which border hit test succeeded on we
745 //need to choose a proper target for resizing
746 auto it = bottomBorderHit ? currentChannel : currentChannel.advance(-1);
747 auto result = std::make_shared<TrackPanelResizeHandle>((*it)->shared_from_this(), py);
748 result = AssignUIHandlePtr(mResizeHandle, result);
749 results.second.push_back(result);
750 }
751 }
752 }
753
754 if ( auto pHandle = SubViewAdjustHandle::HitTest(
756 *pWaveTrackView, *this, state ) )
757 results.second.push_back( pHandle );
758 if ( auto pHandle = SubViewRearrangeHandle::HitTest(
760 *pWaveTrackView, *this, state ) )
761 results.second.push_back( pHandle );
762 if (auto pHandle = WaveClipTrimHandle::HitTest(
764 *pWaveTrackView, pProject, state))
765 results.second.push_back(pHandle);
766 }
767 if (auto result = CutlineHandle::HitTest(
768 mCutlineHandle, state.state, state.rect,
769 pProject, wt ))
770 // This overriding test applies in all tools
771 results.second.push_back(result);
772
773 return results;
774}
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:1539
static UIHandlePtr HitTest(std::weak_ptr< WaveClipTrimHandle > &holder, WaveTrackView &view, const AudacityProject *pProject, const TrackPanelMouseState &state)
std::weak_ptr< TrackPanelResizeHandle > mResizeHandle
Definition: WaveTrackView.h:76
std::weak_ptr< SubViewAdjustHandle > mAdjustHandle
Definition: WaveTrackView.h:77
std::weak_ptr< SubViewRearrangeHandle > mRearrangeHandle
Definition: WaveTrackView.h:78
std::weak_ptr< WaveClipTrimHandle > mClipTrimHandle
Definition: WaveTrackView.h:79
std::weak_ptr< CutlineHandle > mCutlineHandle
Definition: WaveTrackView.h:80
std::weak_ptr< SubViewCloseHandle > mCloseHandle
Definition: WaveTrackView.h:75
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 777 of file WaveTrackView.cpp.

780{
781 auto &dc = context.dc;
782 const auto artist = TrackArtist::Get( context );
783
784 const auto &zoomInfo = *artist->pZoomInfo;
785
786#ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING
787 auto target2 = dynamic_cast<CutlineHandle*>(context.target.get());
788#endif
789 for (const auto loc : track->GetCachedLocations()) {
790 bool highlightLoc = false;
791#ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING
792 highlightLoc =
793 target2 && target2->GetTrack().get() == track &&
794 target2->GetLocation() == loc;
795#endif
796 const int xx = zoomInfo.TimeToPosition(loc.pos);
797 if (xx >= 0 && xx < rect.width) {
798 dc.SetPen( highlightLoc ? AColor::uglyPen : *wxGREY_PEN );
799 AColor::Line(dc, (int) (rect.x + xx - 1), rect.y, (int) (rect.x + xx - 1), rect.y + rect.height);
800 if (loc.typ == WaveTrackLocation::locationCutLine) {
801 dc.SetPen( highlightLoc ? AColor::uglyPen : *wxRED_PEN );
802 }
803 else {
804#ifdef EXPERIMENTAL_DA
805 // JKC Black does not show up enough.
806 dc.SetPen(highlightLoc ? AColor::uglyPen : *wxWHITE_PEN);
807#else
808 dc.SetPen(highlightLoc ? AColor::uglyPen : *wxBLACK_PEN);
809#endif
810 }
811 AColor::Line(dc, (int) (rect.x + xx), rect.y, (int) (rect.x + xx), rect.y + rect.height);
812 dc.SetPen( highlightLoc ? AColor::uglyPen : *wxGREY_PEN );
813 AColor::Line(dc, (int) (rect.x + xx + 1), rect.y, (int) (rect.x + xx + 1), rect.y + rect.height);
814 }
815 }
816}
static void Line(wxDC &dc, wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
Definition: AColor.cpp:187
static wxPen uglyPen
Definition: AColor.h:136
std::shared_ptr< WaveTrack > GetTrack()
Definition: CutlineHandle.h:44
static TrackArtist * Get(TrackPanelDrawingContext &)
Definition: TrackArtist.cpp:69
const std::vector< Location > & GetCachedLocations() const
Definition: WaveTrack.h:489

References TrackPanelDrawingContext::dc, TrackArtist::Get(), WaveTrack::GetCachedLocations(), 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 823 of file WaveTrackView.cpp.

826{
827 const WaveClip *pClip = nullptr;
828 auto pTrack = static_cast<WaveTrack*>( FindTrack().get() );
829 double time = 0.0;
830 if ( pTrack && pPosition ) {
831 auto &viewInfo = ViewInfo::Get(*pProject);
832 time = viewInfo.PositionToTime( pPosition->x, rect.x );
833 pClip = pTrack->GetClipAtTime( time );
834 }
835
836 if (pClip)
837 return {
838 { L"Cut", XO("Cut") },
839 { L"Copy", XO("Copy") },
840 { L"Paste", XO("Paste") },
841 {},
842 { L"Split", XO("Split Clip") },
843 { L"TrackMute", XO("Mute/Unmute Track") },
844 {},
845 { L"RenameClip", XO("Rename clip...") },
846 };
847 else
848 return {
849 { L"Paste", XO("Paste") },
850 {},
851 { L"TrackMute", XO("Mute/Unmute Track") },
852 };
853}
#define XO(s)
Definition: Internat.h:31
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:235
This allows multiple clips to be a part of one WaveTrack.
Definition: WaveClip.h:101
A Track that contains audio waveform data.
Definition: WaveTrack.h:57

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 818 of file WaveTrackView.cpp.

819{
820 return mwWaveTrackView;
821}

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 77 of file WaveTrackView.h.

Referenced by DoDetailedHitTest().

◆ mClipTrimHandle

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

Definition at line 79 of file WaveTrackView.h.

Referenced by DoDetailedHitTest().

◆ mCloseHandle

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

Definition at line 75 of file WaveTrackView.h.

Referenced by DoDetailedHitTest().

◆ mCutlineHandle

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

Definition at line 80 of file WaveTrackView.h.

Referenced by DoDetailedHitTest().

◆ mRearrangeHandle

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

Definition at line 78 of file WaveTrackView.h.

Referenced by DoDetailedHitTest().

◆ mResizeHandle

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

Definition at line 76 of file WaveTrackView.h.

Referenced by DoDetailedHitTest().

◆ mwWaveTrackView

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

Definition at line 81 of file WaveTrackView.h.

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


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