Audacity  2.2.0
TrackPanel Class Referencefinal

The TrackPanel class coordinates updates and operations on the main part of the screen which contains multiple tracks. More...

#include <TrackPanel.h>

Inheritance diagram for TrackPanel:
OverlayPanel BackedPanel wxTabTraversalWrapper< Base >

Classes

class  AudacityTimer
 Timer class dedicated to infomring the TrackPanel that it is time to refresh some aspect of the screen. More...
 
struct  FoundCell
 

Public Member Functions

 TrackPanel (wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, const std::shared_ptr< TrackList > &tracks, ViewInfo *viewInfo, TrackPanelListener *listener, AdornedRulerPanel *ruler)
 
virtual ~TrackPanel ()
 
IteratorRange
< TrackPanelCellIterator
Cells ()
 
void UpdatePrefs ()
 
void ApplyUpdatedTheme ()
 
void OnPaint (wxPaintEvent &event)
 
void OnMouseEvent (wxMouseEvent &event)
 
void OnCaptureLost (wxMouseCaptureLostEvent &event)
 Should handle the case when the mouse capture is lost. More...
 
void OnCaptureKey (wxCommandEvent &event)
 
void OnKeyDown (wxKeyEvent &event)
 
void OnChar (wxKeyEvent &event)
 
void OnKeyUp (wxKeyEvent &event)
 
void OnSetFocus (wxFocusEvent &event)
 
void OnKillFocus (wxFocusEvent &event)
 
void OnContextMenu (wxContextMenuEvent &event)
 
void OnPlayback (wxCommandEvent &)
 
void OnTrackListResizing (wxCommandEvent &event)
 
void OnTrackListDeletion (wxCommandEvent &event)
 
void UpdateViewIfNoTracks ()
 
double GetMostRecentXPos ()
 
void OnIdle (wxIdleEvent &event)
 
void OnTimer (wxTimerEvent &event)
 AS: This gets called on our wx timer events. More...
 
int GetLeftOffset () const
 
void GetTracksUsableArea (int *width, int *height) const
 
void Refresh (bool eraseBackground=true, const wxRect *rect=(const wxRect *) NULL) override
 
void RefreshTrack (Track *trk, bool refreshbacking=true)
 
void DisplaySelection ()
 Displays the bounds of the selection in the status bar. More...
 
void HandleInterruptedDrag ()
 
void Uncapture (wxMouseState *pState=nullptr)
 
bool CancelDragging ()
 
bool HandleEscapeKey (bool down)
 
void UpdateMouseState (const wxMouseState &state)
 
void HandleModifierKey ()
 
void HandlePageUpKey ()
 
void HandlePageDownKey ()
 
AudacityProjectGetProject () const
 
void ScrollIntoView (double pos)
 
void ScrollIntoView (int x)
 
void OnTrackMenu (Track *t=NULL)
 
TrackGetFirstSelectedTrack ()
 
bool IsMouseCaptured ()
 Determines if a modal tool is active. More...
 
void EnsureVisible (Track *t)
 
TrackGetFocusedTrack ()
 
void SetFocusedTrack (Track *t)
 
void HandleCursorForPresentMouseState (bool doHit=true)
 
void UpdateVRulers ()
 
void UpdateVRuler (Track *t)
 
void UpdateTrackVRuler (const Track *t)
 
void UpdateVRulerSize ()
 
double GetScreenEndTime () const
 
size_t GetTrackCount () const
 
size_t GetSelectedTrackCount () const
 
void UpdateAccessibility ()
 
void MessageForScreenReader (const wxString &message)
 
void HandleWheelRotation (TrackPanelMouseEvent &tpmEvent)
 Handle mouse wheel rotation (for zoom in/out, vertical and horizontal scrolling) More...
 
void MakeParentRedrawScrollbars ()
 
const TrackListGetTracks () const
 
TrackListGetTracks ()
 
ViewInfoGetViewInfo ()
 
TrackPanelListenerGetListener ()
 
