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 OnProjectSettingsChange (wxCommandEvent &event)
 
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
 
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 253 of file TrackPanel.cpp.

260 : CellularPanel(parent, id, pos, size, viewInfo,
261 wxWANTS_CHARS | wxNO_BORDER),
262 mListener( &ProjectWindow::Get( *project ) ),
263 mTracks(tracks),
264 mRuler(ruler),
265 mTrackArtist(nullptr),
266 mRefreshBacking(false)
267#ifndef __WXGTK__ //Get rid if this pragma for gtk
268#pragma warning( default: 4355 )
269#endif
270{
271 SetLayoutDirection(wxLayout_LeftToRight);
272 SetLabel(XO("Track Panel"));
273 SetName(XO("Track Panel"));
274 SetBackgroundStyle(wxBG_STYLE_PAINT);
275
276 {
277 auto pAx = std::make_unique <TrackPanelAx>( *project );
278 pAx->SetWindow( this );
279 wxWeakRef< TrackPanel > weakThis{ this };
280 pAx->SetFinder(
281 [weakThis]( const Track &track ) -> wxRect {
282 if (weakThis)
283 return weakThis->FindTrackRect( &track );
284 return {};
285 }
286 );
287 TrackFocus::Get( *GetProject() ).SetAccessible(
288 *this, std::move( pAx ) );
289 }
290
291 mTrackArtist = std::make_unique<TrackArtist>( this );
292
293 mTimeCount = 0;
294 mTimer.parent = this;
295 // Timer is started after the window is visible
296 ProjectWindow::Get( *GetProject() ).Bind(wxEVT_IDLE,
297 &TrackPanel::OnIdle, this);
298
299 // Register for tracklist updates
301 mTracks->Subscribe([this](const TrackListEvent &event){
302 switch (event.mType) {
303 case TrackListEvent::RESIZING:
304 case TrackListEvent::ADDITION:
305 OnTrackListResizing(event); break;
306 case TrackListEvent::DELETION:
307 OnTrackListDeletion(); break;
308 case TrackListEvent::TRACK_REQUEST_VISIBLE:
309 OnEnsureVisible(event); break;
310 default:
311 break;
312 }
313 });
314
315 auto theProject = GetProject();
316 theProject->Bind(
317 EVT_PROJECT_SETTINGS_CHANGE, &TrackPanel::OnProjectSettingsChange, this);
319 .Subscribe(*this, &TrackPanel::OnTrackFocusChange);
320
323
326
328 .Subscribe([this](const RealtimeEffectManagerMessage& msg)
329 {
330 if(msg.track)
331 //update "effects" button
332 RefreshTrack(msg.track.get());
333 });
334
335 UpdatePrefs();
336}
#define XO(s)
Definition: Internat.h:31
static AudioIO * Get()
Definition: AudioIO.cpp:133
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)
Track * Get()
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:225
void UpdatePrefs() override
Definition: TrackPanel.cpp:349
AdornedRulerPanel * mRuler
Definition: TrackPanel.h:198
TrackPanelListener * mListener
Definition: TrackPanel.h:194
std::shared_ptr< TrackList > mTracks
Definition: TrackPanel.h:196
void OnProjectSettingsChange(wxCommandEvent &event)
Definition: TrackPanel.cpp:455
Observer::Subscription mAudioIOSubscription
Definition: TrackPanel.h:189
AudacityProject * GetProject() const override
Definition: TrackPanel.cpp:360
Observer::Subscription mTrackListSubscription
Definition: TrackPanel.h:188
void OnTrackFocusChange(struct TrackFocusChangeMessage)
Observer::Subscription mRealtimeEffectManagerSubscription
Definition: TrackPanel.h:192
bool mRefreshBacking
Definition: TrackPanel.h:220
TrackPanel::AudacityTimer mTimer
void OnUndoReset(struct UndoRedoMessage)
Definition: TrackPanel.cpp:467
Observer::Subscription mUndoSubscription
Definition: TrackPanel.h:190
int mTimeCount
Definition: TrackPanel.h:218
void OnAudioIO(AudioIOEvent)
Definition: TrackPanel.cpp:807
void OnIdle(wxIdleEvent &event)
Definition: TrackPanel.cpp:382
Observer::Subscription mFocusChangeSubscription
Definition: TrackPanel.h:191
void RefreshTrack(Track *trk, bool refreshbacking=true)
Definition: TrackPanel.cpp:748
std::unique_ptr< TrackArtist > mTrackArtist
Definition: TrackPanel.h:200
static UndoManager & Get(AudacityProject &project)
Definition: UndoManager.cpp:67
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:1288
const Type mType
Definition: Track.h:1325

