Audacity 3.2.0
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 (AudioIOEvent)
 
void OnPaint (wxPaintEvent &event)
 
void OnMouseEvent (wxMouseEvent &event)
 
void OnKeyDown (wxKeyEvent &event)
 
void OnTrackListResizing (const TrackListEvent &event)
 
void OnTrackListDeletion ()
 
void OnEnsureVisible (const 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 OnSyncLockChange (struct SyncLockChangeMessage)
 
void OnTrackFocusChange (struct TrackFocusChangeMessage)
 
void OnUndoReset (struct UndoRedoMessage)
 
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)
 
wxRect FindFocusedTrackRect (const Track *target)
 
std::vector< wxRect > FindRulerRects (const Track *target)
 
const TrackListGetTracks () const
 
TrackListGetTracks ()
 
ViewInfoGetViewInfo ()
 
TrackPanelListenerGetListener ()
 
AdornedRulerPanelGetRuler ()
 
void SetBackgroundCell (const std::shared_ptr< CommonTrackPanelCell > &pCell)
 
std::shared_ptr< CommonTrackPanelCellGetBackgroundCell ()
 
- 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
 
virtual AudacityProjectGetProject () const =0
 
virtual std::shared_ptr< TrackPanelNodeRoot ()=0
 
virtual TrackPanelCellGetFocusedCell ()=0
 
virtual void SetFocusedCell ()=0
 
virtual void ProcessUIHandleResult (TrackPanelCell *pClickedCell, TrackPanelCell *pLatestCell, unsigned refreshResult)=0
 
virtual void UpdateStatusMessage (const TranslatableString &)=0
 
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

Observer::Subscription mTrackListSubscription
 
Observer::Subscription mAudioIOSubscription
 
Observer::Subscription mUndoSubscription
 
Observer::Subscription mFocusChangeSubscription
 
Observer::Subscription mRealtimeEffectManagerSubscription
 
Observer::Subscription mSyncLockSubscription
 
TrackPanelListenermListener
 
std::shared_ptr< TrackListmTracks
 
AdornedRulerPanelmRuler
 
std::unique_ptr< TrackArtistmTrackArtist
 
TrackPanel::AudacityTimer mTimer
 
int mTimeCount
 
bool mRefreshBacking
 
SelectedRegion mLastDrawnSelectedRegion {}
 
std::shared_ptr< CommonTrackPanelCellmpBackground
 
- 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 UpdatePrefs ()=0
 
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, "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.

GetLeftOffset() counts columns up to and including the VRuler and one more, 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 61 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 254 of file TrackPanel.cpp.

261 : CellularPanel(parent, id, pos, size, viewInfo,
262 wxWANTS_CHARS | wxNO_BORDER),
263 mListener( &ProjectWindow::Get( *project ) ),
264 mTracks(tracks),
265 mRuler(ruler),
266 mTrackArtist(nullptr),
267 mRefreshBacking(false)
268#ifndef __WXGTK__ //Get rid if this pragma for gtk
269#pragma warning( default: 4355 )
270#endif
271{
272 SetLayoutDirection(wxLayout_LeftToRight);
273 SetLabel(XO("Track Panel"));
274 SetName(XO("Track Panel"));
275 SetBackgroundStyle(wxBG_STYLE_PAINT);
276
277 {
278 auto pAx = std::make_unique <TrackPanelAx>( *project );
279 pAx->SetWindow( this );
280 wxWeakRef< TrackPanel > weakThis{ this };
281 pAx->SetFinder(
282 [weakThis]( const Track &track ) -> wxRect {
283 if (weakThis)
284 return weakThis->FindTrackRect( &track );
285 return {};
286 }
287 );
288 TrackFocus::Get( *GetProject() ).SetAccessible(
289 *this, std::move( pAx ) );
290 }
291
292 mTrackArtist = std::make_unique<TrackArtist>( this );
293
294 mTimeCount = 0;
295 mTimer.parent = this;
296 // Timer is started after the window is visible
297 ProjectWindow::Get( *GetProject() ).Bind(wxEVT_IDLE,
298 &TrackPanel::OnIdle, this);
299
300 // Register for tracklist updates
302 mTracks->Subscribe([this](const TrackListEvent &event){
303 switch (event.mType) {
304 case TrackListEvent::RESIZING:
305 case TrackListEvent::ADDITION:
306 OnTrackListResizing(event); break;
307 case TrackListEvent::DELETION:
308 OnTrackListDeletion(); break;
309 case TrackListEvent::TRACK_REQUEST_VISIBLE:
310 OnEnsureVisible(event); break;
311 default:
312 break;
313 }
314 });
315
316 auto theProject = GetProject();
319
321 .Subscribe(*this, &TrackPanel::OnTrackFocusChange);
322
325
328
330 .Subscribe([this](const RealtimeEffectManagerMessage& msg)
331 {
332 if(msg.track)
333 //update "effects" button
334 RefreshTrack(msg.track.get());
335 });
336
337 UpdatePrefs();
338}
XO("Cut/Copy/Paste")
static AudioIO * Get()
Definition: AudioIO.cpp:147
CellularPanel(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, ViewInfo *viewInfo, long style=wxTAB_TRAVERSAL|wxNO_BORDER)
Subscription Subscribe(Callback callback)
Connect a callback to the Publisher; later-connected are called earlier.
Definition: Observer.h:199
static ProjectWindow & Get(AudacityProject &project)
static RealtimeEffectManager & Get(AudacityProject &project)
static SyncLockState & Get(AudacityProject &project)
Definition: SyncLock.cpp:26
Track * Get()
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:226
void UpdatePrefs() override
Definition: TrackPanel.cpp:351
AdornedRulerPanel * mRuler
Definition: TrackPanel.h:199
TrackPanelListener * mListener
Definition: TrackPanel.h:195
std::shared_ptr< TrackList > mTracks
Definition: TrackPanel.h:197
Observer::Subscription mAudioIOSubscription
Definition: TrackPanel.h:189
AudacityProject * GetProject() const override
Definition: TrackPanel.cpp:362
Observer::Subscription mTrackListSubscription
Definition: TrackPanel.h:188
void OnTrackFocusChange(struct TrackFocusChangeMessage)
Observer::Subscription mRealtimeEffectManagerSubscription
Definition: TrackPanel.h:192
Observer::Subscription mSyncLockSubscription
Definition: TrackPanel.h:193
bool mRefreshBacking
Definition: TrackPanel.h:221
TrackPanel::AudacityTimer mTimer
void OnUndoReset(struct UndoRedoMessage)
Definition: TrackPanel.cpp:462
Observer::Subscription mUndoSubscription
Definition: TrackPanel.h:190
int mTimeCount
Definition: TrackPanel.h:219
void OnAudioIO(AudioIOEvent)
Definition: TrackPanel.cpp:802
void OnSyncLockChange(struct SyncLockChangeMessage)
Definition: TrackPanel.cpp:457
void OnIdle(wxIdleEvent &event)
Definition: TrackPanel.cpp:384
Observer::Subscription mFocusChangeSubscription
Definition: TrackPanel.h:191
void RefreshTrack(Track *trk, bool refreshbacking=true)
Definition: TrackPanel.cpp:743
std::unique_ptr< TrackArtist > mTrackArtist
Definition: TrackPanel.h:201
static UndoManager & Get(AudacityProject &project)
Definition: UndoManager.cpp:71
void SetLabel(const TranslatableString &label)
Posted when effect is being added or removed to/from track or project.
std::shared_ptr< Track > track
null, if changes happened in the project scope
Notification of changes in individual tracks of TrackList, or of TrackList's composition.
Definition: Track.h:1289
const Type mType
Definition: Track.h:1326