AdornedRulerPanelGetRuler ()
 
void SetBackgroundCell (const std::shared_ptr< TrackPanelCell > &pCell)
 
std::shared_ptr< TrackPanelCellGetBackgroundCell ()
 
LWSliderGainSlider (const WaveTrack *wt)
 
LWSliderPanSlider (const WaveTrack *wt)
 
TrackInfoGetTrackInfo ()
 
const TrackInfoGetTrackInfo () const
 
TrackPanelAxGetAx ()
 
UIHandlePtr Target ()
 
- Public Member Functions inherited from OverlayPanel
 OverlayPanel (wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, long style=wxTAB_TRAVERSAL|wxNO_BORDER)
 
void AddOverlay (Overlay *pOverlay)
 
bool RemoveOverlay (Overlay *pOverlay)
 
void ClearOverlays ()
 
void DrawOverlays (bool repaint_all, wxDC *pDC=nullptr)
 
- Public Member Functions inherited from BackedPanel
 BackedPanel (wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, long style)
 
 ~BackedPanel ()
 
wxDC & GetBackingDC ()
 
wxDC & GetBackingDCForRepaint ()
 
void ResizeBacking ()
 
void RepairBitmap (wxDC &dc, wxCoord x, wxCoord y, wxCoord width, wxCoord height)
 
void DisplayBitmap (wxDC &dc)
 
void OnSize (wxSizeEvent &event)
 
- Public Member Functions inherited from wxTabTraversalWrapper< Base >
template<typename... Args>
 wxTabTraversalWrapper (Args &&...args)
 
 ~wxTabTraversalWrapper ()
 

Static Public Member Functions

static bool HasSoloButton ()
 

Public Attributes

wxSize vrulerSize
 

Static Public Attributes

static TrackPanel *(* FactoryFunction )(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, const std::shared_ptr< TrackList > &tracks, ViewInfo *viewInfo, TrackPanelListener *listener, AdornedRulerPanel *ruler) = TrackPanelFactory
 

Protected Member Functions

bool IsAudioActive ()
 
void HandleClick (const TrackPanelMouseEvent &tpmEvent)
 
void UpdateSelectionDisplay ()
 
void MakeParentModifyState (bool bWantsAutoSave)
 
FoundCell FindCell (int mouseX, int mouseY)
 
void HandleMotion (wxMouseState &state, bool doHit=true)
 
void HandleMotion (const TrackPanelMouseState &tpmState, bool doHit=true)
 
wxRect FindTrackRect (const Track *target, bool label)
 
int GetVRulerWidth () const
 
int GetVRulerOffset () const
 
int GetLabelWidth () const
 
void DrawTracks (wxDC *dc)
 
void DrawEverythingElse (TrackPanelDrawingContext &context, const wxRegion &region, const wxRect &clip)
 
void DrawOutside (TrackPanelDrawingContext &context, Track *t, const wxRect &rec)
 
void HighlightFocusedTrack (wxDC *dc, const wxRect &rect)
 Draw a three-level highlight gradient around the focused track. More...
 
void DrawShadow (Track *t, wxDC *dc, const wxRect &rect)
 
void DrawBordersAroundTrack (Track *t, wxDC *dc, const wxRect &rect, const int labelw, const int vrul)
 
void DrawOutsideOfTrack (TrackPanelDrawingContext &context, Track *t, const wxRect &rect)
 
void ClearTargets ()
 
bool HasRotation ()
 
bool HasEscape ()
 
bool ChangeTarget (bool forward, bool cycle)
 

Protected Attributes

TrackInfo mTrackInfo
 
TrackPanelListenermListener
 
std::shared_ptr< TrackListmTracks
 
ViewInfomViewInfo
 
AdornedRulerPanelmRuler
 
std::unique_ptr< TrackArtistmTrackArtist
 
TrackPanel::AudacityTimer mTimer
 
int mTimeCount
 
bool mRefreshBacking
 
bool mRedrawAfterStop
 
wxMouseState mLastMouseState
 
int mMouseMostRecentX
 
int mMouseMostRecentY
 
std::unique_ptr< TrackPanelAxmAx
 
SelectedRegion mLastDrawnSelectedRegion {}
 
std::weak_ptr< TrackPanelCellmLastCell
 
std::vector< UIHandlePtrmTargets
 
size_t mTarget {}
 
unsigned mMouseOverUpdateFlags {}
 
std::weak_ptr< TrackmpClickedTrack
 
UIHandlePtr mUIHandle
 
std::shared_ptr< TrackPanelCellmpBackground
 
bool mEnableTab {}
 

Static Protected Attributes

static wxString gSoloPref
 

Friends

class TrackPanelAx
 
class ScreenshotCommand
 

Detailed Description

The TrackPanel class coordinates updates and operations on the main part of the screen which contains multiple tracks.

It uses many other classes, but in particular it uses the TrackInfo class to draw the controls area on the left of a track, and the TrackArtist class to draw the actual waveforms.

Note that in some of the older code here, e.g., GetLabelWidth(), "Label" means the TrackInfo plus the vertical ruler. Confusing relative to LabelTrack labels.

The TrackPanel manages multiple tracks and their TrackInfos.

Note that with stereo tracks there will be one TrackInfo being used by two wavetracks.

Constructor & Destructor Documentation

TrackPanel::TrackPanel ( wxWindow *  parent,
wxWindowID  id,
const wxPoint &  pos,
const wxSize &  size,
const std::shared_ptr< TrackList > &  tracks,
ViewInfo viewInfo,
TrackPanelListener listener,
AdornedRulerPanel ruler 
)
TrackPanel::~TrackPanel ( )
virtual

Member Function Documentation

void TrackPanel::ApplyUpdatedTheme ( )
IteratorRange< TrackPanelCellIterator > TrackPanel::Cells ( )

Referenced by FindCell().

bool TrackPanel::ChangeTarget ( bool  forward,
bool  cycle 
)
protected

References IsMouseCaptured(), mTarget, mTargets, and Target().

Referenced by HandleEscapeKey(), and OnKeyDown().

void TrackPanel::ClearTargets ( )
inlineprotected
void TrackPanel::DisplaySelection ( )

Displays the bounds of the selection in the status bar.

References mListener, and TrackPanelListener::TP_DisplaySelection().

Referenced by OnTimer(), Refresh(), and UpdateSelectionDisplay().

void TrackPanel::DrawBordersAroundTrack ( Track t,
wxDC *  dc,
const wxRect &  rect,
const int  labelw,
const int  vrul 
)
protected
void TrackPanel::DrawEverythingElse ( TrackPanelDrawingContext context,
const wxRegion &  region,
const wxRect &  clip 
)
protected
void TrackPanel::DrawOutsideOfTrack ( TrackPanelDrawingContext context,
Track t,
const wxRect &  rect 
)
protected
void TrackPanel::DrawShadow ( Track t,
wxDC *  dc,
const wxRect &  rect 
)
protected

References AColor::Dark(), and AColor::Line().

void TrackPanel::DrawTracks ( wxDC *  dc)
protected

Draw the actual track areas. We only draw the borders and the little buttons and menues and whatnot here, the actual contents of each track are drawn by the TrackArtist.

References DrawEverythingElse(), drawTool, envelopeTool, AudacityProject::GetFirstVisible(), GetLabelWidth(), GetProject(), GetTracks(), ToolsToolBar::IsDown(), mLastMouseState, mListener, mTrackArtist, multiTool, mViewInfo, ViewInfo::selectedRegion, Target(), TrackPanelListener::TP_GetToolsToolBar(), and ZoomInfo::vpos.

Referenced by OnPaint().

TrackPanel::FoundCell TrackPanel::FindCell ( int  mouseX,
int  mouseY 
)
protected

Determines which cell is under the mouse

Parameters
mouseX- mouse X position.
mouseY- mouse Y position.

References Cells().

Referenced by HandleMotion(), and OnMouseEvent().

TrackPanelAx& TrackPanel::GetAx ( )
inline
std::shared_ptr< TrackPanelCell > TrackPanel::GetBackgroundCell ( )
int TrackPanel::GetLabelWidth ( ) const
inlineprotected

Referenced by DrawTracks(), and GetMostRecentXPos().

TrackPanelListener* TrackPanel::GetListener ( )
inline
AudacityProject * TrackPanel::GetProject ( ) const
AdornedRulerPanel* TrackPanel::GetRuler ( )
inline
size_t TrackPanel::GetSelectedTrackCount ( ) const
size_t TrackPanel::GetTrackCount ( ) const
TrackInfo* TrackPanel::GetTrackInfo ( )
inline
const TrackInfo* TrackPanel::GetTrackInfo ( ) const
inline
TrackList* TrackPanel::GetTracks ( )
inline
ViewInfo* TrackPanel::GetViewInfo ( )
inline
int TrackPanel::GetVRulerOffset ( ) const
inlineprotected
int TrackPanel::GetVRulerWidth ( ) const
protected

References vrulerSize.

Referenced by DrawEverythingElse(), and UpdateTrackVRuler().

void TrackPanel::HandleCursorForPresentMouseState ( bool  doHit = true)
bool TrackPanel::HandleEscapeKey ( bool  down)
void TrackPanel::HandleInterruptedDrag ( )

References mUIHandle.

Referenced by OnCaptureKey().

void TrackPanel::HandleModifierKey ( )

References HandleCursorForPresentMouseState().

Referenced by OnKeyDown(), and OnKeyUp().

void TrackPanel::HandleMotion ( wxMouseState &  inState,
bool  doHit = true 
)
protected

TrackPanel::HandleMotion( ) sets the cursor drawn at the mouse location, and updates the status bar message. We treat certain other changes of mouse button and key state as "motions" too, and also starting and stopping of playback or recording, all of which may cause the appropriate cursor and message to change. As this procedure checks which region the mouse is over, it is appropriate to establish the message in the status bar.

References FindCell(), mLastMouseState, and UpdateMouseState().

Referenced by HandleClick(), HandleCursorForPresentMouseState(), OnMouseEvent(), and Uncapture().

void TrackPanel::HandleMotion ( const TrackPanelMouseState tpmState,
bool  doHit = true 
)
protected
void TrackPanel::HandlePageDownKey ( )
void TrackPanel::HandlePageUpKey ( )
void TrackPanel::HandleWheelRotation ( TrackPanelMouseEvent tpmEvent)

Handle mouse wheel rotation (for zoom in/out, vertical and horizontal scrolling)

References TrackPanelMouseEvent::event, GetProject(), mRuler, TrackPanelMouseEvent::pCell, and TrackPanelMouseEvent::steps.

Referenced by OnMouseEvent().

bool TrackPanel::HasEscape ( )
protected
bool TrackPanel::HasRotation ( )
protected

References mTargets, and Target().

Referenced by OnCaptureKey(), and OnKeyDown().

static bool TrackPanel::HasSoloButton ( )
inlinestatic
void TrackPanel::HighlightFocusedTrack ( wxDC *  dc,
const wxRect &  rect 
)
protected

Draw a three-level highlight gradient around the focused track.

References kLeftInset, kTopInset, and AColor::TrackFocusPen().

Referenced by DrawEverythingElse().

bool TrackPanel::IsAudioActive ( )
protected

References GetProject(), and AudacityProject::IsAudioActive().

Referenced by OnTimer().

bool TrackPanel::IsMouseCaptured ( )

Determines if a modal tool is active.

References mUIHandle.

Referenced by ChangeTarget(), HasEscape(), OnMouseEvent(), AudacityProject::OnRedo(), and AudacityProject::OnUndo().

void TrackPanel::MakeParentModifyState ( bool  bWantsAutoSave)
protected
void TrackPanel::MakeParentRedrawScrollbars ( )
void TrackPanel::MessageForScreenReader ( const wxString &  message)
void TrackPanel::OnCaptureKey ( wxCommandEvent &  event)
void TrackPanel::OnCaptureLost ( wxMouseCaptureLostEvent &  event)

Should handle the case when the mouse capture is lost.

References ClearTargets(), mMouseMostRecentX, mMouseMostRecentY, and OnMouseEvent().

void TrackPanel::OnChar ( wxKeyEvent &  event)

References GetFocusedTrack(), mRuler, and mViewInfo.

void TrackPanel::OnContextMenu ( wxContextMenuEvent &  event)

References OnTrackMenu().

void TrackPanel::OnIdle ( wxIdleEvent &  event)

References GetProject(), kTimerInterval, and mTimer.

Referenced by TrackPanel().

void TrackPanel::OnKeyUp ( wxKeyEvent &  event)
void TrackPanel::OnKillFocus ( wxFocusEvent &  event)
void TrackPanel::OnMouseEvent ( wxMouseEvent &  event)
void TrackPanel::OnPaint ( wxPaintEvent &  event)
void TrackPanel::OnPlayback ( wxCommandEvent &  e)
void TrackPanel::OnSetFocus ( wxFocusEvent &  event)
void TrackPanel::OnTrackListDeletion ( wxCommandEvent &  event)
void TrackPanel::OnTrackListResizing ( wxCommandEvent &  event)

References UpdateVRuler().

Referenced by TrackPanel(), and ~TrackPanel().

void TrackPanel::OnTrackMenu ( Track t = NULL)
void TrackPanel::Refresh ( bool  eraseBackground = true,
const wxRect *  rect = (const wxRect *) NULL 
)
override

This method overrides Refresh() of wxWindow so that the boolean play indictaor can be set to false, so that an old play indicator that is no longer there won't get XORed (to erase it), thus redrawing it on the TrackPanel

References DisplaySelection(), and mRefreshBacking.

Referenced by AudacityProject::AS_ModifySelection(), AudacityProject::AS_SetSelectionFormat(), WaveformPrefs::Commit(), AudacityProject::DoNextPeakFrequency(), AudacityProject::DoScroll(), AudacityProject::DoTrackMute(), AudacityProject::DoTrackSolo(), EnsureVisible(), AudacityProject::FixScrollbars(), AudacityProject::MoveTrack(), AudacityProject::OnBoundaryMove(), AudacityProject::OnCopy(), AudacityProject::OnCopyLabels(), AudacityProject::OnCursorClipBoundary(), AudacityProject::OnCursorSelEnd(), AudacityProject::OnCursorSelStart(), AudacityProject::OnCursorTrackEnd(), AudacityProject::OnCursorTrackStart(), AudacityProject::OnCut(), AudacityProject::OnEffect(), OnKillFocus(), AudacityProject::OnNextTool(), AudacityProject::OnODTaskComplete(), AudacityProject::OnODTaskUpdate(), AudacityProject::OnPrevTool(), AudacityProject::OnRemoveTracks(), AudacityProject::OnSelectClip(), AudacityProject::OnSelectClipBoundary(), AudacityProject::OnSelectCursorEnd(), AudacityProject::OnSelectCursorStoredCursor(), AudacityProject::OnSelectionRestore(), AudacityProject::OnSelectStartCursor(), AudacityProject::OnSelectSyncLockSel(), AudacityProject::OnSelectTimeAndTracks(), OnSetFocus(), AudacityProject::OnSetLeftSelection(), AudacityProject::OnSetRightSelection(), AudacityProject::OnShowClipping(), AudacityProject::OnSilence(), AudacityProject::OnSilenceLabels(), AudacityProject::OnSortName(), AudacityProject::OnSortTime(), AudacityProject::OnSplit(), AudacityProject::OnSyncLock(), OnTimer(), AudacityProject::PlaybackScroller::OnTimer(), SelectHandle::TimerHandler::OnTimer(), AudacityProject::OnToggleSpectralSelection(), AudacityProject::OnTrackClose(), AudacityProject::OnTrackMoveBottom(), AudacityProject::OnTrackMoveDown(), AudacityProject::OnTrackMoveTop(), AudacityProject::OnTrackMoveUp(), AudacityProject::OnZeroCrossing(), AudacityProject::OnZoomNormal(), AudacityProject::OpenFile(), SpectrumPrefs::Preview(), AudacityProject::RedrawProject(), RefreshTrack(), AudacityProject::RemoveTrack(), SpectrumPrefs::Rollback(), ScrollIntoView(), AudacityProject::SelectNone(), SetFocusedTrack(), AudacityProject::SetStateTo(), AudacityProject::SetSyncLock(), AudacityProject::SetTool(), AudacityProject::SkipEnd(), AudacityProject::SSBL_ModifySpectralSelection(), UpdatePrefs(), UpdateSelectionDisplay(), UpdateVRulerSize(), and AudacityProject::ZoomInByFactor().

void TrackPanel::ScrollIntoView ( int  x)
void TrackPanel::SetBackgroundCell ( const std::shared_ptr< TrackPanelCell > &  pCell)
void TrackPanel::Uncapture ( wxMouseState *  pState = nullptr)

References HandleMotion().

Referenced by CancelDragging(), and OnMouseEvent().

void TrackPanel::UpdateAccessibility ( )
void TrackPanel::UpdateMouseState ( const wxMouseState &  state)

References mLastMouseState.

Referenced by HandleMotion(), and OnMouseEvent().

void TrackPanel::UpdateSelectionDisplay ( )
protected
void TrackPanel::UpdateTrackVRuler ( const Track t)
void TrackPanel::UpdateVRuler ( Track t)

Friends And Related Function Documentation

friend class ScreenshotCommand
friend
friend class TrackPanelAx
friend

Member Data Documentation

TrackPanel *(* TrackPanel::FactoryFunction)(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, const std::shared_ptr< TrackList > &tracks, ViewInfo *viewInfo, TrackPanelListener *listener, AdornedRulerPanel *ruler) = TrackPanelFactory
static
wxString TrackPanel::gSoloPref
staticprotected

Referenced by UpdatePrefs().

bool TrackPanel::mEnableTab {}
protected

Referenced by OnCaptureKey(), and OnKeyDown().

std::weak_ptr<TrackPanelCell> TrackPanel::mLastCell
protected
SelectedRegion TrackPanel::mLastDrawnSelectedRegion {}
protected

Referenced by OnPaint(), and OnTimer().

wxMouseState TrackPanel::mLastMouseState
protected
int TrackPanel::mMouseMostRecentX
protected
int TrackPanel::mMouseMostRecentY
protected

Referenced by OnCaptureLost(), and OnMouseEvent().

unsigned TrackPanel::mMouseOverUpdateFlags {}
protected
std::shared_ptr<TrackPanelCell> TrackPanel::mpBackground
protected

Referenced by GetBackgroundCell().

std::weak_ptr<Track> TrackPanel::mpClickedTrack
protected
bool TrackPanel::mRedrawAfterStop
protected

Referenced by OnTimer(), and TrackPanel().

bool TrackPanel::mRefreshBacking
protected
size_t TrackPanel::mTarget {}
protected

Referenced by ChangeTarget(), and HasEscape().

std::vector<UIHandlePtr> TrackPanel::mTargets
protected
int TrackPanel::mTimeCount
protected

Referenced by OnTimer(), and TrackPanel().

TrackPanel::AudacityTimer TrackPanel::mTimer
protected
std::unique_ptr<TrackArtist> TrackPanel::mTrackArtist
protected
TrackInfo TrackPanel::mTrackInfo
protected

Referenced by ApplyUpdatedTheme(), and UpdatePrefs().

std::shared_ptr<TrackList> TrackPanel::mTracks
protected
wxSize TrackPanel::vrulerSize

Referenced by GetVRulerWidth(), and UpdateVRulerSize().


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