References AudioIO::Get(), TrackFocus::Get(), UndoManager::Get(), RealtimeEffectManager::Get(), ProjectWindow::Get(), GetProject(), mAudioIOSubscription, mFocusChangeSubscription, mRealtimeEffectManagerSubscription, mTimeCount, mTimer, mTrackArtist, mTrackListSubscription, mTracks, TrackListEvent::mType, mUndoSubscription, OnAudioIO(), OnIdle(), OnProjectSettingsChange(), 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 339 of file TrackPanel.cpp.

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

References mTimer.

Member Function Documentation

◆ Destroy()

void TrackPanel::Destroy ( AudacityProject project)
static

Definition at line 240 of file TrackPanel.cpp.

241{
242 auto *pPanel = GetAttachedWindows(project).Find<TrackPanel>( sKey );
243 if (pPanel) {
244 pPanel->wxWindow::Destroy();
245 GetAttachedWindows(project).Assign(sKey, nullptr);
246 }
247}
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:206

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

821{
822 wxRegion region = GetUpdateRegion();
823
824 const wxRect clip = GetRect();
825
827 mTrackArtist->pSelectedRegion = &sr;
828 mTrackArtist->pZoomInfo = mViewInfo;
830 *dc, Target(), mLastMouseState, mTrackArtist.get()
831 };
832
833 // Don't draw a bottom margin here.
834
835 const auto &settings = ProjectSettings::Get( *GetProject() );
836 bool bMultiToolDown =
837 (ToolCodes::multiTool == settings.GetTool());
838 bool envelopeFlag =
839 bMultiToolDown || (ToolCodes::envelopeTool == settings.GetTool());
840 bool bigPointsFlag =
841 bMultiToolDown || (ToolCodes::drawTool == settings.GetTool());
842 bool sliderFlag = bMultiToolDown;
843 bool brushFlag = false;
844#ifdef EXPERIMENTAL_BRUSH_TOOL
845 brushFlag = (ToolCodes::brushTool == settings.GetTool());
846#endif
847
848 const bool hasSolo = GetTracks()->Any< PlayableTrack >()
849 .any_of( []( const PlayableTrack *pt ) {
850 pt = static_cast< const PlayableTrack * >(
851 pt->SubstitutePendingChangedTrack().get() );
852 return (pt && pt->GetSolo());
853 } );
854
855 mTrackArtist->drawEnvelope = envelopeFlag;
856 mTrackArtist->bigPoints = bigPointsFlag;
857 mTrackArtist->drawSliders = sliderFlag;
858 mTrackArtist->onBrushTool = brushFlag;
859 mTrackArtist->hasSolo = hasSolo;
860
862}
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:916
bool GetSolo() const
Definition: Track.h:924
static ProjectSettings & Get(AudacityProject &project)
Defines a selected portion of a project.
std::shared_ptr< Track > SubstitutePendingChangedTrack()
Definition: Track.cpp:1210
auto Any() -> TrackIterRange< TrackType >
Definition: Track.h:1437
const TrackList * GetTracks() const
Definition: TrackPanel.h:168
NotifyingSelectedRegion selectedRegion
Definition: ViewInfo.h:216

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

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

1697{
1698 std::vector<wxRect> results;
1699 if (target)
1700 VisitCells( [&]( const wxRect &rect, TrackPanelCell &visited ) {
1701 if (auto pRuler = dynamic_cast<const TrackVRulerControls*>(&visited);
1702 pRuler && pRuler->FindTrack().get() == target)
1703 results.push_back(rect);
1704 } );
1705 return results;
1706}
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 1654 of file TrackPanel.cpp.