References AudioIO::Get(), TrackFocus::Get(), UndoManager::Get(), RealtimeEffectManager::Get(), SyncLockState::Get(), ProjectWindow::Get(), GetProject(), mAudioIOSubscription, mFocusChangeSubscription, mRealtimeEffectManagerSubscription, mSyncLockSubscription, mTimeCount, mTimer, mTrackArtist, mTrackListSubscription, mTracks, TrackListEvent::mType, mUndoSubscription, OnAudioIO(), OnIdle(), OnSyncLockChange(), OnTrackFocusChange(), OnUndoReset(), TrackPanel::AudacityTimer::parent, RefreshTrack(), wxPanelWrapper::SetLabel(), wxPanelWrapper::SetName(), Observer::Publisher< Message, NotifyAll >::Subscribe(), RealtimeEffectManagerMessage::track, UpdatePrefs(), and XO().

Here is the call graph for this function:

◆ ~TrackPanel()

TrackPanel::~TrackPanel ( )
virtual

Definition at line 341 of file TrackPanel.cpp.

342{
343 mTimer.Stop();
344
345 // This can happen if a label is being edited and the user presses
346 // ALT+F4 or Command+Q
347 if (HasCapture())
348 ReleaseMouse();
349}

References mTimer.

Member Function Documentation

◆ Destroy()

void TrackPanel::Destroy ( AudacityProject project)
static

Definition at line 241 of file TrackPanel.cpp.

242{
243 auto *pPanel = GetAttachedWindows(project).Find<TrackPanel>( sKey );
244 if (pPanel) {
245 pPanel->wxWindow::Destroy();
246 GetAttachedWindows(project).Assign(sKey, nullptr);
247 }
248}
AUDACITY_DLL_API AttachedWindows & GetAttachedWindows(AudacityProject &project)
Subclass * Find(const RegisteredFactory &key)
Get a (bare) pointer to an attachment, or null, down-cast it to Subclass *; will not create on demand...
Definition: ClientData.h:333
void Assign(const RegisteredFactory &key, ReplacementPointer &&replacement)
Reassign Site's pointer to ClientData.
Definition: ClientData.h:355
The TrackPanel class coordinates updates and operations on the main part of the screen which contains...
Definition: TrackPanel.h:65
AttachedWindows::RegisteredFactory sKey
Definition: TrackPanel.cpp:207

References ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >::Assign(), ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >::Find(), GetAttachedWindows(), and anonymous_namespace{TrackPanel.cpp}::sKey.

Referenced by ProjectManager::OnCloseWindow().

Here is the call graph for this function:
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 815 of file TrackPanel.cpp.

816{
817 wxRegion region = GetUpdateRegion();
818
819 const wxRect clip = GetRect();
820
822 mTrackArtist->pSelectedRegion = &sr;
823 mTrackArtist->pZoomInfo = mViewInfo;
825 *dc, Target(), mLastMouseState, mTrackArtist.get()
826 };
827
828 // Don't draw a bottom margin here.
829
830 const auto &settings = ProjectSettings::Get( *GetProject() );
831 bool bMultiToolDown =
832 (ToolCodes::multiTool == settings.GetTool());
833 bool envelopeFlag =
834 bMultiToolDown || (ToolCodes::envelopeTool == settings.GetTool());
835 bool bigPointsFlag =
836 bMultiToolDown || (ToolCodes::drawTool == settings.GetTool());
837 bool sliderFlag = bMultiToolDown;
838 bool brushFlag = false;
839#ifdef EXPERIMENTAL_BRUSH_TOOL
840 brushFlag = (ToolCodes::brushTool == settings.GetTool());
841#endif
842
843 const bool hasSolo = GetTracks()->Any< PlayableTrack >()
844 .any_of( []( const PlayableTrack *pt ) {
845 pt = static_cast< const PlayableTrack * >(
846 pt->SubstitutePendingChangedTrack().get() );
847 return (pt && pt->GetSolo());
848 } );
849
850 mTrackArtist->drawEnvelope = envelopeFlag;
851 mTrackArtist->bigPoints = bigPointsFlag;
852 mTrackArtist->drawSliders = sliderFlag;
853 mTrackArtist->onBrushTool = brushFlag;
854 mTrackArtist->hasSolo = hasSolo;
855
857}
static Settings & settings()
Definition: TrackInfo.cpp:87
void Draw(TrackPanelDrawingContext &context, unsigned nPasses)
UIHandlePtr Target()
ViewInfo * mViewInfo
wxMouseState mLastMouseState
AudioTrack subclass that can also be audibly replayed by the program.
Definition: Track.h:917
bool GetSolo() const
Definition: Track.h:925
static ProjectSettings & Get(AudacityProject &project)
Defines a selected portion of a project.
std::shared_ptr< Track > SubstitutePendingChangedTrack()
Definition: Track.cpp:1211
auto Any() -> TrackIterRange< TrackType >
Definition: Track.h:1440
const TrackList * GetTracks() const
Definition: TrackPanel.h:168
NotifyingSelectedRegion selectedRegion
Definition: ViewInfo.h:219

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:

