Audacity  3.0.3
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
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:
[legend]
Collaboration diagram for TrackPanel:
[legend]

Classes

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

Public Member Functions

 TrackPanel (wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, const std::shared_ptr< TrackList > &tracks, ViewInfo *viewInfo, AudacityProject *project, AdornedRulerPanel *ruler)
 
virtual ~ TrackPanel ()
 
void UpdatePrefs () override
 
void OnAudioIO (wxCommandEvent &evt)
 
void OnPaint (wxPaintEvent &event)
 
void OnMouseEvent (wxMouseEvent &event)
 
void OnKeyDown (wxKeyEvent &event)
 
void OnTrackListResizing (TrackListEvent &event)
 
void OnTrackListDeletion (wxEvent &event)
 
void OnEnsureVisible (TrackListEvent &event)
 
void UpdateViewIfNoTracks ()
 
double GetMostRecentXPos ()
 
void OnSize (wxSizeEvent &)
 
void OnIdle (wxIdleEvent &event)
 
void OnTimer (wxTimerEvent &event)
 AS: This gets called on our wx timer events. More...
 
void OnProjectSettingsChange (wxCommandEvent &event)
 
void OnTrackFocusChange (wxCommandEvent &event)
 
void OnUndoReset (wxCommandEvent &event)
 
void Refresh (bool eraseBackground=true, const wxRect *rect=(const wxRect *) NULL) override
 
void RefreshTrack (Track *trk, bool refreshbacking=true)
 
void HandlePageUpKey ()
 
void HandlePageDownKey ()
 
AudacityProjectGetProject () const override
 
void OnTrackMenu (Track *t=NULL)
 
void VerticalScroll (float fracPosition)
 
TrackPanelCellGetFocusedCell () override
 
void SetFocusedCell () override
 
void UpdateVRulers ()
 
void UpdateVRuler (Track *t)
 
void UpdateTrackVRuler (Track *t)
 
void UpdateVRulerSize ()
 
size_t GetSelectedTrackCount () const
 
void MakeParentRedrawScrollbars ()
 
wxRect FindTrackRect (const Track *target)
 
const TrackListGetTracks () const
 
TrackListGetTracks ()
 
ViewInfoGetViewInfo ()
 
TrackPanelListenerGetListener ()
 
AdornedRulerPanelGetRuler ()
 
void SetBackgroundCell (const std::shared_ptr< TrackPanelCell > &pCell)
 
std::shared_ptr< TrackPanelCellGetBackgroundCell ()
 
- Public Member Functions inherited from CellularPanel
 CellularPanel (wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, ViewInfo *viewInfo, long style=wxTAB_TRAVERSAL|wxNO_BORDER)
 
 ~CellularPanel () override
 
void Visit (Visitor &visitor)
 
void VisitCells (const SimpleCellVisitor &visitor)
 
void VisitPreorder (const SimpleNodeVisitor &visitor)
 
void VisitPostorder (const SimpleNodeVisitor &visitor)
 
FoundCell FindCell (int mouseX, int mouseY)
 
wxRect FindRect (const TrackPanelCell &cell)
 
wxRect FindRect (const std::function< bool(TrackPanelNode &) > &pred)
 
UIHandlePtr Target ()
 
std::shared_ptr< TrackPanelCellLastCell () const
 
bool IsMouseCaptured ()
 Determines if a modal tool is active. More...
 
wxCoord MostRecentXCoord () const
 
void HandleCursorForPresentMouseState (bool doHit=true)
 
void Draw (TrackPanelDrawingContext &context, unsigned nPasses)
 