1655{
1656 auto leader = *GetTracks()->FindLeader( target );
1657 if (!leader) {
1658 return {};
1659 }
1660
1661 return CellularPanel::FindRect( [&] ( TrackPanelNode &node ) {
1662 if (auto pGroup = dynamic_cast<const LabeledChannelGroup*>( &node ))
1663 return pGroup->mpTrack.get() == leader;
1664 return false;
1665 } );
1666}
wxRect FindRect(const TrackPanelCell &cell)
TrackIter< Track > FindLeader(Track *pTrack)
Definition: Track.cpp:644
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 230 of file TrackPanel.cpp.

231{
232 return GetAttachedWindows(project).Get< TrackPanel >( sKey );
233}
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(), EditActions::Handler::OnCopy(), EditActions::Handler::OnCut(), anonymous_namespace{WaveTrackAffordanceControls.cpp}::Handler::OnEditClipName(), ToolActions::Handler::OnNextTool(), EditActions::Handler::OnPaste(), LabelEditActions::Handler::OnPasteNewLabel(), TransportActions::Handler::OnPlayOneSecond(), TransportActions::Handler::OnPlayToSelection(), ToolActions::Handler::OnPrevTool(), FileActions::Handler::OnPrint(), EditActions::Handler::OnRedo(), SelectActions::Handler::OnSelectAll(), 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().

Here is the call graph for this function:

◆ Get() [2/2]

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

Definition at line 235 of file TrackPanel.cpp.

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

References Get().

Here is the call graph for this function:

◆ GetBackgroundCell()

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

Definition at line 870 of file TrackPanel.cpp.

871{
872 return mpBackground;
873}
std::shared_ptr< CommonTrackPanelCell > mpBackground
Definition: TrackPanel.h:229

References mpBackground.

Referenced by GetFocusedCell().

Here is the caller graph for this function:

◆ GetFocusedCell()

TrackPanelCell * TrackPanel::GetFocusedCell ( )
overridevirtual

Implements CellularPanel.

Definition at line 1708 of file TrackPanel.cpp.

1709{
1710 auto pTrack = TrackFocus::Get( *GetProject() ).Get();
1711 return pTrack ? &TrackView::Get( *pTrack ) : GetBackgroundCell().get();
1712}
std::shared_ptr< CommonTrackPanelCell > GetBackgroundCell()
Definition: TrackPanel.cpp:870
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 742 of file TrackPanel.cpp.

743{
746}
wxCoord MostRecentXCoord() const
int GetLeftOffset() const
Definition: ZoomInfo.h:103
double PositionToTime(wxInt64 position, wxInt64 origin=0, bool ignoreFisheye=false) const
Definition: ZoomInfo.cpp:41

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

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

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

637{
638 return GetTracks()->SelectedLeaders().size();
639}
auto SelectedLeaders() -> TrackIterRange< TrackType >
Definition: Track.h:1488

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

606{
608}
virtual void TP_ScrollWindow(double scrollto)=0
double GetScreenEndTime() const
Definition: ZoomInfo.h:114

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

611{
613 return ProjectAudioIO::Get( *p ).IsAudioActive();
614}
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 520 of file TrackPanel.cpp.

521{
523}
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 807 of file TrackPanel.cpp.

808{
809 if (evt.type == AudioIOEvent::MONITOR)
810 return;
811 // Some hit tests want to change their cursor to and from the ban symbol
813}
void HandleCursorForPresentMouseState(bool doHit=true)
void CallAfter(Action action)
Schedule an action to be done later, and in the main thread.
Definition: BasicUI.cpp:206
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 1002 of file TrackPanel.cpp.

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

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

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

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

References HandlePageDownKey(), and HandlePageUpKey().

Here is the call graph for this function:

◆ OnMouseEvent()

void TrackPanel::OnMouseEvent ( wxMouseEvent &  event)

Definition at line 713 of file TrackPanel.cpp.

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

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