◆ FindFocusedTrackRect()

wxRect TrackPanel::FindFocusedTrackRect ( const Track target)
Returns
includes what's in FindTrackRect(target) and the focus ring area around it. If target is nullptr, returns empty rectangle.

Definition at line 1663 of file TrackPanel.cpp.

1664{
1665 auto rect = FindTrackRect(target);
1666 if (rect != wxRect{}) {
1667 // Enlarge horizontally.
1668 // PRL: perhaps it's one pixel too much each side, including some gray
1669 // beyond the yellow?
1670 rect.x = 0;
1671 GetClientSize(&rect.width, nullptr);
1672
1673 // Enlarge vertically, enough to enclose the yellow focus border pixels
1674 // The the outermost ring of gray pixels is included on three sides
1675 // but not the top (should that be fixed?)
1676
1677 // (Note that TrackPanel paints its focus over the "top margin" of the
1678 // rectangle allotted to the track, according to TrackView::GetY() and
1679 // TrackView::GetHeight(), but also over the margin of the next track.)
1680
1681 rect.height += kBottomMargin;
1682 int dy = kTopMargin - 1;
1683 rect.Inflate( 0, dy );
1684
1685 // Note that this rectangle does not coincide with any one of
1686 // the nodes in the subdivision.
1687 }
1688 return rect;
1689}
@ kBottomMargin
@ kTopMargin
wxRect FindTrackRect(const Track *target)

References FindTrackRect(), kBottomMargin, and kTopMargin.

Referenced by ScreenshotCommand::GetTrackRect().

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

◆ FindRulerRects()

std::vector< wxRect > TrackPanel::FindRulerRects ( const Track target)
Returns
extents of the vertical rulers of one channel, top to bottom. (There may be multiple sub-views, each with a ruler.) If target is nullptr, returns an empty vector.

Definition at line 1691 of file TrackPanel.cpp.

1692{
1693 std::vector<wxRect> results;
1694 if (target)
1695 VisitCells( [&]( const wxRect &rect, TrackPanelCell &visited ) {
1696 if (auto pRuler = dynamic_cast<const TrackVRulerControls*>(&visited);
1697 pRuler && pRuler->FindTrack().get() == target)
1698 results.push_back(rect);
1699 } );
1700 return results;
1701}
void VisitCells(const SimpleCellVisitor &visitor)
std::shared_ptr< Track > FindTrack()

References CommonTrackPanelCell::FindTrack(), and CellularPanel::VisitCells().

Here is the call graph for this function:

◆ FindTrackRect()

wxRect TrackPanel::FindTrackRect ( const Track target)
Returns
includes track control panel, and the vertical ruler, and the proper track area of all channels, and the separators between them. If target is nullptr, returns empty rectangle.

Definition at line 1649 of file TrackPanel.cpp.

1650{
1651 auto leader = *GetTracks()->FindLeader( target );
1652 if (!leader) {
1653 return {};
1654 }
1655
1656 return CellularPanel::FindRect( [&] ( TrackPanelNode &node ) {
1657 if (auto pGroup = dynamic_cast<const LabeledChannelGroup*>( &node ))
1658 return pGroup->mpTrack.get() == leader;
1659 return false;
1660 } );
1661}
wxRect FindRect(const TrackPanelCell &cell)
TrackIter< Track > FindLeader(Track *pTrack)
Definition: Track.cpp:645
The TrackPanel is built up of nodes, subtrees of the CellularPanel's area Common base class for Track...

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

Referenced by FindFocusedTrackRect().

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 231 of file TrackPanel.cpp.

232{
233 return GetAttachedWindows(project).Get< TrackPanel >( sKey );
234}
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

References ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >::Get(), GetAttachedWindows(), and anonymous_namespace{TrackPanel.cpp}::sKey.

Referenced by ScreenshotCommand::Apply(), SelectTimeCommand::Apply(), SetTrackVisualsCommand::ApplyInner(), ProjectSelectionManager::AS_ModifySelection(), ProjectSelectionManager::AS_SetSelectionFormat(), BrushHandle::Click(), SelectHandle::Click(), WaveformPrefs::Commit(), MenuButtonHandle::CommitChanges(), LabelTrackView::DialogForLabelName(), anonymous_namespace{LabelMenus.cpp}::DoAddLabel(), EffectUI::DoEffect(), anonymous_namespace{TrackMenus.cpp}::DoMixAndRender(), TrackUtilities::DoRemoveTracks(), BrushHandle::Drag(), EditCursorOverlay::Draw(), DeviceToolBar::EnableDisableButtons(), GetInfoCommand::ExploreTrackPanel(), Get(), MixerTrackCluster::HandleSliderGain(), MixerTrackCluster::HandleSliderPan(), GainSliderHandle::HitTest(), PanSliderHandle::HitTest(), InitProjectWindow(), anonymous_namespace{SelectMenus.cpp}::MoveWhenAudioInactive(), anonymous_namespace{NavigationMenus.cpp}::NextOrPrevFrame(), MixerTrackCluster::OnButton_Mute(), anonymous_namespace{EditMenus.cpp}::OnCopy(), anonymous_namespace{EditMenus.cpp}::OnCut(), anonymous_namespace{WaveTrackAffordanceControls.cpp}::OnEditClipName(), anonymous_namespace{ToolsToolBar.cpp}::OnNextTool(), anonymous_namespace{EditMenus.cpp}::OnPaste(), anonymous_namespace{LabelMenus.cpp}::OnPasteNewLabel(), anonymous_namespace{TransportMenus.cpp}::OnPlayOneSecond(), anonymous_namespace{TransportMenus.cpp}::OnPlayToSelection(), anonymous_namespace{ToolsToolBar.cpp}::OnPrevTool(), anonymous_namespace{Printing.cpp}::OnPrint(), anonymous_namespace{EditMenus.cpp}::OnRedo(), SelectActions::Handler::OnSelectAll(), ViewActions::Handler::OnShowClipping(), ViewActions::Handler::OnShowNameOverlay(), anonymous_namespace{TrackMenus.cpp}::OnSyncLock(), SelectHandle::TimerHandler::OnTimer(), anonymous_namespace{TrackMenus.cpp}::OnTrackClose(), anonymous_namespace{TrackMenus.cpp}::OnTrackGain(), anonymous_namespace{TrackMenus.cpp}::OnTrackGainDec(), anonymous_namespace{TrackMenus.cpp}::OnTrackGainInc(), anonymous_namespace{TrackMenus.cpp}::OnTrackMenu(), anonymous_namespace{TrackMenus.cpp}::OnTrackMoveBottom(), anonymous_namespace{TrackMenus.cpp}::OnTrackMoveDown(), anonymous_namespace{TrackMenus.cpp}::OnTrackMoveTop(), anonymous_namespace{TrackMenus.cpp}::OnTrackMoveUp(), anonymous_namespace{TrackMenus.cpp}::OnTrackPan(), anonymous_namespace{TrackMenus.cpp}::OnTrackPanLeft(), anonymous_namespace{TrackMenus.cpp}::OnTrackPanRight(), anonymous_namespace{EditMenus.cpp}::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().

Here is the call graph for this function:

◆ Get() [2/2]

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

Definition at line 236 of file TrackPanel.cpp.

237{
238 return Get( const_cast< AudacityProject & >( project ) );
239}
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
static TrackPanel & Get(AudacityProject &project)
Definition: TrackPanel.cpp:231

References Get().

Here is the call graph for this function:

◆ GetBackgroundCell()

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

Definition at line 865 of file TrackPanel.cpp.

866{
867 return mpBackground;
868}
std::shared_ptr< CommonTrackPanelCell > mpBackground
Definition: TrackPanel.h:230

References mpBackground.

Referenced by GetFocusedCell().

Here is the caller graph for this function:

◆ GetFocusedCell()

TrackPanelCell * TrackPanel::GetFocusedCell ( )
overridevirtual

Implements CellularPanel.

Definition at line 1703 of file TrackPanel.cpp.

1704{
1705 auto pTrack = TrackFocus::Get( *GetProject() ).Get();
1706 return pTrack ? &TrackView::Get( *pTrack ) : GetBackgroundCell().get();
1707}
std::shared_ptr< CommonTrackPanelCell > GetBackgroundCell()
Definition: TrackPanel.cpp:865
static TrackView & Get(Track &)
Definition: TrackView.cpp:69

References TrackFocus::Get(), ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >::Get(), TrackView::Get(), GetBackgroundCell(), 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 171 of file TrackPanel.h.

171{ return mListener;}

◆ GetMostRecentXPos()

double TrackPanel::GetMostRecentXPos ( )

Definition at line 737 of file TrackPanel.cpp.

738{
741}
wxCoord MostRecentXCoord() const
double PositionToTime(int64 position, int64 origin=0, bool ignoreFisheye=false) const
Definition: ZoomInfo.cpp:35
int GetLeftOffset() const
Definition: ZoomInfo.h:93

References ZoomInfo::GetLeftOffset(), 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 362 of file TrackPanel.cpp.

363{
364 auto window = GetParent();
365
366 while(window != nullptr)
367 {
368 if(const auto projectWindow = dynamic_cast<ProjectWindow*>(window))
369 return projectWindow->FindProject().get();
370
371 window = window->GetParent();
372 }
373 return nullptr;
374}
A top-level window associated with a project, and handling scrollbars and zooming.
Definition: ProjectWindow.h:41

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 172 of file TrackPanel.h.

172{ 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 631 of file TrackPanel.cpp.

632{
633 return GetTracks()->SelectedLeaders().size();
634}
auto SelectedLeaders() -> TrackIterRange< TrackType >
Definition: Track.h:1491

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

Here is the call graph for this function:

◆ GetTracks() [1/2]

TrackList * TrackPanel::GetTracks ( )
inline

Definition at line 169 of file TrackPanel.h.

169{ return mTracks.get(); }

◆ GetTracks() [2/2]

const TrackList * TrackPanel::GetTracks ( ) const
inline

Definition at line 168 of file TrackPanel.h.

168{ 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 170 of file TrackPanel.h.

170{ return mViewInfo;}

References CellularPanel::mViewInfo.

◆ HandlePageDownKey()

void TrackPanel::HandlePageDownKey ( )

Definition at line 600 of file TrackPanel.cpp.

601{
603}
virtual void TP_ScrollWindow(double scrollto)=0
double GetScreenEndTime() const
Definition: ZoomInfo.h:104

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 595 of file TrackPanel.cpp.

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 605 of file TrackPanel.cpp.

606{
608 return ProjectAudioIO::Get( *p ).IsAudioActive();
609}
bool IsAudioActive() const
static ProjectAudioIO & Get(AudacityProject &project)

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 515 of file TrackPanel.cpp.

516{
518}
virtual void TP_RedrawScrollbars()=0

References mListener, and TrackPanelListener::TP_RedrawScrollbars().

Here is the call graph for this function:

◆ OnAudioIO()

void TrackPanel::OnAudioIO ( AudioIOEvent  evt)

Definition at line 802 of file TrackPanel.cpp.

803{
804 if (evt.type == AudioIOEvent::MONITOR)
805 return;
806 // Some hit tests want to change their cursor to and from the ban symbol
808}
void HandleCursorForPresentMouseState(bool doHit=true)
void CallAfter(Action action)
Schedule an action to be done later, and in the main thread.
Definition: BasicUI.cpp:208
enum AudioIOEvent::Type type

References BasicUI::CallAfter(), CellularPanel::HandleCursorForPresentMouseState(), AudioIOEvent::MONITOR, and AudioIOEvent::type.

Referenced by TrackPanel().

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

◆ OnEnsureVisible()

void TrackPanel::OnEnsureVisible ( const TrackListEvent event)

Definition at line 997 of file TrackPanel.cpp.

998{
999 bool modifyState = e.mExtra;
1000
1001 auto pTrack = e.mpTrack.lock();
1002 auto t = pTrack.get();
1003
1004 int trackTop = 0;
1005 int trackHeight =0;
1006
1007 for (auto it : GetTracks()->Leaders()) {
1008 trackTop += trackHeight;
1009
1010 auto channels = TrackList::Channels(it);
1011 trackHeight = channels.sum( TrackView::GetTrackHeight );
1012
1013 //We have found the track we want to ensure is visible.
1014 if (channels.contains(t)) {
1015
1016 //Get the size of the trackpanel.
1017 int width, height;
1018 GetSize(&width, &height);
1019
1020 if (trackTop < mViewInfo->vpos) {
1021 height = mViewInfo->vpos - trackTop + mViewInfo->scrollStep;
1022 height /= mViewInfo->scrollStep;
1023 mListener->TP_ScrollUpDown(-height);
1024 }
1025 else if (trackTop + trackHeight > mViewInfo->vpos + height) {
1026 height = (trackTop + trackHeight) - (mViewInfo->vpos + height);
1027 height = (height + mViewInfo->scrollStep + 1) / mViewInfo->scrollStep;
1028 mListener->TP_ScrollUpDown(height);
1029 }
1030
1031 break;
1032 }
1033 }
1034 Refresh(false);
1035
1036 if ( modifyState )
1038}
void ModifyState(bool bWantsAutoSave)
static ProjectHistory & Get(AudacityProject &project)
static auto Channels(TrackType *pTrack) -> TrackIterRange< TrackType >
Definition: Track.h:1544
void Refresh(bool eraseBackground=true, const wxRect *rect=(const wxRect *) NULL) override
Definition: TrackPanel.cpp:781
virtual bool TP_ScrollUpDown(int delta)=0
static int GetTrackHeight(const Track *pTrack)
Definition: TrackView.cpp:29
int scrollStep
Definition: ViewInfo.h:237
int vpos
Definition: ZoomInfo.h:50

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

Here is the call graph for this function:

◆ OnIdle()

void TrackPanel::OnIdle ( wxIdleEvent &  event)

Definition at line 384 of file TrackPanel.cpp.

385{
386 event.Skip();
387 // The window must be ready when the timer fires (#1401)
388 if (IsShownOnScreen())
389 {
390 mTimer.Start(std::chrono::milliseconds{kTimerInterval}.count(), FALSE);
391
392 // Timer is started, we don't need the event anymore
393 GetProjectFrame( *GetProject() ).Unbind(wxEVT_IDLE,
394 &TrackPanel::OnIdle, this);
395 }
396 else
397 {
398 // Get another idle event, wx only guarantees we get one
399 // event after "some other normal events occur"
400 event.RequestMore();
401 }
402}
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 ...
constexpr auto kTimerInterval

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

Referenced by OnIdle(), and 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 688 of file TrackPanel.cpp.

689{
690 switch (event.GetKeyCode())
691 {
692 // Allow PageUp and PageDown keys to
693 //scroll the Track Panel left and right
694 case WXK_PAGEUP:
696 return;
697
698 case WXK_PAGEDOWN:
700 return;
701
702 default:
703 // fall through to base class handler
704 event.Skip();
705 }
706}
void HandlePageUpKey()
Definition: TrackPanel.cpp:595
void HandlePageDownKey()
Definition: TrackPanel.cpp:600

References HandlePageDownKey(), and HandlePageUpKey().

Here is the call graph for this function:

◆ OnMouseEvent()

void TrackPanel::OnMouseEvent ( wxMouseEvent &  event)

Definition at line 708 of file TrackPanel.cpp.

709{
710 if (event.LeftDown()) {
711 // wxTimers seem to be a little unreliable, so this
712 // "primes" it to make sure it keeps going for a while...
713
714 // When this timer fires, we call TrackPanel::OnTimer and
715 // possibly update the screen for offscreen scrolling.
716 mTimer.Stop();
717 mTimer.Start(std::chrono::milliseconds{kTimerInterval}.count(), FALSE);
718 }
719
720
721 if (event.ButtonUp()) {
722 //EnsureVisible should be called after processing the up-click.
723 this->CallAfter( [this, event]{
724 const auto foundCell = FindCell(event.m_x, event.m_y);
725 const auto t = FindTrack( foundCell.pCell.get() );
726 if ( t ) {
727 TrackFocus::Get(*GetProject()).Set(t.get());
728 t->EnsureVisible();
729 }
730 } );
731 }
732
733 // Must also fall through to base class handler
734 event.Skip();
735}
FoundCell FindCell(int mouseX, int mouseY)
void EnsureVisible(bool modifyState=false)
Definition: Track.cpp:98
std::shared_ptr< Track > FindTrack(TrackPanelCell *pCell)
Definition: TrackPanel.cpp:521

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 472 of file TrackPanel.cpp.

473{
475
476 auto sw =
478
479 {
480 wxPaintDC dc(this);
481
482 // Retrieve the damage rectangle
483 wxRect box = GetUpdateRegion().GetBox();
484
485 // Recreate the backing bitmap if we have a full refresh
486 // (See TrackPanel::Refresh())
487 if (mRefreshBacking || (box == GetRect()))
488 {
489 // Reset (should a mutex be used???)
490 mRefreshBacking = false;
491
492 // Redraw the backing bitmap
494
495 // Copy it to the display
496 DisplayBitmap(dc);
497 }
498 else
499 {
500 // Copy full, possibly clipped, damage rectangle
501 RepairBitmap(dc, box.x, box.y, box.width, box.height);
502 }
503
504 // Done with the clipped DC
505
506 // Drawing now goes directly to the client area.
507 // DrawOverlays() may need to draw outside the clipped region.
508 // (Used to make a NEW, separate wxClientDC, but that risks flashing
509 // problems on Mac.)
510 dc.DestroyClippingRegion();
511 DrawOverlays(true, &dc);
512 }
513}
wxDC & GetBackingDCForRepaint()
Definition: BackedPanel.cpp:35
void DisplayBitmap(wxDC &dc)
Definition: BackedPanel.cpp:65
void RepairBitmap(wxDC &dc, wxCoord x, wxCoord y, wxCoord width, wxCoord height)
Definition: BackedPanel.cpp:60
@ TrackPanel
Full repaint time of the TrackPanel.
static Stopwatch CreateStopwatch(SectionID section) noexcept
Create a Stopwatch for the section specified.
void DrawOverlays(bool repaint_all, wxDC *pDC=nullptr)
SelectedRegion mLastDrawnSelectedRegion
Definition: TrackPanel.h:226
void DrawTracks(wxDC *dc)
Definition: TrackPanel.cpp:815

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

Here is the call graph for this function:

◆ OnSize()

void TrackPanel::OnSize ( wxSizeEvent &  evt)

Definition at line 376 of file TrackPanel.cpp.

377{
378 evt.Skip();
379 const auto &size = evt.GetSize();
380 mViewInfo->SetWidth( size.GetWidth() );
381 mViewInfo->SetHeight( size.GetHeight() );
382}
void SetHeight(int height)
Definition: ViewInfo.h:202
void SetWidth(int width)
Definition: ZoomInfo.h:86

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

Here is the call graph for this function:

◆ OnSyncLockChange()

void TrackPanel::OnSyncLockChange ( struct SyncLockChangeMessage  )

Definition at line 457 of file TrackPanel.cpp.

458{
459 Refresh(false);
460}

References Refresh().

Referenced by TrackPanel().

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

◆ OnTimer()

void TrackPanel::OnTimer ( wxTimerEvent &  event)

AS: This gets called on our wx timer events.

Definition at line 405 of file TrackPanel.cpp.

406{
407 mTimeCount++;
408
409 AudacityProject *const p = GetProject();
410 auto &window = ProjectWindow::Get( *p );
411
412 auto &projectAudioIO = ProjectAudioIO::Get( *p );
413 auto gAudioIO = AudioIO::Get();
414
415 // Check whether we were playing or recording, but the stream has stopped.
416 if (projectAudioIO.GetAudioIOToken()>0 && !IsAudioActive())
417 {
418 //the stream may have been started up after this one finished (by some other project)
419 //in that case reset the buttons don't stop the stream
420 auto &projectAudioManager = ProjectAudioManager::Get( *p );
421 projectAudioManager.Stop(!gAudioIO->IsStreamActive());
422 }
423
424 // Next, check to see if we were playing or recording
425 // audio, but now Audio I/O is completely finished.
426 if (projectAudioIO.GetAudioIOToken()>0 &&
427 !gAudioIO->IsAudioTokenActive(projectAudioIO.GetAudioIOToken()))
428 {
429 projectAudioIO.SetAudioIOToken(0);
430 window.RedrawProject();
431 }
434 }
435
436 // Notify listeners for timer ticks
437 window.GetPlaybackScroller().OnTimer();
438
439 DrawOverlays(false);
440 mRuler->DrawOverlays(false);
441
442 if(IsAudioActive() && gAudioIO->GetNumCaptureChannels()) {
443
444 // Periodically update the display while recording
445
446 if ((mTimeCount % 5) == 0) {
447 // Must tell OnPaint() to recreate the backing bitmap
448 // since we've not done a full refresh.
449 mRefreshBacking = true;
450 Refresh( false );
451 }
452 }
453 if(mTimeCount > 1000)
454 mTimeCount = 0;
455}
static ProjectAudioManager & Get(AudacityProject &project)
void UpdateSelectionDisplay()
Definition: TrackPanel.cpp:620
bool IsAudioActive()
Definition: TrackPanel.cpp:605

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 ( struct TrackFocusChangeMessage  )

Definition at line 1717 of file TrackPanel.cpp.

1718{
1719 if (auto cell = GetFocusedCell())
1720 Refresh( false );
1721}
TrackPanelCell * GetFocusedCell() override

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 ( )

Definition at line 673 of file TrackPanel.cpp.

674{
675 // copy shared_ptr for safety, as in HandleClick
676 auto handle = Target();
677 if (handle) {
678 handle->OnProjectChange(GetProject());
679 }
680
681 // If the focused track disappeared but there are still other tracks,
682 // this reassigns focus.
683 TrackFocus( *GetProject() ).Get();
684
686}
static TrackFocus & Get(AudacityProject &project)
void UpdateVRulerSize()
Definition: TrackPanel.cpp:973

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

Here is the call graph for this function:

◆ OnTrackListResizing()

void TrackPanel::OnTrackListResizing ( const TrackListEvent event)

Definition at line 660 of file TrackPanel.cpp.

661{
662 auto t = e.mpTrack.lock();
663 // A deleted track can trigger the event. In which case do nothing here.
664 // A deleted track can have a valid pointer but no owner, bug 2060
665 if( t && t->HasOwner() )
666 UpdateVRuler(t.get());
667
668 // fix for bug 2477
670}
void UpdateVRuler(Track *t)
Definition: TrackPanel.cpp:924

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

Here is the call graph for this function:

◆ OnTrackMenu()

void TrackPanel::OnTrackMenu ( Track t = NULL)

Definition at line 991 of file TrackPanel.cpp.

992{
993 CellularPanel::DoContextMenu( t ? &TrackView::Get( *t ) : nullptr );
994}
void DoContextMenu(TrackPanelCell *pCell=nullptr)

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

Here is the call graph for this function:

◆ OnUndoReset()

void TrackPanel::OnUndoReset ( struct UndoRedoMessage  message)

Definition at line 462 of file TrackPanel.cpp.

463{
464 if (message.type == UndoRedoMessage::Reset) {
465 TrackFocus::Get( *GetProject() ).Set( nullptr );
466 Refresh( false );
467 }
468}
enum UndoRedoMessage::Type type

References TrackFocus::Get(), GetProject(), Refresh(), UndoRedoMessage::Reset, and UndoRedoMessage::type.

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 529 of file TrackPanel.cpp.

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

References RefreshCode::DestroyedCell, RefreshCode::DrawOverlays, OverlayPanel::DrawOverlays(), Track::EnsureVisible(), RefreshCode::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 781 of file TrackPanel.cpp.

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

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

Referenced by ProjectSelectionManager::AS_SetSelectionFormat(), OnEnsureVisible(), OnSyncLockChange(), 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 743 of file TrackPanel.cpp.

744{
745 if (!trk)
746 return;
747
748 // Always move to the first channel of the group, and use only
749 // the sum of channel heights, not the height of any channel alone!
750 trk = *GetTracks()->FindLeader(trk);
751 auto &view = TrackView::Get( *trk );
752 auto height =
754
755 // Set rectangle top according to the scrolling position, `vpos`
756 // Subtract the inset (above) and shadow (below) from the height of the
757 // rectangle, but not the border
758 // This matters because some separators do paint over the border
759 const auto top =
760 -mViewInfo->vpos + view.GetCumulativeHeightBefore() + kTopInset;
761 height -= (kTopInset + kShadowThickness);
762
763 // Width also subtracts insets (left and right) plus shadow (right)
764 const auto left = kLeftInset;
765 const auto width = GetRect().GetWidth()
767
768 wxRect rect(left, top, width, height);
769
770 if( refreshbacking )
771 mRefreshBacking = true;
772
773 Refresh( false, &rect );
774}
@ kTopInset
@ kRightInset
Definition: ZoomInfo.h:26
@ kShadowThickness
Definition: ZoomInfo.h:23
@ kLeftInset
Definition: ZoomInfo.h:25

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{WaveTrackAffordanceControls.cpp}::OnEditClipName(), anonymous_namespace{TrackMenus.cpp}::SetTrackGain(), anonymous_namespace{TrackMenus.cpp}::SetTrackPan(), and TrackPanel().

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 1637 of file TrackPanel.cpp.

1638{
1639 // Root and other subgroup objects are throwaways.
1640 // They might instead be cached to avoid repeated allocation.
1641 // That cache would need invalidation when there is addition, deletion, or
1642 // permutation of tracks, or change of width of the vertical rulers.
1643 return std::make_shared< MainGroup >( *this );
1644}

◆ SetBackgroundCell()

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

Definition at line 859 of file TrackPanel.cpp.

861{
862 mpBackground = pCell;
863}

References mpBackground.

◆ SetFocusedCell()

void TrackPanel::SetFocusedCell ( )
overridevirtual

Implements CellularPanel.

Definition at line 1709 of file TrackPanel.cpp.

1710{
1711 // This may have a side-effect of assigning a focus if there was none
1712 auto& trackFocus = TrackFocus::Get(*GetProject());
1713 trackFocus.Set(trackFocus.Get());
1715}
void Capture(wxWindow *handler)

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 351 of file TrackPanel.cpp.

352{
353 // All vertical rulers must be recalculated since the minimum and maximum
354 // frequencies may have been changed.
356
357 Refresh();
358}
void UpdateVRulers()
Definition: TrackPanel.cpp:916

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 620 of file TrackPanel.cpp.

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

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 611 of file TrackPanel.cpp.

612{
613 auto status = st;
614 if (HasEscape())
615 /* i18n-hint Esc is a key on the keyboard */
616 status.Join( XO("(Esc to cancel)"), " " );
617 ProjectStatus::Get( *GetProject() ).Set( status );
618}
static ProjectStatus & Get(AudacityProject &project)
void Set(const TranslatableString &msg, StatusBarField field=mainStatusBarField)
TranslatableString & Join(TranslatableString arg, const wxString &separator={}) &
Append another translatable string.

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 932 of file TrackPanel.cpp.

933{
934 wxASSERT(t);
935 if (!t)
936 return;
937
938 auto heights = FindAdjustedChannelHeights(*t);
939
940 wxRect rect(mViewInfo->GetVRulerOffset(),
941 0,
943 0);
944
945 auto pHeight = heights.begin();
946 for (auto channel : TrackList::Channels(t)) {
947 auto &view = TrackView::Get( *channel );
948 const auto height = *pHeight++;
949 rect.SetHeight( height );
950 const auto subViews = view.GetSubViews( rect );
951 if (subViews.empty())
952 continue;
953
954 auto iter = subViews.begin(), end = subViews.end(), next = iter;
955 auto yy = iter->first;
956 wxSize vRulerSize{ 0, 0 };
957 for ( ; iter != end; iter = next ) {
958 ++next;
959 auto nextY = ( next == end )
960 ? height
961 : next->first;
962 rect.SetHeight( nextY - yy );
963 // This causes ruler size in the track to be reassigned:
964 TrackVRulerControls::Get( *iter->second ).UpdateRuler( rect );
965 // But we want to know the maximum width and height over all sub-views:
966 vRulerSize.IncTo( {t->vrulerSize.first, t->vrulerSize.second} );
967 yy = nextY;
968 }
969 t->vrulerSize = {vRulerSize.x, vRulerSize.y};
970 }
971}
std::pair< int, int > vrulerSize
Definition: Track.h:387
static TrackVRulerControls & Get(TrackView &)
virtual void UpdateRuler(const wxRect &rect)=0
int GetVRulerOffset() const
Definition: ZoomInfo.h:90
int GetVRulerWidth() const
Definition: ZoomInfo.h:88
auto end(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
Definition: PackedArray.h:159
std::vector< int > FindAdjustedChannelHeights(Track &t)
Definition: TrackPanel.cpp:871

References TrackList::Channels(), PackedArray::end(), anonymous_namespace{TrackPanel.cpp}::FindAdjustedChannelHeights(), TrackView::Get(), TrackVRulerControls::Get(), ZoomInfo::GetVRulerOffset(), ZoomInfo::GetVRulerWidth(), 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 636 of file TrackPanel.cpp.

637{
638 if (mTracks->empty())
639 {
640 // BG: There are no more tracks on screen
641 //BG: Set zoom to normal
643
644 //STM: Set selection to 0,0
645 //PRL: and default the rest of the selection information
647
648 // PRL: Following causes the time ruler to align 0 with left edge.
649 // Bug 972
650 mViewInfo->h = 0;
651
653 //STM: Clear message if all tracks are removed
655 }
656}
virtual void TP_HandleResize()=0
static double GetDefaultZoom()
Definition: ZoomInfo.h:113
void SetZoom(double pixelsPerSecond)
Definition: ZoomInfo.cpp:80

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 924 of file TrackPanel.cpp.

925{
926 if (t)
928
930}
void UpdateTrackVRuler(Track *t)
Definition: TrackPanel.cpp:932

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 916 of file TrackPanel.cpp.

917{
918 for (auto t : GetTracks()->Any< WaveTrack >())
920
922}

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 973 of file TrackPanel.cpp.

974{
975 auto trackRange = GetTracks()->Any();
976 if (trackRange) {
977 wxSize s { 0, 0 };
978 for (auto t : trackRange)
979 s.IncTo({t->vrulerSize.first, t->vrulerSize.second});
980
981 if (mViewInfo->GetVRulerWidth() != s.GetWidth()) {
982 mViewInfo->SetVRulerWidth( s.GetWidth() );
984 mViewInfo->GetLeftOffset()); // bevel on AdornedRuler
985 mRuler->Refresh();
986 }
987 }
988 Refresh(false);
989}
void Refresh(bool eraseBackground=true, const wxRect *rect=(const wxRect *) NULL) override
void SetLeftOffset(int offset)
void SetVRulerWidth(int width)
Definition: ZoomInfo.h:89

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 1042 of file TrackPanel.cpp.

1042 {
1043
1044 int trackTop = 0;
1045 int trackHeight = 0;
1046
1047 auto tracks = GetTracks();
1048
1049 auto range = tracks->Leaders();
1050 if (!range.empty()) {
1051 trackHeight = TrackView::GetChannelGroupHeight( *range.rbegin() );
1052 --range.second;
1053 }
1054 trackTop = range.sum( TrackView::GetChannelGroupHeight );
1055
1056 int delta;
1057
1058 //Get the size of the trackpanel.
1059 int width, height;
1060 GetSize(&width, &height);
1061
1062 delta = (fracPosition * (trackTop + trackHeight - height)) - mViewInfo->vpos + mViewInfo->scrollStep;
1063 //wxLogDebug( "Scroll down by %i pixels", delta );
1064 delta /= mViewInfo->scrollStep;
1065 mListener->TP_ScrollUpDown(delta);
1066 Refresh(false);
1067}
static int GetChannelGroupHeight(const Track *pTrack)
Definition: TrackView.cpp:34

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

◆ mAudioIOSubscription

Observer::Subscription TrackPanel::mAudioIOSubscription
protected

Definition at line 188 of file TrackPanel.h.

Referenced by TrackPanel().

◆ mFocusChangeSubscription

Observer::Subscription TrackPanel::mFocusChangeSubscription
protected

Definition at line 190 of file TrackPanel.h.

Referenced by TrackPanel().

◆ mLastDrawnSelectedRegion

SelectedRegion TrackPanel::mLastDrawnSelectedRegion {}
protected

Definition at line 226 of file TrackPanel.h.

Referenced by OnPaint(), and OnTimer().

◆ mListener

TrackPanelListener* TrackPanel::mListener
protected

◆ mpBackground

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

Definition at line 230 of file TrackPanel.h.

Referenced by GetBackgroundCell(), and SetBackgroundCell().

◆ mRealtimeEffectManagerSubscription

Observer::Subscription TrackPanel::mRealtimeEffectManagerSubscription
protected

Definition at line 191 of file TrackPanel.h.

Referenced by TrackPanel().

◆ mRefreshBacking

bool TrackPanel::mRefreshBacking
protected

Definition at line 221 of file TrackPanel.h.

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

◆ mRuler

AdornedRulerPanel* TrackPanel::mRuler
protected

◆ mSyncLockSubscription

Observer::Subscription TrackPanel::mSyncLockSubscription
protected

Definition at line 192 of file TrackPanel.h.

Referenced by TrackPanel().

◆ mTimeCount

int TrackPanel::mTimeCount
protected

Definition at line 219 of file TrackPanel.h.

Referenced by OnTimer(), and TrackPanel().

◆ mTimer

TrackPanel::AudacityTimer TrackPanel::mTimer
protected

◆ mTrackArtist

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

Definition at line 201 of file TrackPanel.h.

Referenced by DrawTracks(), and TrackPanel().

◆ mTrackListSubscription

Observer::Subscription TrackPanel::mTrackListSubscription
protected

Definition at line 187 of file TrackPanel.h.

Referenced by TrackPanel().

◆ mTracks

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

Definition at line 197 of file TrackPanel.h.

Referenced by TrackPanel(), and UpdateViewIfNoTracks().

◆ mUndoSubscription

Observer::Subscription TrackPanel::mUndoSubscription
protected

Definition at line 189 of file TrackPanel.h.

Referenced by TrackPanel().


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