- 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 (const std::weak_ptr< 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 wxPanelWrapper
 wxPanelWrapper ()
 
 wxPanelWrapper (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const TranslatableString &name=XO("Panel"))
 
bool Create (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const TranslatableString &name=XO("Panel"))
 
void SetLabel (const TranslatableString &label)
 
void SetName (const TranslatableString &name)
 
void SetToolTip (const TranslatableString &toolTip)
 
void SetName ()
 
- Public Member Functions inherited from wxTabTraversalWrapper< wxPanel >
 wxTabTraversalWrapper (Args &&... args)
 
 wxTabTraversalWrapper (const wxTabTraversalWrapper &)=delete
 
 wxTabTraversalWrapper (wxTabTraversalWrapper &&)=delete
 
wxTabTraversalWrapperoperator= (const wxTabTraversalWrapper &)=delete
 
wxTabTraversalWrapperoperator= (wxTabTraversalWrapper &&)=delete
 
- Public Member Functions inherited from NonKeystrokeInterceptingWindow
virtual ~NonKeystrokeInterceptingWindow ()
 

Static Public Member Functions

static TrackPanelGet (AudacityProject &project)
 
static const TrackPanelGet (const AudacityProject &project)
 
static void Destroy (AudacityProject &project)
 

Protected Member Functions

bool IsAudioActive ()
 
void UpdateSelectionDisplay ()
 
std::shared_ptr< TrackPanelNodeRoot () override
 
void DrawTracks (wxDC *dc)
 
void ProcessUIHandleResult (TrackPanelCell *pClickedTrack, TrackPanelCell *pLatestCell, unsigned refreshResult) override
 
void UpdateStatusMessage (const TranslatableString &status) override
 
- Protected Member Functions inherited from CellularPanel
bool HasEscape ()
 
bool CancelDragging (bool escaping)
 
void DoContextMenu (TrackPanelCell *pCell=nullptr)
 
void ClearTargets ()
 

Protected Attributes

TrackPanelListenermListener
 
std::shared_ptr< TrackListmTracks
 
AdornedRulerPanelmRuler
 
std::unique_ptr< TrackArtistmTrackArtist
 
TrackPanel::AudacityTimer mTimer
 
int mTimeCount
 
bool mRefreshBacking
 
SelectedRegion mLastDrawnSelectedRegion {}
 
std::shared_ptr< TrackPanelCellmpBackground
 
- Protected Attributes inherited from CellularPanel
ViewInfomViewInfo
 
wxMouseState mLastMouseState
 

Additional Inherited Members

- Public Types inherited from CellularPanel
using SimpleCellVisitor = std::function< void(const wxRect &rect, TrackPanelCell &cell) >
 
using SimpleNodeVisitor = std::function< void(const wxRect &rect, TrackPanelNode &node) >
 
- Private Member Functions inherited from PrefsListener
 PrefsListener ()
 
virtual ~PrefsListener ()
 
virtual void UpdateSelectedPrefs (int id)
 
- Static Private Member Functions inherited from PrefsListener
static void Broadcast (int id=0)
 Call this static function to notify all PrefsListener objects. More...
 

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.

This is a diagram of TrackPanel's division of one (non-stereo) track rectangle. Total height equals TrackView::GetHeight()'s value. Total width is the wxWindow's width. Each character that is not . represents one pixel.

Inset space of this track, and top inset of the next track, are used to draw the focus highlight.

Top inset of the right channel of a stereo track, and bottom shadow line of the left channel, are used for the channel separator.

"Margin" is a term used for inset plus border (top and left) or inset plus shadow plus border (right and bottom).

GetVRulerOffset() counts columns from the left edge up to and including controls, and is a constant.

GetVRulerWidth() is variable – all tracks have the same ruler width at any time, but that width may be adjusted when tracks change their vertical scales.

GetLabelWidth() counts columns up to and including the VRuler. GetLeftOffset() is yet one more – it counts the "one pixel" column.

Cell for label has a rectangle that OMITS left, top, and bottom margins

Cell for vruler has a rectangle right of the label, up to and including the One Pixel column, and OMITS top and bottom margins

Cell() for track returns a rectangle with x == GetLeftOffset(), and OMITS right, top, and bottom margins

+------------— ... ---— ... ------------------— ... ... ----------—+

Top Inset
+---------— ... ---— ... ------------------— ... ... -------—+

| L|+-Border-— ... ---— ... ------------------— ... ... -Border-+ |R | | e||+-------— ... -++— ... -+++--------------— ... ... ----—+| |i | | f|B| || ||| |BS|g | | t|o| Controls || V |O| The good stuff |oh|h | | |r| || R |n| |ra|t | | I|d| || u |e| |dd| | | n|e| || l | | |eo|I | | s|r| || e |P| |rw|n | | e||| || r |i| ||||s | | t||| || |x| ||||e | | ||| || |e| ||||t | | ||| || |l| |||| | | ||| || ||| |||| |

. ... .. ... .... . . ... .. ... .... . . ... .. ... .... .

| ||| || ||| |||| | | ||+-------— -++– ... -+++--------------— ... ... ----—+||| | | |+-Border-— ... --— ... ------------------— ... ... -Border-+|| | | | Shadow-— ... --— ... ------------------— ... ... –Shadow-+| |

Definition at line 60 of file TrackPanel.h.

Constructor & Destructor Documentation

◆ TrackPanel()

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

Definition at line 244 of file TrackPanel.cpp.

251  : CellularPanel(parent, id, pos, size, viewInfo,
252  wxWANTS_CHARS | wxNO_BORDER),
253  mListener( &ProjectWindow::Get( *project ) ),
254  mTracks(tracks),
255  mRuler(ruler),
256  mTrackArtist(nullptr),
257  mRefreshBacking(false)
258 #ifndef __WXGTK__ //Get rid if this pragma for gtk
259 #pragma warning( default: 4355 )
260 #endif
261 {
262  SetLayoutDirection(wxLayout_LeftToRight);
263  SetLabel(XO("Track Panel"));
264  SetName(XO("Track Panel"));
265  SetBackgroundStyle(wxBG_STYLE_PAINT);
266 
267  {
268  auto pAx = std::make_unique <TrackPanelAx>( *project );
269  pAx->SetWindow( this );
270  wxWeakRef< TrackPanel > weakThis{ this };
271  pAx->SetFinder(
272  [weakThis]( const Track &track ) -> wxRect {
273  if (weakThis)
274  return weakThis->FindTrackRect( &track );
275  return {};
276  }
277  );
278  TrackFocus::Get( *GetProject() ).SetAccessible(
279  *this, std::move( pAx ) );
280  }
281 
282  mTrackArtist = std::make_unique<TrackArtist>( this );
283 
284  mTimeCount = 0;
285  mTimer.parent = this;
286  // Timer is started after the window is visible
287  ProjectWindow::Get( *GetProject() ).Bind(wxEVT_IDLE,
288  &TrackPanel::OnIdle, this);
289 
290  // Register for tracklist updates
291  mTracks->Bind(EVT_TRACKLIST_RESIZING,
293  this);
294  mTracks->Bind(EVT_TRACKLIST_ADDITION,
296  this);
297  mTracks->Bind(EVT_TRACKLIST_DELETION,
299  this);
300  mTracks->Bind(EVT_TRACKLIST_TRACK_REQUEST_VISIBLE,
302  this);
303 
304  auto theProject = GetProject();
305  theProject->Bind(
306  EVT_PROJECT_SETTINGS_CHANGE, &TrackPanel::OnProjectSettingsChange, this);
307  theProject->Bind(
308  EVT_TRACK_FOCUS_CHANGE, &TrackPanel::OnTrackFocusChange, this );
309 
310  theProject->Bind(EVT_UNDO_RESET, &TrackPanel::OnUndoReset, this);
311 
312  wxTheApp->Bind(EVT_AUDIOIO_PLAYBACK,
314  this);
315  wxTheApp->Bind(EVT_AUDIOIO_CAPTURE,
317  this);
318  UpdatePrefs();
319 }

References TrackFocus::Get(), ProjectWindow::Get(), GetProject(), mTimeCount, mTimer, mTrackArtist, mTracks, OnAudioIO(), OnEnsureVisible(), OnIdle(), OnProjectSettingsChange(), OnTrackFocusChange(), OnTrackListDeletion(), OnTrackListResizing(), OnUndoReset(), TrackPanel::AudacityTimer::parent, wxPanelWrapper::SetLabel(), wxPanelWrapper::SetName(), UpdatePrefs(), and XO.

Here is the call graph for this function:

◆ ~ TrackPanel()

virtual TrackPanel::~ TrackPanel ( )
virtual

Member Function Documentation

◆ Destroy()

void TrackPanel::Destroy ( AudacityProject project)
static

Definition at line 231 of file TrackPanel.cpp.

232 {
233  auto *pPanel = project.AttachedWindows::Find( sKey );
234  if (pPanel) {
235  pPanel->wxWindow::Destroy();
236  project.AttachedWindows::Assign( sKey, nullptr );
237  }
238 }

References anonymous_namespace{TrackPanel.cpp}::sKey.

Referenced by ProjectManager::OnCloseWindow().

Here is the caller graph for this function:

◆ DrawTracks()

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.

Definition at line 813 of file TrackPanel.cpp.

814 {
815  wxRegion region = GetUpdateRegion();
816 
817  const wxRect clip = GetRect();
818 
820  mTrackArtist->pSelectedRegion = &sr;
821  mTrackArtist->pZoomInfo = mViewInfo;
822  TrackPanelDrawingContext context {
823  *dc, Target(), mLastMouseState, mTrackArtist.get()
824  };
825 
826  // Don't draw a bottom margin here.
827 
828  const auto &settings = ProjectSettings::Get( *GetProject() );
829  bool bMultiToolDown =
830  (ToolCodes::multiTool == settings.GetTool());
831  bool envelopeFlag =
832  bMultiToolDown || (ToolCodes::envelopeTool == settings.GetTool());
833  bool bigPointsFlag =
834  bMultiToolDown || (ToolCodes::drawTool == settings.GetTool());
835  bool sliderFlag = bMultiToolDown;
836 
837  const bool hasSolo = GetTracks()->Any< PlayableTrack >()
838  .any_of( []( const PlayableTrack *pt ) {
839  pt = static_cast< const PlayableTrack * >(
840  pt->SubstitutePendingChangedTrack().get() );
841  return (pt && pt->GetSolo());
842  } );
843 
844  mTrackArtist->drawEnvelope = envelopeFlag;
845  mTrackArtist->bigPoints = bigPointsFlag;
846  mTrackArtist->drawSliders = sliderFlag;
847  mTrackArtist->hasSolo = hasSolo;
848 
849  this->CellularPanel::Draw( context, TrackArtist::NPasses );
850 }

References TrackList::Any(), CellularPanel::Draw(), ToolCodes::drawTool, ToolCodes::envelopeTool, ProjectSettings::Get(), GetProject(), PlayableTrack::GetSolo(), GetTracks(), CellularPanel::mLastMouseState, mTrackArtist, ToolCodes::multiTool, CellularPanel::mViewInfo, TrackArtist::NPasses, ViewInfo::selectedRegion, settings(), Track::SubstitutePendingChangedTrack(), and CellularPanel::Target().

Referenced by OnPaint().

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

◆ FindTrackRect()

wxRect TrackPanel::FindTrackRect ( const Track target)

Definition at line 1588 of file TrackPanel.cpp.

1589 {
1590  auto leader = *GetTracks()->FindLeader( target );
1591  if (!leader) {
1592  return { 0, 0, 0, 0 };
1593  }
1594 
1595  return CellularPanel::FindRect( [&] ( TrackPanelNode &node ) {
1596  if (auto pGroup = dynamic_cast<const LabeledChannelGroup*>( &node ))
1597  return pGroup->mpTrack.get() == leader;
1598  return false;
1599  } );
1600 }

References TrackList::FindLeader(), CellularPanel::FindRect(), and GetTracks().

Referenced by ScreenshotCommand::GetTrackRect().

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

◆ Get() [1/2]

TrackPanel & TrackPanel::Get ( AudacityProject project)
static

Definition at line 221 of file TrackPanel.cpp.

222 {
223  return project.AttachedWindows::Get< TrackPanel >( sKey );
224 }

References anonymous_namespace{TrackPanel.cpp}::sKey.

Referenced by ScreenshotCommand::Apply(), SelectTimeCommand::Apply(), SetTrackVisualsCommand::ApplyInner(), ProjectSelectionManager::AS_ModifySelection(), ProjectSelectionManager::AS_SetSelectionFormat(), SelectHandle::Click(), WaveformPrefs::Commit(), MenuButtonHandle::CommitChanges(), LabelTrackView::DialogForLabelName(), anonymous_namespace{LabelMenus.cpp}::DoAddLabel(), EffectUI::DoEffect(), anonymous_namespace{TrackMenus.cpp}::DoMixAndRender(), TrackUtilities::DoRemoveTracks(), EditCursorOverlay::Draw(), DeviceToolBar::EnableDisableButtons(), GetInfoCommand::ExploreTrackPanel(), Get(), MixerTrackCluster::HandleSliderGain(), MixerTrackCluster::HandleSliderPan(), GainSliderHandle::HitTest(), PanSliderHandle::HitTest(), InitProjectWindow(), anonymous_namespace{SelectMenus.cpp}::MoveWhenAudioInactive(), ProjectManager::New(), anonymous_namespace{NavigationMenus.cpp}::NextOrPrevFrame(), MixerTrackCluster::OnButton_Mute(), EditActions::Handler::OnCopy(), EditActions::Handler::OnCut(), ToolActions::Handler::OnNextTool(), LabelEditActions::Handler::OnPasteNewLabel(), TransportActions::Handler::OnPlayOneSecond(), TransportActions::Handler::OnPlayToSelection(), ToolActions::Handler::OnPrevTool(), FileActions::Handler::OnPrint(), EditActions::Handler::OnRedo(), ViewActions::Handler::OnShowClipping(), ViewActions::Handler::OnShowNameOverlay(), TrackActions::Handler::OnSyncLock(), SelectHandle::TimerHandler::OnTimer(), TrackActions::Handler::OnTrackClose(), TrackActions::Handler::OnTrackGain(), TrackActions::Handler::OnTrackGainDec(), TrackActions::Handler::OnTrackGainInc(), TrackActions::Handler::OnTrackMenu(), TrackActions::Handler::OnTrackMoveBottom(), TrackActions::Handler::OnTrackMoveDown(), TrackActions::Handler::OnTrackMoveTop(), TrackActions::Handler::OnTrackMoveUp(), TrackActions::Handler::OnTrackPan(), TrackActions::Handler::OnTrackPanLeft(), TrackActions::Handler::OnTrackPanRight(), EditActions::Handler::OnUndo(), ViewActions::Handler::OnZoomIn(), ViewActions::Handler::OnZoomNormal(), ViewActions::Handler::OnZoomToggle(), ProjectFileManager::OpenProjectFile(), SpectrumPrefs::Preview(), SpectrumPrefs::Rollback(), SelectUtilities::SelectNone(), anonymous_namespace{ToolsToolBar.cpp}::SetTool(), anonymous_namespace{TrackMenus.cpp}::SetTrackGain(), anonymous_namespace{TrackMenus.cpp}::SetTrackPan(), and ProjectSelectionManager::SSBL_ModifySpectralSelection().

◆ Get() [2/2]

const TrackPanel & TrackPanel::Get ( const AudacityProject project)
static

Definition at line 226 of file TrackPanel.cpp.

227 {
228  return Get( const_cast< AudacityProject & >( project ) );
229 }

References Get().

Here is the call graph for this function:

◆ GetBackgroundCell()

std::shared_ptr< TrackPanelCell > TrackPanel::GetBackgroundCell ( )

Definition at line 858 of file TrackPanel.cpp.

859 {
860  return mpBackground;
861 }

References mpBackground.

◆ GetFocusedCell()

TrackPanelCell * TrackPanel::GetFocusedCell ( )
overridevirtual

Implements CellularPanel.

Definition at line 1602 of file TrackPanel.cpp.

1603 {
1604  auto pTrack = TrackFocus::Get( *GetProject() ).Get();
1605  return pTrack ? &TrackView::Get( *pTrack ) : nullptr;
1606 }

References TrackFocus::Get(), ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >::Get(), TrackView::Get(), and GetProject().

Referenced by OnTrackFocusChange().

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

◆ GetListener()

TrackPanelListener* TrackPanel::GetListener ( )
inline

Definition at line 153 of file TrackPanel.h.

153 { return mListener;}

◆ GetMostRecentXPos()

double TrackPanel::GetMostRecentXPos ( )

Definition at line 743 of file TrackPanel.cpp.

744 {
745  return mViewInfo->PositionToTime(
747 }

References ZoomInfo::GetLabelWidth(), CellularPanel::MostRecentXCoord(), CellularPanel::mViewInfo, and ZoomInfo::PositionToTime().

Here is the call graph for this function:

◆ GetProject()

AudacityProject * TrackPanel::GetProject ( ) const
overridevirtual

Gets the pointer to the AudacityProject that goes with this track panel.

Implements CellularPanel.

Definition at line 343 of file TrackPanel.cpp.

344 {
345  //JKC casting away constness here.
346  //Do it in two stages in case 'this' is not a wxWindow.
347  //when the compiler will flag the error.
348  wxWindow const * const pConstWind = this;
349  wxWindow * pWind=(wxWindow*)pConstWind;
350 #ifdef EXPERIMENTAL_NOTEBOOK
351  pWind = pWind->GetParent(); //Page
352  wxASSERT( pWind );
353  pWind = pWind->GetParent(); //Notebook
354  wxASSERT( pWind );
355 #endif
356  pWind = pWind->GetParent(); //MainPanel
357  wxASSERT( pWind );
358  pWind = pWind->GetParent(); //ProjectWindow
359  wxASSERT( pWind );
360  return &static_cast<ProjectWindow*>( pWind )->GetProject();
361 }

Referenced by DrawTracks(), GetFocusedCell(), IsAudioActive(), OnEnsureVisible(), OnIdle(), OnMouseEvent(), OnTimer(), OnTrackListDeletion(), OnUndoReset(), ProcessUIHandleResult(), SetFocusedCell(), TrackPanel(), UpdateStatusMessage(), and UpdateViewIfNoTracks().

Here is the caller graph for this function:

◆ GetRuler()

AdornedRulerPanel* TrackPanel::GetRuler ( )
inline

Definition at line 154 of file TrackPanel.h.

154 { return mRuler;}

Referenced by ScreenshotCommand::Apply(), and ScreenshotCommand::GetPanelRect().

Here is the caller graph for this function:

◆ GetSelectedTrackCount()

size_t TrackPanel::GetSelectedTrackCount ( ) const

Definition at line 634 of file TrackPanel.cpp.

635 {
636  return GetTracks()->SelectedLeaders().size();
637 }

References GetTracks(), and TrackList::SelectedLeaders().

Here is the call graph for this function:

◆ GetTracks() [1/2]

TrackList* TrackPanel::GetTracks ( )
inline

Definition at line 151 of file TrackPanel.h.

151 { return mTracks.get(); }

◆ GetTracks() [2/2]

const TrackList* TrackPanel::GetTracks ( ) const
inline

Definition at line 150 of file TrackPanel.h.

150 { return mTracks.get(); }

Referenced by DrawTracks(), FindTrackRect(), GetSelectedTrackCount(), OnEnsureVisible(), ProcessUIHandleResult(), RefreshTrack(), UpdateVRulers(), UpdateVRulerSize(), and VerticalScroll().

Here is the caller graph for this function:

◆ GetViewInfo()

ViewInfo* TrackPanel::GetViewInfo ( )
inline

Definition at line 152 of file TrackPanel.h.

152 { return mViewInfo;}

References CellularPanel::mViewInfo.

◆ HandlePageDownKey()

void TrackPanel::HandlePageDownKey ( )

Definition at line 603 of file TrackPanel.cpp.

References ZoomInfo::GetScreenEndTime(), mListener, CellularPanel::mViewInfo, and TrackPanelListener::TP_ScrollWindow().

Referenced by OnKeyDown().

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

◆ HandlePageUpKey()

void TrackPanel::HandlePageUpKey ( )

Definition at line 598 of file TrackPanel.cpp.

599 {
601 }

References ZoomInfo::GetScreenEndTime(), ZoomInfo::h, mListener, CellularPanel::mViewInfo, and TrackPanelListener::TP_ScrollWindow().

Referenced by OnKeyDown().

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

◆ IsAudioActive()

bool TrackPanel::IsAudioActive ( )
protected

Definition at line 608 of file TrackPanel.cpp.

609 {
611  return ProjectAudioIO::Get( *p ).IsAudioActive();
612 }

References ProjectAudioIO::Get(), GetProject(), and ProjectAudioIO::IsAudioActive().

Referenced by OnTimer().

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

◆ MakeParentRedrawScrollbars()

void TrackPanel::MakeParentRedrawScrollbars ( )

Definition at line 518 of file TrackPanel.cpp.

519 {
521 }

References mListener, and TrackPanelListener::TP_RedrawScrollbars().

Here is the call graph for this function:

◆ OnAudioIO()

void TrackPanel::OnAudioIO ( wxCommandEvent &  evt)

Definition at line 801 of file TrackPanel.cpp.

802 {
803  evt.Skip();
804  // Some hit tests want to change their cursor to and from the ban symbol
806 }

References BasicUI::CallAfter(), and CellularPanel::HandleCursorForPresentMouseState().

Referenced by TrackPanel().

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

◆ OnEnsureVisible()

void TrackPanel::OnEnsureVisible ( TrackListEvent event)

Definition at line 942 of file TrackPanel.cpp.

943 {
944  e.Skip();
945  bool modifyState = e.GetInt();
946 
947  auto pTrack = e.mpTrack.lock();
948  auto t = pTrack.get();
949 
950  int trackTop = 0;
951  int trackHeight =0;
952 
953  for (auto it : GetTracks()->Leaders()) {
954  trackTop += trackHeight;
955 
956  auto channels = TrackList::Channels(it);
957  trackHeight = channels.sum( TrackView::GetTrackHeight );
958 
959  //We have found the track we want to ensure is visible.
960  if (channels.contains(t)) {
961 
962  //Get the size of the trackpanel.
963  int width, height;
964  GetSize(&width, &height);
965 
966  if (trackTop < mViewInfo->vpos) {
967  height = mViewInfo->vpos - trackTop + mViewInfo->scrollStep;
968  height /= mViewInfo->scrollStep;
969  mListener->TP_ScrollUpDown(-height);
970  }
971  else if (trackTop + trackHeight > mViewInfo->vpos + height) {
972  height = (trackTop + trackHeight) - (mViewInfo->vpos + height);
973  height = (height + mViewInfo->scrollStep + 1) / mViewInfo->scrollStep;
974  mListener->TP_ScrollUpDown(height);
975  }
976 
977  break;
978  }
979  }
980  Refresh(false);
981 
982  if ( modifyState )
984 }

References TrackList::Channels(), ProjectHistory::Get(), GetProject(), TrackView::GetTrackHeight(), GetTracks(), mListener, ProjectHistory::ModifyState(), TrackListEvent::mpTrack, CellularPanel::mViewInfo, Refresh(), ViewInfo::scrollStep, TrackPanelListener::TP_ScrollUpDown(), and ZoomInfo::vpos.

Referenced by TrackPanel().

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

◆ OnIdle()

void TrackPanel::OnIdle ( wxIdleEvent &  event)

Definition at line 371 of file TrackPanel.cpp.

372 {
373  event.Skip();
374  // The window must be ready when the timer fires (#1401)
375  if (IsShownOnScreen())
376  {
377  mTimer.Start(kTimerInterval, FALSE);
378 
379  // Timer is started, we don't need the event anymore
380  GetProjectFrame( *GetProject() ).Unbind(wxEVT_IDLE,
381  &TrackPanel::OnIdle, this);
382  }
383  else
384  {
385  // Get another idle event, wx only guarantees we get one
386  // event after "some other normal events occur"
387  event.RequestMore();
388  }
389 }

References GetProject(), GetProjectFrame(), kTimerInterval, and mTimer.

Referenced by TrackPanel().

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

◆ OnKeyDown()

void TrackPanel::OnKeyDown ( wxKeyEvent &  event)

Definition at line 694 of file TrackPanel.cpp.

695 {
696  switch (event.GetKeyCode())
697  {
698  // Allow PageUp and PageDown keys to
699  //scroll the Track Panel left and right
700  case WXK_PAGEUP:
701  HandlePageUpKey();
702  return;
703 
704  case WXK_PAGEDOWN:
706  return;
707 
708  default:
709  // fall through to base class handler
710  event.Skip();
711  }
712 }

References HandlePageDownKey(), and HandlePageUpKey().

Here is the call graph for this function:

◆ OnMouseEvent()

void TrackPanel::OnMouseEvent ( wxMouseEvent &  event)

Definition at line 714 of file TrackPanel.cpp.

715 {
716  if (event.LeftDown()) {
717  // wxTimers seem to be a little unreliable, so this
718  // "primes" it to make sure it keeps going for a while...
719 
720  // When this timer fires, we call TrackPanel::OnTimer and
721  // possibly update the screen for offscreen scrolling.
722  mTimer.Stop();
723  mTimer.Start(kTimerInterval, FALSE);
724  }
725 
726 
727  if (event.ButtonUp()) {
728  //EnsureVisible should be called after processing the up-click.
729  this->CallAfter( [this, event]{
730  const auto foundCell = FindCell(event.m_x, event.m_y);
731  const auto t = FindTrack( foundCell.pCell.get() );
732  if ( t ) {
733  TrackFocus::Get(*GetProject()).Set(t.get());
734  t->EnsureVisible();
735  }
736  } );
737  }
738 
739  // Must also fall through to base class handler
740  event.Skip();
741 }

References BasicUI::CallAfter(), Track::EnsureVisible(), CellularPanel::FindCell(), anonymous_namespace{TrackPanel.cpp}::FindTrack(), TrackFocus::Get(), GetProject(), kTimerInterval, and mTimer.

Here is the call graph for this function:

◆ OnPaint()

void TrackPanel::OnPaint ( wxPaintEvent &  event)

AS: OnPaint( ) is called during the normal course of completing a repaint operation.

Definition at line 468 of file TrackPanel.cpp.

469 {
471 
472 #if DEBUG_DRAW_TIMING
473  wxStopWatch sw;
474 #endif
475 
476  {
477  wxPaintDC dc(this);
478 
479  // Retrieve the damage rectangle
480  wxRect box = GetUpdateRegion().GetBox();
481 
482  // Recreate the backing bitmap if we have a full refresh
483  // (See TrackPanel::Refresh())
484  if (mRefreshBacking || (box == GetRect()))
485  {
486  // Reset (should a mutex be used???)
487  mRefreshBacking = false;
488 
489  // Redraw the backing bitmap
491 
492  // Copy it to the display
493  DisplayBitmap(dc);
494  }
495  else
496  {
497  // Copy full, possibly clipped, damage rectangle
498  RepairBitmap(dc, box.x, box.y, box.width, box.height);
499  }
500 
501  // Done with the clipped DC
502 
503  // Drawing now goes directly to the client area.
504  // DrawOverlays() may need to draw outside the clipped region.
505  // (Used to make a NEW, separate wxClientDC, but that risks flashing
506  // problems on Mac.)
507  dc.DestroyClippingRegion();
508  DrawOverlays(true, &dc);
509  }
510 
511 #if DEBUG_DRAW_TIMING
512  sw.Pause();
513  wxLogDebug(wxT("Total: %ld milliseconds"), sw.Time());
514  wxPrintf(wxT("Total: %ld milliseconds\n"), sw.Time());
515 #endif
516 }

References BackedPanel::DisplayBitmap(), OverlayPanel::DrawOverlays(), DrawTracks(), BackedPanel::GetBackingDCForRepaint(), mLastDrawnSelectedRegion, mRefreshBacking, CellularPanel::mViewInfo, BackedPanel::RepairBitmap(), and ViewInfo::selectedRegion.

Here is the call graph for this function:

◆ OnProjectSettingsChange()

void TrackPanel::OnProjectSettingsChange ( wxCommandEvent &  event)

Definition at line 447 of file TrackPanel.cpp.

448 {
449  event.Skip();
450  switch ( static_cast<ProjectSettings::EventCode>( event.GetInt() ) ) {
452  Refresh(false);
453  break;
454  default:
455  break;
456  }
457 }

References ProjectSettings::ChangedSyncLock, and Refresh().

Referenced by TrackPanel().

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

◆ OnSize()

void TrackPanel::OnSize ( wxSizeEvent &  evt)

Definition at line 363 of file TrackPanel.cpp.

364 {
365  evt.Skip();
366  const auto &size = evt.GetSize();
367  mViewInfo->SetWidth( size.GetWidth() );
368  mViewInfo->SetHeight( size.GetHeight() );
369 }

References CellularPanel::mViewInfo, ViewInfo::SetHeight(), and ZoomInfo::SetWidth().

Here is the call graph for this function:

◆ OnTimer()

void TrackPanel::OnTimer ( wxTimerEvent &  event)

AS: This gets called on our wx timer events.

Definition at line 392 of file TrackPanel.cpp.

393 {
394  mTimeCount++;
395 
396  AudacityProject *const p = GetProject();
397  auto &window = ProjectWindow::Get( *p );
398 
399  auto &projectAudioIO = ProjectAudioIO::Get( *p );
400  auto gAudioIO = AudioIO::Get();
401 
402  // Check whether we were playing or recording, but the stream has stopped.
403  if (projectAudioIO.GetAudioIOToken()>0 && !IsAudioActive())
404  {
405  //the stream may have been started up after this one finished (by some other project)
406  //in that case reset the buttons don't stop the stream
407  auto &projectAudioManager = ProjectAudioManager::Get( *p );
408  projectAudioManager.Stop(!gAudioIO->IsStreamActive());
409  }
410 
411  // Next, check to see if we were playing or recording
412  // audio, but now Audio I/O is completely finished.
413  if (projectAudioIO.GetAudioIOToken()>0 &&
414  !gAudioIO->IsAudioTokenActive(projectAudioIO.GetAudioIOToken()))
415  {
416  projectAudioIO.SetAudioIOToken(0);
417  window.RedrawProject();
418  }
421  }
422 
423  // Notify listeners for timer ticks
424  {
425  wxCommandEvent e(EVT_TRACK_PANEL_TIMER);
426  p->ProcessEvent(e);
427  }
428 
429  DrawOverlays(false);
430  mRuler->DrawOverlays(false);
431 
432  if(IsAudioActive() && gAudioIO->GetNumCaptureChannels()) {
433 
434  // Periodically update the display while recording
435 
436  if ((mTimeCount % 5) == 0) {
437  // Must tell OnPaint() to recreate the backing bitmap
438  // since we've not done a full refresh.
439  mRefreshBacking = true;
440  Refresh( false );
441  }
442  }
443  if(mTimeCount > 1000)
444  mTimeCount = 0;
445 }

References OverlayPanel::DrawOverlays(), AudioIO::Get(), ProjectAudioIO::Get(), ProjectAudioManager::Get(), ProjectWindow::Get(), GetProject(), IsAudioActive(), mLastDrawnSelectedRegion, mRefreshBacking, mRuler, mTimeCount, CellularPanel::mViewInfo, Refresh(), ViewInfo::selectedRegion, and UpdateSelectionDisplay().

Here is the call graph for this function:

◆ OnTrackFocusChange()

void TrackPanel::OnTrackFocusChange ( wxCommandEvent &  event)

Definition at line 1616 of file TrackPanel.cpp.

1617 {
1618  event.Skip();
1619  auto cell = GetFocusedCell();
1620 
1621  if (cell) {
1622  Refresh( false );
1623  }
1624 }

References GetFocusedCell(), and Refresh().

Referenced by TrackPanel().

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

◆ OnTrackListDeletion()

void TrackPanel::OnTrackListDeletion ( wxEvent &  event)

Definition at line 677 of file TrackPanel.cpp.

678 {
679  // copy shared_ptr for safety, as in HandleClick
680  auto handle = Target();
681  if (handle) {
682  handle->OnProjectChange(GetProject());
683  }
684 
685  // If the focused track disappeared but there are still other tracks,
686  // this reassigns focus.
687  TrackFocus( *GetProject() ).Get();
688 
690 
691  e.Skip();
692 }

References TrackFocus::Get(), GetProject(), CellularPanel::Target(), and UpdateVRulerSize().

Referenced by TrackPanel().

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

◆ OnTrackListResizing()

void TrackPanel::OnTrackListResizing ( TrackListEvent event)

Definition at line 663 of file TrackPanel.cpp.

664 {
665  auto t = e.mpTrack.lock();
666  // A deleted track can trigger the event. In which case do nothing here.
667  // A deleted track can have a valid pointer but no owner, bug 2060
668  if( t && t->HasOwner() )
669  UpdateVRuler(t.get());
670  e.Skip();
671 
672  // fix for bug 2477
674 }

References mListener, TrackListEvent::mpTrack, TrackPanelListener::TP_RedrawScrollbars(), and UpdateVRuler().

Referenced by TrackPanel().

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

◆ OnTrackMenu()

void TrackPanel::OnTrackMenu ( Track t = NULL)

Definition at line 936 of file TrackPanel.cpp.

937 {
938  CellularPanel::DoContextMenu( t ? &TrackView::Get( *t ) : nullptr );
939 }

References CellularPanel::DoContextMenu(), and TrackView::Get().

Here is the call graph for this function:

◆ OnUndoReset()

void TrackPanel::OnUndoReset ( wxCommandEvent &  event)

Definition at line 459 of file TrackPanel.cpp.

460 {
461  event.Skip();
462  TrackFocus::Get( *GetProject() ).Set( nullptr );
463  Refresh( false );
464 }

References TrackFocus::Get(), GetProject(), and Refresh().

Referenced by TrackPanel().

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

◆ ProcessUIHandleResult()

void TrackPanel::ProcessUIHandleResult ( TrackPanelCell pClickedTrack,
TrackPanelCell pLatestCell,
unsigned  refreshResult 
)
overrideprotectedvirtual

Implements CellularPanel.

Definition at line 532 of file TrackPanel.cpp.

535 {
536  const auto panel = this;
537  auto pLatestTrack = FindTrack( pLatestCell ).get();
538 
539  // This precaution checks that the track is not only nonnull, but also
540  // really owned by the track list
541  auto pClickedTrack = GetTracks()->Lock(
542  std::weak_ptr<Track>{ FindTrack( pClickedCell ) }
543  ).get();
544 
545  // TODO: make a finer distinction between refreshing the track control area,
546  // and the waveform area. As it is, redraw both whenever you must redraw either.
547 
548  // Copy data from the underlying tracks to the pending tracks that are
549  // really displayed
550  TrackList::Get( *panel->GetProject() ).UpdatePendingTracks();
551 
552  using namespace RefreshCode;
553 
554  if (refreshResult & DestroyedCell) {
555  panel->UpdateViewIfNoTracks();
556  // Beware stale pointer!
557  if (pLatestTrack == pClickedTrack)
558  pLatestTrack = NULL;
559  pClickedTrack = NULL;
560  }
561 
562  if (pClickedTrack && (refreshResult & RefreshCode::UpdateVRuler))
563  panel->UpdateVRuler(pClickedTrack);
564 
565  if (refreshResult & RefreshCode::DrawOverlays) {
566  panel->DrawOverlays(false);
567  mRuler->DrawOverlays(false);
568  }
569 
570  // Refresh all if told to do so, or if told to refresh a track that
571  // is not known.
572  const bool refreshAll =
573  ( (refreshResult & RefreshAll)
574  || ((refreshResult & RefreshCell) && !pClickedTrack)
575  || ((refreshResult & RefreshLatestCell) && !pLatestTrack));
576 
577  if (refreshAll)
578  panel->Refresh(false);
579  else {
580  if (refreshResult & RefreshCell)
581  panel->RefreshTrack(pClickedTrack);
582  if (refreshResult & RefreshLatestCell)
583  panel->RefreshTrack(pLatestTrack);
584  }
585 
586  if (refreshResult & FixScrollbars)
587  panel->MakeParentRedrawScrollbars();
588 
589  if (refreshResult & Resize)
590  panel->GetListener()->TP_HandleResize();
591 
592  if ((refreshResult & RefreshCode::EnsureVisible) && pClickedTrack) {
593  TrackFocus::Get(*GetProject()).Set(pClickedTrack);
594  pClickedTrack->EnsureVisible();
595  }
596 }

References RefreshCode::DestroyedCell, RefreshCode::DrawOverlays, OverlayPanel::DrawOverlays(), RefreshCode::EnsureVisible, Track::EnsureVisible(), anonymous_namespace{TrackPanel.cpp}::FindTrack(), RefreshCode::FixScrollbars, TrackFocus::Get(), TrackList::Get(), GetProject(), GetTracks(), TrackList::Lock(), mRuler, RefreshCode::RefreshAll, RefreshCode::RefreshCell, RefreshCode::RefreshLatestCell, RefreshCode::Resize, TrackList::UpdatePendingTracks(), and RefreshCode::UpdateVRuler.

Here is the call graph for this function:

◆ Refresh()

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

This method overrides Refresh() of wxWindow so that the boolean play indicator 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

Definition at line 780 of file TrackPanel.cpp.

782 {
783  // Tell OnPaint() to refresh the backing bitmap.
784  //
785  // Originally I had the check within the OnPaint() routine and it
786  // was working fine. That was until I found that, even though a full
787  // refresh was requested, Windows only set the onscreen portion of a
788  // window as damaged.
789  //
790  // So, if any part of the trackpanel was off the screen, full refreshes
791  // didn't work and the display got corrupted.
792  if( !rect || ( *rect == GetRect() ) )
793  {
794  mRefreshBacking = true;
795  }
796  wxWindow::Refresh(eraseBackground, rect);
797 
799 }

References BasicUI::CallAfter(), CellularPanel::HandleCursorForPresentMouseState(), and mRefreshBacking.

Referenced by ProjectSelectionManager::AS_SetSelectionFormat(), OnEnsureVisible(), OnProjectSettingsChange(), SelectHandle::TimerHandler::OnTimer(), OnTimer(), OnTrackFocusChange(), OnUndoReset(), RefreshTrack(), anonymous_namespace{ToolsToolBar.cpp}::SetTool(), UpdatePrefs(), UpdateSelectionDisplay(), UpdateVRulerSize(), and VerticalScroll().

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

◆ RefreshTrack()

void TrackPanel::RefreshTrack ( Track trk,
bool  refreshbacking = true 
)

Definition at line 749 of file TrackPanel.cpp.

750 {
751  if (!trk)
752  return;
753 
754  trk = *GetTracks()->FindLeader(trk);
755  auto &view = TrackView::Get( *trk );
756  auto height =
759 
760  // subtract insets and shadows from the rectangle, but not border
761  // This matters because some separators do paint over the border
762  wxRect rect(kLeftInset,
763  -mViewInfo->vpos + view.GetY() + kTopInset,
764  GetRect().GetWidth() - kLeftInset - kRightInset - kShadowThickness,
765  height);
766 
767  if( refreshbacking )
768  {
769  mRefreshBacking = true;
770  }
771 
772  Refresh( false, &rect );
773 }

References TrackList::Channels(), TrackList::FindLeader(), TrackView::Get(), TrackView::GetTrackHeight(), GetTracks(), kLeftInset, kRightInset, kShadowThickness, kTopInset, mRefreshBacking, CellularPanel::mViewInfo, Refresh(), and ZoomInfo::vpos.

Referenced by MixerTrackCluster::HandleSliderGain(), MixerTrackCluster::HandleSliderPan(), MixerTrackCluster::OnButton_Mute(), anonymous_namespace{TrackMenus.cpp}::SetTrackGain(), and anonymous_namespace{TrackMenus.cpp}::SetTrackPan().

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

◆ Root()

std::shared_ptr< TrackPanelNode > TrackPanel::Root ( )
overrideprotectedvirtual

Implements CellularPanel.

Definition at line 1576 of file TrackPanel.cpp.

1577 {
1578  // Root and other subgroup objects are throwaways.
1579  // They might instead be cached to avoid repeated allocation.
1580  // That cache would need invalidation when there is addition, deletion, or
1581  // permutation of tracks, or change of width of the vertical rulers.
1582  return std::make_shared< MainGroup >( *this );
1583 }

◆ SetBackgroundCell()

void TrackPanel::SetBackgroundCell ( const std::shared_ptr< TrackPanelCell > &  pCell)

Definition at line 852 of file TrackPanel.cpp.

854 {
855  mpBackground = pCell;
856 }

References mpBackground.

◆ SetFocusedCell()

void TrackPanel::SetFocusedCell ( )
overridevirtual

Implements CellularPanel.

Definition at line 1608 of file TrackPanel.cpp.

1609 {
1610  // This may have a side-effect of assigning a focus if there was none
1611  auto& trackFocus = TrackFocus::Get(*GetProject());
1612  trackFocus.Set(trackFocus.Get());
1614 }

References KeyboardCapture::Capture(), TrackFocus::Get(), and GetProject().

Here is the call graph for this function:

◆ UpdatePrefs()

void TrackPanel::UpdatePrefs ( )
overridevirtual

Implements PrefsListener.

Definition at line 332 of file TrackPanel.cpp.

333 {
334  // All vertical rulers must be recalculated since the minimum and maximum
335  // frequencies may have been changed.
336  UpdateVRulers();
337 
338  Refresh();
339 }

References Refresh(), and UpdateVRulers().

Referenced by TrackPanel().

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

◆ UpdateSelectionDisplay()

void TrackPanel::UpdateSelectionDisplay ( )
protected

Definition at line 623 of file TrackPanel.cpp.

624 {
625  // Full refresh since the label area may need to indicate
626  // newly selected tracks.
627  Refresh(false);
628 
629  // Make sure the ruler follows suit.
631 }

References AdornedRulerPanel::DrawSelection(), mRuler, and Refresh().

Referenced by OnTimer().

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

◆ UpdateStatusMessage()

void TrackPanel::UpdateStatusMessage ( const TranslatableString status)
overrideprotectedvirtual

Implements CellularPanel.

Definition at line 614 of file TrackPanel.cpp.

615 {
616  auto status = st;
617  if (HasEscape())
618  /* i18n-hint Esc is a key on the keyboard */
619  status.Join( XO("(Esc to cancel)"), " " );
620  ProjectStatus::Get( *GetProject() ).Set( status );
621 }

References ProjectStatus::Get(), GetProject(), CellularPanel::HasEscape(), TranslatableString::Join(), ProjectStatus::Set(), and XO.

Here is the call graph for this function:

◆ UpdateTrackVRuler()

void TrackPanel::UpdateTrackVRuler ( Track t)

Definition at line 879 of file TrackPanel.cpp.

880 {
881  wxASSERT(t);
882  if (!t)
883  return;
884 
885  wxRect rect(mViewInfo->GetVRulerOffset(),
886  0,
888  0);
889 
890 
891  for (auto channel : TrackList::Channels(t)) {
892  auto &view = TrackView::Get( *channel );
893  const auto height = view.GetHeight() - (kTopMargin + kBottomMargin);
894  rect.SetHeight( height );
895  const auto subViews = view.GetSubViews( rect );
896  if (subViews.empty())
897  continue;
898 
899  auto iter = subViews.begin(), end = subViews.end(), next = iter;
900  auto yy = iter->first;
901  wxSize vRulerSize{ 0, 0 };
902  for ( ; iter != end; iter = next ) {
903  ++next;
904  auto nextY = ( next == end )
905  ? height
906  : next->first;
907  rect.SetHeight( nextY - yy );
908  // This causes ruler size in the track to be reassigned:
909  TrackVRulerControls::Get( *iter->second ).UpdateRuler( rect );
910  // But we want to know the maximum width and height over all sub-views:
911  vRulerSize.IncTo( t->vrulerSize );
912  yy = nextY;
913  }
914  t->vrulerSize = vRulerSize;
915  }
916 }

References TrackList::Channels(), TrackView::Get(), TrackVRulerControls::Get(), ZoomInfo::GetVRulerOffset(), ZoomInfo::GetVRulerWidth(), kBottomMargin, kTopMargin, CellularPanel::mViewInfo, TrackVRulerControls::UpdateRuler(), and Track::vrulerSize.

Referenced by UpdateVRuler(), and UpdateVRulers().

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

◆ UpdateViewIfNoTracks()

void TrackPanel::UpdateViewIfNoTracks ( )

Definition at line 639 of file TrackPanel.cpp.

640 {
641  if (mTracks->empty())
642  {
643  // BG: There are no more tracks on screen
644  //BG: Set zoom to normal
646 
647  //STM: Set selection to 0,0
648  //PRL: and default the rest of the selection information
650 
651  // PRL: Following causes the time ruler to align 0 with left edge.
652  // Bug 972
653  mViewInfo->h = 0;
654 
656  //STM: Clear message if all tracks are removed
658  }
659 }

References ProjectStatus::Get(), ZoomInfo::GetDefaultZoom(), GetProject(), ZoomInfo::h, mListener, mTracks, CellularPanel::mViewInfo, ViewInfo::selectedRegion, ProjectStatus::Set(), ZoomInfo::SetZoom(), and TrackPanelListener::TP_HandleResize().

Here is the call graph for this function:

◆ UpdateVRuler()

void TrackPanel::UpdateVRuler ( Track t)

Definition at line 871 of file TrackPanel.cpp.

872 {
873  if (t)
875 
877 }

References UpdateTrackVRuler(), and UpdateVRulerSize().

Referenced by OnTrackListResizing().

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

◆ UpdateVRulers()

void TrackPanel::UpdateVRulers ( )

Definition at line 863 of file TrackPanel.cpp.

864 {
865  for (auto t : GetTracks()->Any< WaveTrack >())
867 
869 }

References GetTracks(), UpdateTrackVRuler(), and UpdateVRulerSize().

Referenced by UpdatePrefs().

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

◆ UpdateVRulerSize()

void TrackPanel::UpdateVRulerSize ( )

Definition at line 918 of file TrackPanel.cpp.

919 {
920  auto trackRange = GetTracks()->Any();
921  if (trackRange) {
922  wxSize s { 0, 0 };
923  for (auto t : trackRange)
924  s.IncTo(t->vrulerSize);
925 
926  if (mViewInfo->GetVRulerWidth() != s.GetWidth()) {
927  mViewInfo->SetVRulerWidth( s.GetWidth() );
929  mViewInfo->GetLeftOffset()); // bevel on AdornedRuler
930  mRuler->Refresh();
931  }
932  }
933  Refresh(false);
934 }

References TrackList::Any(), ZoomInfo::GetLeftOffset(), GetTracks(), ZoomInfo::GetVRulerWidth(), mRuler, CellularPanel::mViewInfo, AdornedRulerPanel::Refresh(), Refresh(), AdornedRulerPanel::SetLeftOffset(), and ZoomInfo::SetVRulerWidth().

Referenced by OnTrackListDeletion(), UpdateVRuler(), and UpdateVRulers().

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

◆ VerticalScroll()

void TrackPanel::VerticalScroll ( float  fracPosition)

Definition at line 988 of file TrackPanel.cpp.

988  {
989 
990  int trackTop = 0;
991  int trackHeight = 0;
992 
993  auto tracks = GetTracks();
994 
995  auto range = tracks->Leaders();
996  if (!range.empty()) {
997  trackHeight = TrackView::GetChannelGroupHeight( *range.rbegin() );
998  --range.second;
999  }
1000  trackTop = range.sum( TrackView::GetChannelGroupHeight );
1001 
1002  int delta;
1003 
1004  //Get the size of the trackpanel.
1005  int width, height;
1006  GetSize(&width, &height);
1007 
1008  delta = (fracPosition * (trackTop + trackHeight - height)) - mViewInfo->vpos + mViewInfo->scrollStep;
1009  //wxLogDebug( "Scroll down by %i pixels", delta );
1010  delta /= mViewInfo->scrollStep;
1011  mListener->TP_ScrollUpDown(delta);
1012  Refresh(false);
1013 }

References TrackView::GetChannelGroupHeight(), GetTracks(), mListener, CellularPanel::mViewInfo, Refresh(), ViewInfo::scrollStep, TrackPanelListener::TP_ScrollUpDown(), and ZoomInfo::vpos.

Here is the call graph for this function:

Member Data Documentation

◆ mLastDrawnSelectedRegion

SelectedRegion TrackPanel::mLastDrawnSelectedRegion {}
protected

Definition at line 200 of file TrackPanel.h.

Referenced by OnPaint(), and OnTimer().

◆ mListener

TrackPanelListener* TrackPanel::mListener
protected

◆ mpBackground

std::shared_ptr<TrackPanelCell> TrackPanel::mpBackground
protected

Definition at line 204 of file TrackPanel.h.

Referenced by GetBackgroundCell(), and SetBackgroundCell().

◆ mRefreshBacking

bool TrackPanel::mRefreshBacking
protected

Definition at line 195 of file TrackPanel.h.

Referenced by OnPaint(), OnTimer(), Refresh(), and RefreshTrack().

◆ mRuler

AdornedRulerPanel* TrackPanel::mRuler
protected

◆ mTimeCount

int TrackPanel::mTimeCount
protected

Definition at line 193 of file TrackPanel.h.

Referenced by OnTimer(), and TrackPanel().

◆ mTimer

TrackPanel::AudacityTimer TrackPanel::mTimer
protected

Referenced by OnIdle(), OnMouseEvent(), and TrackPanel().

◆ mTrackArtist

std::unique_ptr<TrackArtist> TrackPanel::mTrackArtist
protected

Definition at line 175 of file TrackPanel.h.

Referenced by DrawTracks(), and TrackPanel().

◆ mTracks

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

Definition at line 171 of file TrackPanel.h.

Referenced by TrackPanel(), and UpdateViewIfNoTracks().


The documentation for this class was generated from the following files:
ZoomInfo::vpos
int vpos
Definition: ZoomInfo.h:58
TrackPanel::OnTrackListResizing
void OnTrackListResizing(TrackListEvent &event)
Definition: TrackPanel.cpp:663
ProjectHistory::ModifyState
void ModifyState(bool bWantsAutoSave)
Definition: ProjectHistory.cpp:124
kLeftInset
@ kLeftInset
Definition: ZoomInfo.h:31
RefreshCode::DrawOverlays
@ DrawOverlays
Definition: RefreshCode.h:32
RefreshCode::FixScrollbars
@ FixScrollbars
Definition: RefreshCode.h:27
TrackPanel::GetTracks
const TrackList * GetTracks() const
Definition: TrackPanel.h:150
TrackPanel::UpdateVRulerSize
void UpdateVRulerSize()
Definition: TrackPanel.cpp:918
kBottomMargin
@ kBottomMargin
Definition: ViewInfo.h:107
AdornedRulerPanel::Refresh
void Refresh(bool eraseBackground=true, const wxRect *rect=(const wxRect *) NULL) override
Definition: AdornedRulerPanel.cpp:963
TrackPanel::DrawTracks
void DrawTracks(wxDC *dc)
Definition: TrackPanel.cpp:813
CellularPanel::HandleCursorForPresentMouseState
void HandleCursorForPresentMouseState(bool doHit=true)
Definition: CellularPanel.cpp:231
PlayableTrack::GetSolo
bool GetSolo() const
Definition: Track.h:845
ProjectAudioManager::Get
static ProjectAudioManager & Get(AudacityProject &project)
Definition: ProjectAudioManager.cpp:50
TrackPanelListener::TP_RedrawScrollbars
virtual void TP_RedrawScrollbars()=0
ToolCodes::drawTool
@ drawTool
Definition: ProjectSettings.h:38
RefreshCode::RefreshAll
@ RefreshAll
Definition: RefreshCode.h:26
ZoomInfo::GetVRulerOffset
int GetVRulerOffset() const
Definition: ZoomInfo.h:100
TrackArtist::NPasses
@ NPasses
Definition: TrackArtist.h:84
TrackView::Get
static TrackView & Get(Track &)
Definition: TrackView.cpp:63
TrackPanel::UpdateVRuler
void UpdateVRuler(Track *t)
Definition: TrackPanel.cpp:871
BackedPanel::DisplayBitmap
void DisplayBitmap(wxDC &dc)
Definition: BackedPanel.cpp:65
BackedPanel::RepairBitmap
void RepairBitmap(wxDC &dc, wxCoord x, wxCoord y, wxCoord width, wxCoord height)
Definition: BackedPanel.cpp:60
TrackFocus
Definition: TrackPanelAx.h:161
TrackList::Lock
std::shared_ptr< Subclass > Lock(const std::weak_ptr< Subclass > &wTrack)
Definition: Track.h:1524
ZoomInfo::GetDefaultZoom
static double GetDefaultZoom()
Definition: ZoomInfo.h:121
TrackPanel::OnIdle
void OnIdle(wxIdleEvent &event)
Definition: TrackPanel.cpp:371
Track::EnsureVisible
void EnsureVisible(bool modifyState=false)
Definition: Track.cpp:101
wxPanelWrapper::SetLabel
void SetLabel(const TranslatableString &label)
Definition: wxPanelWrapper.cpp:46
TrackPanelListener::TP_ScrollWindow
virtual void TP_ScrollWindow(double scrollto)=0
CellularPanel::mViewInfo
ViewInfo * mViewInfo
Definition: CellularPanel.h:161
ClientData::Site::Get
Subclass & Get(const RegisteredFactory &key)
Get reference to an attachment, creating on demand if not present, down-cast it to Subclass.
Definition: ClientData.h:309
TrackPanelDrawingContext
Definition: TrackPanelDrawingContext.h:22
TrackList::Channels
static auto Channels(TrackType *pTrack) -> TrackIterRange< TrackType >
Definition: Track.h:1468
kShadowThickness
@ kShadowThickness
Definition: ZoomInfo.h:29
TrackPanel::Get
static TrackPanel & Get(AudacityProject &project)
Definition: TrackPanel.cpp:221
TrackView::GetTrackHeight
static int GetTrackHeight(const Track *pTrack)
Definition: TrackView.cpp:29
XO
#define XO(s)
Definition: Internat.h:31
ProjectSettings::Get
static ProjectSettings & Get(AudacityProject &project)
Definition: ProjectSettings.cpp:40
TrackPanel::AudacityTimer::parent
TrackPanel * parent
Definition: TrackPanel.h:190
ZoomInfo::SetVRulerWidth
void SetVRulerWidth(int width)
Definition: ZoomInfo.h:99
kRightInset
@ kRightInset
Definition: ZoomInfo.h:32
ProjectWindow::Get
static ProjectWindow & Get(AudacityProject &project)
Definition: ProjectWindow.cpp:533
ZoomInfo::GetVRulerWidth
int GetVRulerWidth() const
Definition: ZoomInfo.h:98
CellularPanel::FindRect
wxRect FindRect(const TrackPanelCell &cell)
Definition: CellularPanel.cpp:1068
BasicUI::CallAfter
void CallAfter(Action action)
Schedule an action to be done later, and in the main thread.
Definition: BasicUI.cpp:38
ProjectAudioIO::Get
static ProjectAudioIO & Get(AudacityProject &project)
Definition: ProjectAudioIO.cpp:23
anonymous_namespace{TimeTrackVRulerControls.cpp}::ruler
Ruler & ruler()
Definition: TimeTrackVRulerControls.cpp:34
kTopMargin
@ kTopMargin
Definition: ViewInfo.h:106
TrackPanel
The TrackPanel class coordinates updates and operations on the main part of the screen which contains...
Definition: TrackPanel.h:64
TrackList::SelectedLeaders
auto SelectedLeaders() -> TrackIterRange< TrackType >
Definition: Track.h:1406
RefreshCode::EnsureVisible
@ EnsureVisible
Definition: RefreshCode.h:31
ProjectAudioIO::IsAudioActive
bool IsAudioActive() const
Definition: ProjectAudioIO.cpp:52
TrackPanelListener::TP_ScrollUpDown
virtual bool TP_ScrollUpDown(int delta)=0
CellularPanel::CellularPanel
CellularPanel(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, ViewInfo *viewInfo, long style=wxTAB_TRAVERSAL|wxNO_BORDER)
Definition: CellularPanel.cpp:108
TrackPanel::GetProject
AudacityProject * GetProject() const override
Definition: TrackPanel.cpp:343
ZoomInfo::GetLeftOffset
int GetLeftOffset() const
Definition: ZoomInfo.h:102
TrackPanel::mpBackground
std::shared_ptr< TrackPanelCell > mpBackground
Definition: TrackPanel.h:204
TrackPanel::UpdatePrefs
void UpdatePrefs() override
Definition: TrackPanel.cpp:332
ViewInfo::scrollStep
int scrollStep
Definition: ViewInfo.h:218
TrackPanel::UpdateSelectionDisplay
void UpdateSelectionDisplay()
Definition: TrackPanel.cpp:623
TrackPanel::OnTrackListDeletion
void OnTrackListDeletion(wxEvent &event)
Definition: TrackPanel.cpp:677
ProjectSettings::EventCode
EventCode
Definition: ProjectSettings.h:60
TrackPanel::GetFocusedCell
TrackPanelCell * GetFocusedCell() override
Definition: TrackPanel.cpp:1602
BackedPanel::GetBackingDCForRepaint
wxDC & GetBackingDCForRepaint()
Definition: BackedPanel.cpp:35
ProjectSettings::ChangedSyncLock
@ ChangedSyncLock
Definition: ProjectSettings.h:61
TrackPanelNode
The TrackPanel is built up of nodes, subtrees of the CellularPanel's area Common base class for Track...
Definition: TrackPanelCell.h:39
TrackList::FindLeader
TrackIter< Track > FindLeader(Track *pTrack)
Definition: Track.cpp:648
ProjectStatus::Set
void Set(const TranslatableString &msg, StatusBarField field=mainStatusBarField)
Definition: ProjectStatus.cpp:65
Track::SubstitutePendingChangedTrack
std::shared_ptr< Track > SubstitutePendingChangedTrack()
Definition: Track.cpp:1186
ViewInfo::selectedRegion
NotifyingSelectedRegion selectedRegion
Definition: ViewInfo.h:200
CellularPanel::MostRecentXCoord
wxCoord MostRecentXCoord() const
Definition: CellularPanel.cpp:1106
TrackFocus::Get
static TrackFocus & Get(AudacityProject &project)
Definition: TrackPanelAx.cpp:736
TrackPanel::OnProjectSettingsChange
void OnProjectSettingsChange(wxCommandEvent &event)
Definition: TrackPanel.cpp:447
ToolCodes::multiTool
@ multiTool
Definition: ProjectSettings.h:41
CellularPanel::HasEscape
bool HasEscape()
Definition: CellularPanel.cpp:420
ZoomInfo::SetZoom
void SetZoom(double pixelsPerSecond)
Definition: ZoomInfo.cpp:88
TrackPanel::mLastDrawnSelectedRegion
SelectedRegion mLastDrawnSelectedRegion
Definition: TrackPanel.h:200
kTopInset
@ kTopInset
Definition: ViewInfo.h:105
TrackPanelListener::TP_HandleResize
virtual void TP_HandleResize()=0
ProjectWindow
A top-level window associated with a project, and handling scrollbars and zooming.
Definition: ProjectWindow.h:32
GetProjectFrame
AUDACITY_DLL_API wxFrame & GetProjectFrame(AudacityProject &project)
Get the top-level window associated with the project (as a wxFrame only, when you do not need to use ...
Definition: Project.cpp:188
AdornedRulerPanel::DrawSelection
void DrawSelection()
Definition: AdornedRulerPanel.cpp:2082
KeyboardCapture::Capture
void Capture(wxWindow *handler)
Definition: KeyboardCapture.cpp:70
TrackVRulerControls::Get
static TrackVRulerControls & Get(TrackView &)
Definition: TrackVRulerControls.cpp:36
RefreshCode::Resize
@ Resize
Definition: RefreshCode.h:28
@0::kTimerInterval
@ kTimerInterval
ZoomInfo::GetScreenEndTime
double GetScreenEndTime() const
Definition: ZoomInfo.h:112
AdornedRulerPanel::SetLeftOffset
void SetLeftOffset(int offset)
Definition: AdornedRulerPanel.cpp:2109
CellularPanel::Target
UIHandlePtr Target()
Definition: CellularPanel.cpp:1097
TrackFocus::Get
Track * Get()
Definition: TrackPanelAx.cpp:755
RefreshCode::UpdateVRuler
@ UpdateVRuler
Definition: RefreshCode.h:30
TrackPanel::mTimer
TrackPanel::AudacityTimer mTimer
RefreshCode::RefreshCell
@ RefreshCell
Definition: RefreshCode.h:24
TrackPanel::mRuler
AdornedRulerPanel * mRuler
Definition: TrackPanel.h:173
anonymous_namespace{TrackPanel.cpp}::FindTrack
std::shared_ptr< Track > FindTrack(TrackPanelCell *pCell)
Definition: TrackPanel.cpp:524
TrackVRulerControls::UpdateRuler
virtual void UpdateRuler(const wxRect &rect)=0
PlayableTrack
AudioTrack subclass that can also be audibly replayed by the program.
Definition: Track.h:838
RefreshCode::RefreshLatestCell
@ RefreshLatestCell
Definition: RefreshCode.h:25
TrackPanel::HandlePageUpKey
void HandlePageUpKey()
Definition: TrackPanel.cpp:598
TrackList::UpdatePendingTracks
void UpdatePendingTracks()
Definition: Track.cpp:1060
CellularPanel::Draw
void Draw(TrackPanelDrawingContext &context, unsigned nPasses)
Definition: CellularPanel.cpp:1129
RefreshCode::DestroyedCell
@ DestroyedCell
Definition: RefreshCode.h:34
anonymous_namespace{TrackPanel.cpp}::sKey
AudacityProject::AttachedWindows::RegisteredFactory sKey
Definition: TrackPanel.cpp:197
TrackPanel::mListener
TrackPanelListener * mListener
Definition: TrackPanel.h:169
TrackPanel::UpdateVRulers
void UpdateVRulers()
Definition: TrackPanel.cpp:863
wxPanelWrapper::SetName
void SetName()
Definition: wxPanelWrapper.cpp:61
TrackList::Get
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:495
Track
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:239
ToolCodes::envelopeTool
@ envelopeTool
Definition: ProjectSettings.h:37
ProjectStatus::Get
static ProjectStatus & Get(AudacityProject &project)
Definition: ProjectStatus.cpp:23
TrackPanel::Refresh
void Refresh(bool eraseBackground=true, const wxRect *rect=(const wxRect *) NULL) override
Definition: TrackPanel.cpp:780
AudacityProject
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:113
TrackPanel::mRefreshBacking
bool mRefreshBacking
Definition: TrackPanel.h:195
TrackPanel::mTrackArtist
std::unique_ptr< TrackArtist > mTrackArtist
Definition: TrackPanel.h:175
CellularPanel::mLastMouseState
wxMouseState mLastMouseState
Definition: CellularPanel.h:164
ViewInfo::SetHeight
void SetHeight(int height)
Definition: ViewInfo.h:183
TrackPanel::OnAudioIO
void OnAudioIO(wxCommandEvent &evt)
Definition: TrackPanel.cpp:801
TrackPanel::OnEnsureVisible
void OnEnsureVisible(TrackListEvent &event)
Definition: TrackPanel.cpp:942
OverlayPanel::DrawOverlays
void DrawOverlays(bool repaint_all, wxDC *pDC=nullptr)
Definition: OverlayPanel.cpp:43
TrackPanel::OnTrackFocusChange
void OnTrackFocusChange(wxCommandEvent &event)
Definition: TrackPanel.cpp:1616
CellularPanel::DoContextMenu
void DoContextMenu(TrackPanelCell *pCell=nullptr)
Definition: CellularPanel.cpp:876
ZoomInfo::GetLabelWidth
int GetLabelWidth() const
Definition: ZoomInfo.h:101
TrackView::GetChannelGroupHeight
static int GetChannelGroupHeight(const Track *pTrack)
Definition: TrackView.cpp:34
TrackPanel::mTracks
std::shared_ptr< TrackList > mTracks
Definition: TrackPanel.h:171
TrackList::Any
auto Any() -> TrackIterRange< TrackType >
Definition: Track.h:1355
TranslatableString::Join
TranslatableString & Join(TranslatableString arg, const wxString &separator={}) &
Append another translatable string.
Definition: TranslatableString.cpp:124
TrackPanel::OnUndoReset
void OnUndoReset(wxCommandEvent &event)
Definition: TrackPanel.cpp:459
AudioIO::Get
static AudioIO * Get()
Definition: AudioIO.cpp:505
settings
static Settings & settings()
Definition: TrackInfo.cpp:86
RefreshCode
Namespace containing an enum 'what to do on a refresh?'.
Definition: RefreshCode.h:16
TrackPanel::HandlePageDownKey
void HandlePageDownKey()
Definition: TrackPanel.cpp:603
CellularPanel::FindCell
FoundCell FindCell(int mouseX, int mouseY)
Definition: CellularPanel.cpp:1029
TrackPanel::mTimeCount
int mTimeCount
Definition: TrackPanel.h:193
ProjectHistory::Get
static ProjectHistory & Get(AudacityProject &project)
Definition: ProjectHistory.cpp:26
ZoomInfo::h
double h
Definition: ZoomInfo.h:60
TrackPanel::IsAudioActive
bool IsAudioActive()
Definition: TrackPanel.cpp:608
ZoomInfo::PositionToTime
double PositionToTime(wxInt64 position, wxInt64 origin=0, bool ignoreFisheye=false) const
Definition: ZoomInfo.cpp:43
TrackPanel::UpdateTrackVRuler
void UpdateTrackVRuler(Track *t)
Definition: TrackPanel.cpp:879
SelectedRegion
Defines a selected portion of a project.
Definition: SelectedRegion.h:38
ZoomInfo::SetWidth
void SetWidth(int width)
Definition: ZoomInfo.h:96
Track::vrulerSize
wxSize vrulerSize
Definition: Track.h:343