478{
480
481 auto sw =
483
484 {
485 wxPaintDC dc(this);
486
487 // Retrieve the damage rectangle
488 wxRect box = GetUpdateRegion().GetBox();
489
490 // Recreate the backing bitmap if we have a full refresh
491 // (See TrackPanel::Refresh())
492 if (mRefreshBacking || (box == GetRect()))
493 {
494 // Reset (should a mutex be used???)
495 mRefreshBacking = false;
496
497 // Redraw the backing bitmap
499
500 // Copy it to the display
501 DisplayBitmap(dc);
502 }
503 else
504 {
505 // Copy full, possibly clipped, damage rectangle
506 RepairBitmap(dc, box.x, box.y, box.width, box.height);
507 }
508
509 // Done with the clipped DC
510
511 // Drawing now goes directly to the client area.
512 // DrawOverlays() may need to draw outside the clipped region.
513 // (Used to make a NEW, separate wxClientDC, but that risks flashing
514 // problems on Mac.)
515 dc.DestroyClippingRegion();
516 DrawOverlays(true, &dc);
517 }
518}
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:225
void DrawTracks(wxDC *dc)
Definition: TrackPanel.cpp:820

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:

◆ OnProjectSettingsChange()

void TrackPanel::OnProjectSettingsChange ( wxCommandEvent &  event)

Definition at line 455 of file TrackPanel.cpp.

456{
457 event.Skip();
458 switch ( static_cast<ProjectSettings::EventCode>( event.GetInt() ) ) {
460 Refresh(false);
461 break;
462 default:
463 break;
464 }
465}

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

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

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

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

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

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

1723{
1724 if (auto cell = GetFocusedCell())
1725 Refresh( false );
1726}
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 678 of file TrackPanel.cpp.

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

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

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

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

997{
998 CellularPanel::DoContextMenu( t ? &TrackView::Get( *t ) : nullptr );
999}
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 467 of file TrackPanel.cpp.

468{
469 if (message.type == UndoRedoMessage::Reset) {
470 TrackFocus::Get( *GetProject() ).Set( nullptr );
471 Refresh( false );
472 }
473}
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 534 of file TrackPanel.cpp.

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

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

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

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

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}::Handler::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 1642 of file TrackPanel.cpp.

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

◆ SetBackgroundCell()

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

Definition at line 864 of file TrackPanel.cpp.

866{
867 mpBackground = pCell;
868}

References mpBackground.

◆ SetFocusedCell()

void TrackPanel::SetFocusedCell ( )
overridevirtual

Implements CellularPanel.

Definition at line 1714 of file TrackPanel.cpp.

1715{
1716 // This may have a side-effect of assigning a focus if there was none
1717 auto& trackFocus = TrackFocus::Get(*GetProject());
1718 trackFocus.Set(trackFocus.Get());
1720}
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 349 of file TrackPanel.cpp.

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

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

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

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

617{
618 auto status = st;
619 if (HasEscape())
620 /* i18n-hint Esc is a key on the keyboard */
621 status.Join( XO("(Esc to cancel)"), " " );
622 ProjectStatus::Get( *GetProject() ).Set( status );
623}
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 937 of file TrackPanel.cpp.

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

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

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

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

930{
931 if (t)
933
935}
void UpdateTrackVRuler(Track *t)
Definition: TrackPanel.cpp:937

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

922{
923 for (auto t : GetTracks()->Any< WaveTrack >())
925
927}

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

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

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

1047 {
1048
1049 int trackTop = 0;
1050 int trackHeight = 0;
1051
1052 auto tracks = GetTracks();
1053
1054 auto range = tracks->Leaders();
1055 if (!range.empty()) {
1056 trackHeight = TrackView::GetChannelGroupHeight( *range.rbegin() );
1057 --range.second;
1058 }
1059 trackTop = range.sum( TrackView::GetChannelGroupHeight );
1060
1061 int delta;
1062
1063 //Get the size of the trackpanel.
1064 int width, height;
1065 GetSize(&width, &height);
1066
1067 delta = (fracPosition * (trackTop + trackHeight - height)) - mViewInfo->vpos + mViewInfo->scrollStep;
1068 //wxLogDebug( "Scroll down by %i pixels", delta );
1069 delta /= mViewInfo->scrollStep;
1070 mListener->TP_ScrollUpDown(delta);
1071 Refresh(false);
1072}
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 225 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 229 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 220 of file TrackPanel.h.

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

◆ mRuler

AdornedRulerPanel* TrackPanel::mRuler
protected

◆ mTimeCount

int TrackPanel::mTimeCount
protected

Definition at line 218 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 200 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 196 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: