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 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)
 
std::shared_ptr< 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 Channel &target)
 
const TrackListGetTracks () const
 
TrackListGetTracks ()
 
ViewInfoGetViewInfo ()
 
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 std::shared_ptr< 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 (std::shared_ptr< TrackPanelCell > pCell)
 
void ClearTargets ()
 

Protected Attributes

Observer::Subscription mTrackListSubscription
 
Observer::Subscription mAudioIOSubscription
 
Observer::Subscription mUndoSubscription
 
Observer::Subscription mFocusChangeSubscription
 
Observer::Subscription mRealtimeEffectManagerSubscription
 
Observer::Subscription mSyncLockSubscription
 
Observer::Subscription mProjectRulerInvalidatedSubscription
 
Observer::Subscription mSelectionSubscription
 
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 ChannelView::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 59 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 257 of file TrackPanel.cpp.

264 : CellularPanel(parent, id, pos, size, viewInfo,
265 wxWANTS_CHARS | wxNO_BORDER),
267 mRuler(ruler),
268 mTrackArtist(nullptr),
269 mRefreshBacking(false)
270#ifndef __WXGTK__ //Get rid if this pragma for gtk
271#pragma warning( default: 4355 )
272#endif
273{
274 SetLayoutDirection(wxLayout_LeftToRight);
275 SetLabel(XO("Track Panel"));
276 SetName(XO("Track Panel"));
277 SetBackgroundStyle(wxBG_STYLE_PAINT);
278
279#if wxUSE_ACCESSIBILITY
280 // Inject finder of track rectangles into the accessibility helper
281 {
282 const auto finder = [
283 weakThis = wxWeakRef<TrackPanel>{ this }
284 ] (const Track &track) -> wxRect {
285 if (weakThis)
286 return weakThis->FindTrackRect(&track);
287 return {};
288 };
289 auto &focus = TrackFocus::Get(*GetProject());
290 auto &viewport = Viewport::Get(*GetProject());
291 TrackPanelAx *pAx{};
292 SetAccessible(pAx =
294 viewport.weak_from_this(), focus.weak_from_this(), finder });
295 focus.SetCallbacks(std::make_unique<TrackPanelAx::Adapter>(pAx));
296 }
297#endif
298
299 mTrackArtist = std::make_unique<TrackArtist>( this );
300
301 mTimeCount = 0;
302 mTimer.parent = this;
303 // Timer is started after the window is visible
304 ProjectWindow::Get( *GetProject() ).Bind(wxEVT_IDLE,
305 &TrackPanel::OnIdle, this);
306
307 // Register for tracklist updates
309 .Subscribe([this](const TrackListEvent &event){
310 switch (event.mType) {
311 case TrackListEvent::RESIZING:
312 case TrackListEvent::ADDITION:
313 OnTrackListResizing(event); break;
314 case TrackListEvent::DELETION:
315 OnTrackListDeletion(); break;
316 default:
317 break;
318 }
319 });
320
321 auto theProject = GetProject();
324
326 .Subscribe(*this, &TrackPanel::OnTrackFocusChange);
327
330
333
335 .Subscribe([this](const RealtimeEffectManagerMessage& msg)
336 {
337 if (auto pTrack = dynamic_cast<Track *>(msg.group))
338 //update "effects" button
339 RefreshTrack(pTrack);
340 });
341
343 ProjectTimeRuler::Get(*theProject).GetRuler().Subscribe([this](auto mode) { Refresh(); });
345 .Subscribe([this](auto&){ Refresh(false); });
346
347 UpdatePrefs();
348}
XO("Cut/Copy/Paste")
#define safenew
Definition: MemoryX.h:10
const auto tracks
static AudioIO * Get()
Definition: AudioIO.cpp:126
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 PendingTracks & Get(AudacityProject &project)
static ProjectTimeRuler & Get(AudacityProject &project)
static ProjectWindow & Get(AudacityProject &project)
static RealtimeEffectManager & Get(AudacityProject &project)
static SyncLockState & Get(AudacityProject &project)
Definition: SyncLock.cpp:27
Track * Get()
Definition: TrackFocus.cpp:156
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:110
Helper to TrackPanel to give accessibility.
Definition: TrackPanelAx.h:34
void UpdatePrefs() override
Definition: TrackPanel.cpp:361
Observer::Subscription mProjectRulerInvalidatedSubscription
Definition: TrackPanel.h:188
AdornedRulerPanel * mRuler
Definition: TrackPanel.h:193
std::shared_ptr< TrackList > mTracks
Definition: TrackPanel.h:191
Observer::Subscription mAudioIOSubscription
Definition: TrackPanel.h:183
AudacityProject * GetProject() const override
Definition: TrackPanel.cpp:372
Observer::Subscription mTrackListSubscription
Definition: TrackPanel.h:182
void Refresh(bool eraseBackground=true, const wxRect *rect=(const wxRect *) NULL) override
Definition: TrackPanel.cpp:802
void OnTrackFocusChange(struct TrackFocusChangeMessage)
Observer::Subscription mRealtimeEffectManagerSubscription
Definition: TrackPanel.h:186
Observer::Subscription mSyncLockSubscription
Definition: TrackPanel.h:187
bool mRefreshBacking
Definition: TrackPanel.h:215
TrackPanel::AudacityTimer mTimer
void OnUndoReset(struct UndoRedoMessage)
Definition: TrackPanel.cpp:473
Observer::Subscription mUndoSubscription
Definition: TrackPanel.h:184
int mTimeCount
Definition: TrackPanel.h:213
void OnAudioIO(AudioIOEvent)
Definition: TrackPanel.cpp:825
void OnSyncLockChange(struct SyncLockChangeMessage)
Definition: TrackPanel.cpp:468
void OnIdle(wxIdleEvent &event)
Definition: TrackPanel.cpp:394
Observer::Subscription mFocusChangeSubscription
Definition: TrackPanel.h:185
void RefreshTrack(Track *trk, bool refreshbacking=true)
Definition: TrackPanel.cpp:768
std::unique_ptr< TrackArtist > mTrackArtist
Definition: TrackPanel.h:195
Observer::Subscription mSelectionSubscription
Definition: TrackPanel.h:189
static UndoManager & Get(AudacityProject &project)
Definition: UndoManager.cpp:71
NotifyingSelectedRegion selectedRegion
Definition: ViewInfo.h:216
static Viewport & Get(AudacityProject &project)
Definition: Viewport.cpp:33
void SetLabel(const TranslatableString &label)
Posted when effect is being added or removed to/from channel group or project.
ChannelGroup * group
null, if changes happened in the project scope
Notification of changes in individual tracks of TrackList, or of TrackList's composition.
Definition: Track.h:803
const Type mType
Definition: Track.h:837

References anonymous_namespace{Scrubbing.cpp}::finder, AudioIO::Get(), TrackFocus::Get(), UndoManager::Get(), RealtimeEffectManager::Get(), SyncLockState::Get(), PendingTracks::Get(), Viewport::Get(), ProjectTimeRuler::Get(), ProjectWindow::Get(), GetProject(), ProjectTimeRuler::GetRuler(), RealtimeEffectManagerMessage::group, mAudioIOSubscription, mFocusChangeSubscription, mProjectRulerInvalidatedSubscription, mRealtimeEffectManagerSubscription, mSelectionSubscription, mSyncLockSubscription, mTimeCount, mTimer, mTrackArtist, mTrackListSubscription, TrackListEvent::mType, mUndoSubscription, OnAudioIO(), OnIdle(), OnSyncLockChange(), OnTrackFocusChange(), OnUndoReset(), TrackPanel::AudacityTimer::parent, Refresh(), RefreshTrack(), safenew, ViewInfo::selectedRegion, wxPanelWrapper::SetLabel(), wxPanelWrapper::SetName(), Observer::Publisher< Message, NotifyAll >::Subscribe(), UpdatePrefs(), and XO().

Here is the call graph for this function:

◆ ~TrackPanel()

TrackPanel::~TrackPanel ( )
virtual

Definition at line 351 of file TrackPanel.cpp.

352{
353 mTimer.Stop();
354
355 // This can happen if a label is being edited and the user presses
356 // ALT+F4 or Command+Q
357 if (HasCapture())
358 ReleaseMouse();
359}

References mTimer.

Member Function Documentation

◆ Destroy()

void TrackPanel::Destroy ( AudacityProject project)
static

Definition at line 244 of file TrackPanel.cpp.

245{
246 auto *pPanel = GetAttachedWindows(project).Find<TrackPanel>( sKey );
247 if (pPanel) {
248 pPanel->wxWindow::Destroy();
250 }
251}
AUDACITY_DLL_API AttachedWindows & GetAttachedWindows(AudacityProject &project)
const auto 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:342
void Assign(const RegisteredFactory &key, ReplacementPointer &&replacement)
Reassign Site's pointer to ClientData.
Definition: ClientData.h:364
The TrackPanel class coordinates updates and operations on the main part of the screen which contains...
Definition: TrackPanel.h:63
AttachedWindows::RegisteredFactory sKey
Definition: TrackPanel.cpp:210

References ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >::Assign(), ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >::Find(), GetAttachedWindows(), project, 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 838 of file TrackPanel.cpp.

839{
840 wxRegion region = GetUpdateRegion();
841
842 const wxRect clip = GetRect();
843
845 mTrackArtist->pSelectedRegion = &sr;
846 const auto &pendingTracks = PendingTracks::Get(*GetProject());
847 mTrackArtist->pPendingTracks = &pendingTracks;
848 mTrackArtist->pZoomInfo = mViewInfo;
850 *dc, Target(), mLastMouseState, mTrackArtist.get()
851 };
852
853 // Don't draw a bottom margin here.
854
855 const auto &settings = ProjectSettings::Get( *GetProject() );
856 bool bMultiToolDown =
857 (ToolCodes::multiTool == settings.GetTool());
858 bool envelopeFlag =
859 bMultiToolDown || (ToolCodes::envelopeTool == settings.GetTool());
860 bool bigPointsFlag =
861 bMultiToolDown || (ToolCodes::drawTool == settings.GetTool());
862 bool sliderFlag = bMultiToolDown;
863 bool brushFlag = false;
864#ifdef EXPERIMENTAL_BRUSH_TOOL
865 brushFlag = (ToolCodes::brushTool == settings.GetTool());
866#endif
867
868 const bool hasSolo = GetTracks()->Any<PlayableTrack>()
869 .any_of( [&](const PlayableTrack *pt) {
870 pt = static_cast<const PlayableTrack *>(
871 &pendingTracks.SubstitutePendingChangedTrack(*pt));
872 return pt->GetSolo();
873 } );
874
875 mTrackArtist->drawEnvelope = envelopeFlag;
876 mTrackArtist->bigPoints = bigPointsFlag;
877 mTrackArtist->drawSliders = sliderFlag;
878 mTrackArtist->onBrushTool = brushFlag;
879 mTrackArtist->hasSolo = hasSolo;
880
882}
static Settings & settings()
Definition: TrackInfo.cpp:51
void Draw(TrackPanelDrawingContext &context, unsigned nPasses)
UIHandlePtr Target()
ViewInfo * mViewInfo
wxMouseState mLastMouseState
AudioTrack subclass that can also be audibly replayed by the program.
Definition: PlayableTrack.h:40
bool GetSolo() const
Definition: PlayableTrack.h:48
static ProjectSettings & Get(AudacityProject &project)
Defines a selected portion of a project.
auto Any() -> TrackIterRange< TrackType >
Definition: Track.h:950
const TrackList * GetTracks() const
Definition: TrackPanel.h:163

References TrackList::Any(), CellularPanel::Draw(), ToolCodes::drawTool, ToolCodes::envelopeTool, PendingTracks::Get(), ProjectSettings::Get(), GetProject(), PlayableTrack::GetSolo(), GetTracks(), CellularPanel::mLastMouseState, mTrackArtist, ToolCodes::multiTool, CellularPanel::mViewInfo, TrackArtist::NPasses, ViewInfo::selectedRegion, settings(), 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 1508 of file TrackPanel.cpp.

1509{
1510 auto rect = FindTrackRect(target);
1511 if (rect != wxRect{}) {
1512 // Enlarge horizontally.
1513 // PRL: perhaps it's one pixel too much each side, including some gray
1514 // beyond the yellow?
1515 rect.x = 0;
1516 GetClientSize(&rect.width, nullptr);
1517
1518 // Enlarge vertically, enough to enclose the yellow focus border pixels
1519 // The the outermost ring of gray pixels is included on three sides
1520 // but not the top (should that be fixed?)
1521
1522 // (Note that TrackPanel paints its focus over the "top margin" of the
1523 // rectangle allotted to the track, according to ChannelView::GetY() and
1524 // ChannelView::GetHeight(), but also over the margin of the next track.)
1525
1526 rect.height += kBottomMargin;
1527 int dy = kTopMargin - 1;
1528 rect.Inflate( 0, dy );
1529
1530 // Note that this rectangle does not coincide with any one of
1531 // the nodes in the subdivision.
1532 }
1533 return rect;
1534}
@ kBottomMargin
@ kTopMargin
wxRect FindTrackRect(const Track *target)

References FindTrackRect(), kBottomMargin, and kTopMargin.

Here is the call graph for this function:

◆ FindRulerRects()

std::vector< wxRect > TrackPanel::FindRulerRects ( const Channel 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 1536 of file TrackPanel.cpp.

1537{
1538 std::vector<wxRect> results;
1539 VisitCells( [&](const wxRect &rect, TrackPanelCell &visited) {
1540 if (auto pRuler = dynamic_cast<const ChannelVRulerControls*>(&visited))
1541 if (auto pView = pRuler->GetChannelView())
1542 if (pView->FindChannel().get() == &target)
1543 results.push_back(rect);
1544 } );
1545 return results;
1546}
void VisitCells(const SimpleCellVisitor &visitor)

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

1500{
1501 return CellularPanel::FindRect( [&] ( TrackPanelNode &node ) {
1502 if (auto pGroup = dynamic_cast<const LabeledChannelGroup*>( &node ))
1503 return pGroup->mpTrack.get() == target;
1504 return false;
1505 } );
1506}
wxRect FindRect(const TrackPanelCell &cell)
The TrackPanel is built up of nodes, subtrees of the CellularPanel's area Common base class for Track...

References CellularPanel::FindRect().

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

235{
237}
Subclass & Get(const RegisteredFactory &key)
Get reference to an attachment, creating on demand if not present, down-cast it to Subclass.
Definition: ClientData.h:318

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

Referenced by SelectTimeCommand::Apply(), SetTrackVisualsCommand::ApplyInner(), BrushHandle::Click(), SelectHandle::Click(), WaveformPrefs::Commit(), MenuButtonHandle::CommitChanges(), LabelTrackView::DialogForLabelName(), anonymous_namespace{LabelMenus.cpp}::DoAddLabel(), anonymous_namespace{TrackMenus.cpp}::DoMixAndRender(), anonymous_namespace{EditMenus.cpp}::DoPasteText(), TrackUtilities::DoRemoveTracks(), BrushHandle::Drag(), EditCursorOverlay::Draw(), DeviceToolBar::EnableDisableButtons(), GetInfoCommand::ExploreTrackPanel(), Get(), anonymous_namespace{PitchAndSpeedDialog.cpp}::GetHitClip(), MixerTrackCluster::HandleSliderGain(), MixerTrackCluster::HandleSliderPan(), MixerTrackCluster::HandleSliderVelocity(), PanSliderHandle::HitTest(), VelocitySliderHandle::HitTest(), VolumeSliderHandle::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{LabelMenus.cpp}::OnPasteNewLabel(), anonymous_namespace{TransportMenus.cpp}::OnPlayOneSecond(), anonymous_namespace{TransportMenus.cpp}::OnPlayToSelection(), anonymous_namespace{ToolsToolBar.cpp}::OnPrevTool(), anonymous_namespace{EditMenus.cpp}::OnRedo(), SelectActions::Handler::OnSelectAll(), anonymous_namespace{ViewMenus.cpp}::OnShowClipping(), anonymous_namespace{ViewMenus.cpp}::OnShowRMS(), 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(), anonymous_namespace{ViewMenus.cpp}::OnZoomIn(), anonymous_namespace{ViewMenus.cpp}::OnZoomNormal(), anonymous_namespace{ViewMenus.cpp}::OnZoomToggle(), ProjectFileManager::OpenProjectFile(), SpectrumPrefs::Preview(), SpectrumPrefs::Rollback(), SelectUtilities::SelectNone(), PitchAndSpeedDialog::SetSemitoneShift(), anonymous_namespace{ToolsToolBar.cpp}::SetTool(), anonymous_namespace{TrackMenus.cpp}::SetTrackGain(), anonymous_namespace{TrackMenus.cpp}::SetTrackPan(), and ProjectWindow::ViewportSize().

Here is the call graph for this function:

◆ Get() [2/2]

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

Definition at line 239 of file TrackPanel.cpp.

240{
241 return Get( const_cast< AudacityProject & >( project ) );
242}
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:234

References Get(), and project.

Here is the call graph for this function:

◆ GetBackgroundCell()

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

Definition at line 890 of file TrackPanel.cpp.

891{
892 return mpBackground;
893}
std::shared_ptr< CommonTrackPanelCell > mpBackground
Definition: TrackPanel.h:224

References mpBackground.

Referenced by GetFocusedCell().

Here is the caller graph for this function:

◆ GetFocusedCell()

std::shared_ptr< TrackPanelCell > TrackPanel::GetFocusedCell ( )
overridevirtual

Implements CellularPanel.

Definition at line 1548 of file TrackPanel.cpp.

1549{
1550 auto pTrack = TrackFocus::Get(*GetProject()).Get();
1551 return pTrack
1552 ? ChannelView::Get(*pTrack->GetChannel(0)).shared_from_this()
1554}
static ChannelView & Get(Channel &channel)
std::shared_ptr< CommonTrackPanelCell > GetBackgroundCell()
Definition: TrackPanel.cpp:890

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

Referenced by OnTrackFocusChange().

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

◆ GetMostRecentXPos()

double TrackPanel::GetMostRecentXPos ( )

Definition at line 762 of file TrackPanel.cpp.

763{
766}
wxCoord MostRecentXCoord() const
double PositionToTime(int64 position, int64 origin=0, bool ignoreFisheye=false) const
Definition: ZoomInfo.cpp:34
int GetLeftOffset() const
Definition: ZoomInfo.h:96

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

373{
374 auto window = GetParent();
375
376 while(window != nullptr)
377 {
378 if(const auto projectWindow = dynamic_cast<ProjectWindow*>(window))
379 return projectWindow->FindProject().get();
380
381 window = window->GetParent();
382 }
383 return nullptr;
384}
A top-level window associated with a project, and handling scrollbars and zooming.
Definition: ProjectWindow.h:36

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

Here is the caller graph for this function:

◆ GetRuler()

AdornedRulerPanel * TrackPanel::GetRuler ( )
inline

Definition at line 166 of file TrackPanel.h.

166{ return mRuler;}

◆ GetSelectedTrackCount()

size_t TrackPanel::GetSelectedTrackCount ( ) const

Definition at line 655 of file TrackPanel.cpp.

656{
657 return GetTracks()->Selected().size();
658}
auto Selected() -> TrackIterRange< TrackType >
Definition: Track.h:967

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

Here is the call graph for this function:

◆ GetTracks() [1/2]

TrackList * TrackPanel::GetTracks ( )
inline

Definition at line 164 of file TrackPanel.h.

164{ return mTracks.get(); }

◆ GetTracks() [2/2]

const TrackList * TrackPanel::GetTracks ( ) const
inline

Definition at line 163 of file TrackPanel.h.

163{ return mTracks.get(); }

Referenced by DrawTracks(), GetSelectedTrackCount(), ProcessUIHandleResult(), UpdateVRulers(), and UpdateVRulerSize().

Here is the caller graph for this function:

◆ GetViewInfo()

ViewInfo * TrackPanel::GetViewInfo ( )
inline

Definition at line 165 of file TrackPanel.h.

165{ return mViewInfo;}

References CellularPanel::mViewInfo.

◆ HandlePageDownKey()

void TrackPanel::HandlePageDownKey ( )

Definition at line 623 of file TrackPanel.cpp.

624{
627}
void SetHorizontalThumb(double scrollto, bool doScroll=true)
Definition: Viewport.cpp:201
double GetScreenEndTime() const
Definition: ZoomInfo.h:107

References Viewport::Get(), GetProject(), ZoomInfo::GetScreenEndTime(), CellularPanel::mViewInfo, and Viewport::SetHorizontalThumb().

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

618{
621}
double hpos
Leftmost visible timeline position in seconds.
Definition: ZoomInfo.h:54

References Viewport::Get(), GetProject(), ZoomInfo::GetScreenEndTime(), ZoomInfo::hpos, CellularPanel::mViewInfo, and Viewport::SetHorizontalThumb().

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

630{
632 return ProjectAudioIO::Get( *p ).IsAudioActive();
633}
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 532 of file TrackPanel.cpp.

533{
535}
void UpdateScrollbarsForTracks()
Definition: Viewport.cpp:250

References Viewport::Get(), GetProject(), and Viewport::UpdateScrollbarsForTracks().

Referenced by OnTrackListResizing().

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

◆ OnAudioIO()

void TrackPanel::OnAudioIO ( AudioIOEvent  evt)

Definition at line 825 of file TrackPanel.cpp.

826{
828 return;
829 // Some hit tests want to change their cursor to and from the ban symbol
831}
void HandleCursorForPresentMouseState(bool doHit=true)
void CallAfter(Action action)
Schedule an action to be done later, and in the main thread.
Definition: BasicUI.cpp:214
enum AudioIOEvent::Type type

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

Referenced by TrackPanel().

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

◆ OnIdle()

void TrackPanel::OnIdle ( wxIdleEvent &  event)

Definition at line 394 of file TrackPanel.cpp.

395{
396 event.Skip();
397 // The window must be ready when the timer fires (#1401)
398 if (IsShownOnScreen())
399 {
400 mTimer.Start(std::chrono::milliseconds{kTimerInterval}.count(), FALSE);
401
402 // Timer is started, we don't need the event anymore
403 GetProjectFrame( *GetProject() ).Unbind(wxEVT_IDLE,
404 &TrackPanel::OnIdle, this);
405 }
406 else
407 {
408 // Get another idle event, wx only guarantees we get one
409 // event after "some other normal events occur"
410 event.RequestMore();
411 }
412}
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 712 of file TrackPanel.cpp.

713{
714 switch (event.GetKeyCode())
715 {
716 // Allow PageUp and PageDown keys to
717 //scroll the Track Panel left and right
718 case WXK_PAGEUP:
720 return;
721
722 case WXK_PAGEDOWN:
724 return;
725
726 default:
727 // fall through to base class handler
728 event.Skip();
729 }
730}
void HandlePageUpKey()
Definition: TrackPanel.cpp:617
void HandlePageDownKey()
Definition: TrackPanel.cpp:623

References HandlePageDownKey(), and HandlePageUpKey().

Here is the call graph for this function:

◆ OnMouseEvent()

void TrackPanel::OnMouseEvent ( wxMouseEvent &  event)

Definition at line 732 of file TrackPanel.cpp.

733{
734 if (event.LeftDown()) {
735 // wxTimers seem to be a little unreliable, so this
736 // "primes" it to make sure it keeps going for a while...
737
738 // When this timer fires, we call TrackPanel::OnTimer and
739 // possibly update the screen for offscreen scrolling.
740 mTimer.Stop();
741 mTimer.Start(std::chrono::milliseconds{kTimerInterval}.count(), FALSE);
742 }
743
744
745 if (event.ButtonUp()) {
746 //ShowTrack should be called after processing the up-click.
747 this->CallAfter( [this, event]{
748 const auto foundCell = FindCell(event.m_x, event.m_y);
749 const auto t = FindTrack( foundCell.pCell.get() );
750 if (t) {
751 auto &focus = TrackFocus::Get(*GetProject());
752 focus.Set(t.get());
754 }
755 } );
756 }
757
758 // Must also fall through to base class handler
759 event.Skip();
760}
FoundCell FindCell(int mouseX, int mouseY)
void ShowTrack(const Track &track)
Definition: Viewport.cpp:460
std::shared_ptr< Track > FindTrack(TrackPanelCell *pCell)
Definition: TrackPanel.cpp:538

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

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

484{
485 // If the selected region changes - we must repaint the tracks, because the
486 // selection is baked into track image
488 {
489 mRefreshBacking = true;
491 }
492
493 auto sw =
495
496 {
497 wxPaintDC dc(this);
498
499 // Retrieve the damage rectangle
500 wxRect box = GetUpdateRegion().GetBox();
501
502 // Recreate the backing bitmap if we have a full refresh
503 // (See TrackPanel::Refresh())
504 if (mRefreshBacking || (box == GetRect()))
505 {
506 // Reset (should a mutex be used???)
507 mRefreshBacking = false;
508
509 // Redraw the backing bitmap
511
512 // Copy it to the display
513 DisplayBitmap(dc);
514 }
515 else
516 {
517 // Copy full, possibly clipped, damage rectangle
518 RepairBitmap(dc, box.x, box.y, box.width, box.height);
519 }
520
521 // Done with the clipped DC
522
523 // Drawing now goes directly to the client area.
524 // DrawOverlays() may need to draw outside the clipped region.
525 // (Used to make a NEW, separate wxClientDC, but that risks flashing
526 // problems on Mac.)
527 dc.DestroyClippingRegion();
528 DrawOverlays(true, &dc);
529 }
530}
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:220
void DrawTracks(wxDC *dc)
Definition: TrackPanel.cpp:838

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

387{
388 evt.Skip();
389 const auto &size = evt.GetSize();
390 mViewInfo->SetWidth( size.GetWidth() );
391 mViewInfo->SetHeight( size.GetHeight() );
392}
void SetHeight(int height)
Definition: ViewInfo.h:203
void SetWidth(int width)
Definition: ZoomInfo.h:89

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

469{
470 Refresh(false);
471}

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

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

References OverlayPanel::DrawOverlays(), AudioIO::Get(), ProjectAudioIO::Get(), Viewport::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  message)

Definition at line 1564 of file TrackPanel.cpp.

1565{
1566 if (message.focusPanel)
1567 SetFocus();
1568 if (auto cell = GetFocusedCell())
1569 Refresh(false);
1570}
std::shared_ptr< TrackPanelCell > GetFocusedCell() override
void SetFocus(const WindowPlacement &focus)
Set the window that accepts keyboard input.
Definition: BasicUI.h:392
bool focusPanel
whether to focus the window that shows tracks
Definition: TrackFocus.h:25

References TrackFocusChangeMessage::focusPanel, GetFocusedCell(), Refresh(), and BasicUI::SetFocus().

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

698{
699 // copy shared_ptr for safety, as in HandleClick
700 auto handle = Target();
701 if (handle) {
702 handle->OnProjectChange(GetProject());
703 }
704
705 // If the focused track disappeared but there are still other tracks,
706 // this reassigns focus.
707 TrackFocus( *GetProject() ).Get();
708
710}
static TrackFocus & Get(AudacityProject &project)
Definition: TrackFocus.cpp:132
void UpdateVRulerSize()
Definition: TrackPanel.cpp:995

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

685{
686 auto t = e.mpTrack.lock();
687 // A deleted track can trigger the event. In which case do nothing here.
688 // A deleted track can have a valid pointer but no owner, bug 2060
689 if( t && t->HasOwner() )
690 UpdateVRuler(t.get());
691
692 // fix for bug 2477
694}
void UpdateVRuler(Track *t)
Definition: TrackPanel.cpp:949
void MakeParentRedrawScrollbars()
Definition: TrackPanel.cpp:532

References MakeParentRedrawScrollbars(), TrackListEvent::mpTrack, and UpdateVRuler().

Here is the call graph for this function:

◆ OnTrackMenu()

void TrackPanel::OnTrackMenu ( Track t = NULL)

Definition at line 1017 of file TrackPanel.cpp.

1018{
1020 t ? ChannelView::Get(*t->GetChannel(0)).shared_from_this() : nullptr);
1021}
void DoContextMenu(std::shared_ptr< TrackPanelCell > pCell)
std::shared_ptr< ChannelType > GetChannel(size_t iChannel)
Retrieve a channel, cast to the given type.
Definition: Channel.h:323

References CellularPanel::DoContextMenu(), ChannelView::Get(), and ChannelGroup::GetChannel().

Here is the call graph for this function:

◆ OnUndoReset()

void TrackPanel::OnUndoReset ( struct UndoRedoMessage  message)

Definition at line 473 of file TrackPanel.cpp.

474{
475 if (message.type == UndoRedoMessage::Reset) {
476 TrackFocus::Get( *GetProject() ).Set( nullptr );
477 Refresh( false );
478 }
479}
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 549 of file TrackPanel.cpp.

552{
553 const auto panel = this;
554 auto pLatestTrack = FindTrack( pLatestCell ).get();
555
556 // This precaution checks that the track is not only nonnull, but also
557 // really owned by the track list
558 auto pClickedTrack = GetTracks()->Lock(
559 std::weak_ptr<Track>{ FindTrack( pClickedCell ) }
560 ).get();
561
562 // TODO: make a finer distinction between refreshing the track control area,
563 // and the waveform area. As it is, redraw both whenever you must redraw either.
564
565 // Copy data from the underlying tracks to the pending tracks that are
566 // really displayed
567 PendingTracks::Get(*panel->GetProject()).UpdatePendingTracks();
568
569 using namespace RefreshCode;
570
571 if (refreshResult & DestroyedCell) {
572 panel->UpdateViewIfNoTracks();
573 // Beware stale pointer!
574 if (pLatestTrack == pClickedTrack)
575 pLatestTrack = nullptr;
576 pClickedTrack = nullptr;
577 }
578
579 if (pClickedTrack && (refreshResult & RefreshCode::UpdateVRuler))
580 panel->UpdateVRuler(pClickedTrack);
581
582 if (refreshResult & RefreshCode::DrawOverlays) {
583 panel->DrawOverlays(false);
584 mRuler->DrawOverlays(false);
585 }
586
587 // Refresh all if told to do so, or if told to refresh a track that
588 // is not known.
589 const bool refreshAll =
590 ( (refreshResult & RefreshAll)
591 || ((refreshResult & RefreshCell) && !pClickedTrack)
592 || ((refreshResult & RefreshLatestCell) && !pLatestTrack));
593
594 if (refreshAll)
595 panel->Refresh(false);
596 else {
597 if (refreshResult & RefreshCell)
598 panel->RefreshTrack(pClickedTrack);
599 if (refreshResult & RefreshLatestCell)
600 panel->RefreshTrack(pLatestTrack);
601 }
602
603 if (refreshResult & FixScrollbars)
604 panel->MakeParentRedrawScrollbars();
605
606 if (refreshResult & Resize)
608
609 if ((refreshResult & RefreshCode::EnsureVisible) && pClickedTrack) {
610 auto & focus = TrackFocus::Get(*GetProject());
611 focus.Set(pClickedTrack);
612 if (const auto pFocus = focus.Get())
614 }
615}
void UpdatePendingTracks()
std::shared_ptr< Subclass > Lock(const std::weak_ptr< Subclass > &wTrack)
Definition: Track.h:1079
void HandleResize()
Definition: Viewport.cpp:393
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(), RefreshCode::EnsureVisible, anonymous_namespace{TrackPanel.cpp}::FindTrack(), RefreshCode::FixScrollbars, TrackFocus::Get(), PendingTracks::Get(), Viewport::Get(), GetProject(), GetTracks(), Viewport::HandleResize(), TrackList::Lock(), mRuler, RefreshCode::RefreshAll, RefreshCode::RefreshCell, RefreshCode::RefreshLatestCell, RefreshCode::Resize, Viewport::ShowTrack(), PendingTracks::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 802 of file TrackPanel.cpp.

804{
805 // Tell OnPaint() to refresh the backing bitmap.
806 //
807 // Originally I had the check within the OnPaint() routine and it
808 // was working fine. That was until I found that, even though a full
809 // refresh was requested, Windows only set the onscreen portion of a
810 // window as damaged.
811 //
812 // So, if any part of the trackpanel was off the screen, full refreshes
813 // didn't work and the display got corrupted.
814 if( !rect || ( *rect == GetRect() ) )
815 {
816 mRefreshBacking = true;
817 }
818 wxWindow::Refresh(eraseBackground, rect);
819
820 CallAfter([this]{
821 if (GetProject())
823}

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

Referenced by OnSyncLockChange(), SelectHandle::TimerHandler::OnTimer(), OnTimer(), OnTrackFocusChange(), OnUndoReset(), RefreshTrack(), anonymous_namespace{ToolsToolBar.cpp}::SetTool(), TrackPanel(), UpdatePrefs(), UpdateSelectionDisplay(), and UpdateVRulerSize().

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

769{
770 if (!trk)
771 return;
772
773 auto height = ChannelView::GetChannelGroupHeight(trk);
774
775 // Set rectangle top according to the scrolling position, `vpos`
776 // Subtract the inset (above) and shadow (below) from the height of the
777 // rectangle, but not the border
778 // This matters because some separators do paint over the border
779 auto &view = ChannelView::Get(*trk->GetChannel(0));
780 const auto top =
781 -mViewInfo->vpos + view.GetCumulativeHeightBefore() + kTopInset;
782 height -= (kTopInset + kShadowThickness);
783
784 // Width also subtracts insets (left and right) plus shadow (right)
785 const auto left = kLeftInset;
786 const auto width = GetRect().GetWidth()
788
789 wxRect rect(left, top, width, height);
790
791 if( refreshbacking )
792 mRefreshBacking = true;
793
794 Refresh( false, &rect );
795}
@ kTopInset
@ kRightInset
Definition: ZoomInfo.h:26
@ kShadowThickness
Definition: ZoomInfo.h:23
@ kLeftInset
Definition: ZoomInfo.h:25
static int GetChannelGroupHeight(const Track *pTrack)
Definition: ChannelView.cpp:39
int vpos
Pixel distance from top of tracks to top of visible scrolled area.
Definition: ViewInfo.h:222

References ChannelView::Get(), ChannelGroup::GetChannel(), ChannelView::GetChannelGroupHeight(), kLeftInset, kRightInset, kShadowThickness, kTopInset, mRefreshBacking, CellularPanel::mViewInfo, Refresh(), and ViewInfo::vpos.

Referenced by MixerTrackCluster::HandleSliderGain(), MixerTrackCluster::HandleSliderPan(), MixerTrackCluster::HandleSliderVelocity(), MixerTrackCluster::OnButton_Mute(), anonymous_namespace{WaveTrackAffordanceControls.cpp}::OnEditClipName(), PitchAndSpeedDialog::SetSemitoneShift(), 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 1487 of file TrackPanel.cpp.

1488{
1489 // Root and other subgroup objects are throwaways.
1490 // They might instead be cached to avoid repeated allocation.
1491 // That cache would need invalidation when there is addition, deletion, or
1492 // permutation of tracks, or change of width of the vertical rulers.
1493 return std::make_shared< MainGroup >( *this );
1494}

◆ SetBackgroundCell()

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

Definition at line 884 of file TrackPanel.cpp.

886{
887 mpBackground = pCell;
888}

References mpBackground.

◆ SetFocusedCell()

void TrackPanel::SetFocusedCell ( )
overridevirtual

Implements CellularPanel.

Definition at line 1556 of file TrackPanel.cpp.

1557{
1558 // This may have a side-effect of assigning a focus if there was none
1559 auto& trackFocus = TrackFocus::Get(*GetProject());
1560 trackFocus.Set(trackFocus.Get());
1562}
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 361 of file TrackPanel.cpp.

362{
363 // All vertical rulers must be recalculated since the minimum and maximum
364 // frequencies may have been changed.
366
367 Refresh();
368}
void UpdateVRulers()
Definition: TrackPanel.cpp:941

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

645{
646 // Full refresh since the label area may need to indicate
647 // newly selected tracks.
648 Refresh(false);
649
650 // Make sure the ruler follows suit.
652}

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

636{
637 auto status = st;
638 if (HasEscape())
639 /* i18n-hint Esc is a key on the keyboard */
640 status.Join( XO("(Esc to cancel)"), " " );
641 ProjectStatus::Get( *GetProject() ).Set( status );
642}
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 957 of file TrackPanel.cpp.

958{
959 auto heights = FindAdjustedChannelHeights(t);
960
961 wxRect rect(mViewInfo->GetVRulerOffset(),
962 0,
964 0);
965
966 auto pHeight = heights.begin();
967 for (auto pChannel : t.Channels()) {
968 auto &view = ChannelView::Get(*pChannel);
969 const auto height = *pHeight++;
970 rect.SetHeight(height);
971 const auto subViews = view.GetSubViews(rect);
972 if (subViews.empty())
973 continue;
974
975 auto iter = subViews.begin(), end = subViews.end(), next = iter;
976 auto yy = iter->first;
977 wxSize vRulerSize{ 0, 0 };
978 auto &size = view.vrulerSize;
979 for (; iter != end; iter = next) {
980 ++next;
981 auto nextY = (next == end)
982 ? height
983 : next->first;
984 rect.SetHeight(nextY - yy);
985 // This causes ruler size in the track to be reassigned:
986 ChannelVRulerControls::Get(*iter->second).UpdateRuler(rect);
987 // But we want to know the maximum width and height over all sub-views:
988 vRulerSize.IncTo({ size.first, size.second });
989 yy = nextY;
990 }
991 size = { vRulerSize.x, vRulerSize.y };
992 }
993}
IteratorRange< ChannelIterator< ChannelType > > Channels()
Get range of channels with mutative access.
Definition: Channel.h:384
static ChannelVRulerControls & Get(ChannelView &)
virtual void UpdateRuler(const wxRect &rect)=0
int GetVRulerOffset() const
Definition: ZoomInfo.h:93
int GetVRulerWidth() const
Definition: ZoomInfo.h:91
std::vector< int > FindAdjustedChannelHeights(Track &t)
Definition: TrackPanel.cpp:896
const char * end(const char *str) noexcept
Definition: StringUtils.h:106

References ChannelGroup::Channels(), details::end(), anonymous_namespace{TrackPanel.cpp}::FindAdjustedChannelHeights(), ChannelView::Get(), ChannelVRulerControls::Get(), ZoomInfo::GetVRulerOffset(), ZoomInfo::GetVRulerWidth(), CellularPanel::mViewInfo, size, and ChannelVRulerControls::UpdateRuler().

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

661{
662 if (mTracks->empty())
663 {
664 // BG: There are no more tracks on screen
665 //BG: Set zoom to normal
667
668 //STM: Set selection to 0,0
669 //PRL: and default the rest of the selection information
671
672 // PRL: Following causes the time ruler to align 0 with left edge.
673 // Bug 972
674 mViewInfo->hpos = 0;
675
677 //STM: Clear message if all tracks are removed
679 }
680}
static double GetDefaultZoom()
Definition: ZoomInfo.h:116
void SetZoom(double pixelsPerSecond)
Definition: ZoomInfo.cpp:88

References ProjectStatus::Get(), Viewport::Get(), ZoomInfo::GetDefaultZoom(), GetProject(), Viewport::HandleResize(), ZoomInfo::hpos, mTracks, CellularPanel::mViewInfo, ViewInfo::selectedRegion, ProjectStatus::Set(), and ZoomInfo::SetZoom().

Here is the call graph for this function:

◆ UpdateVRuler()

void TrackPanel::UpdateVRuler ( Track t)

Definition at line 949 of file TrackPanel.cpp.

950{
951 if (t)
953
955}
void UpdateTrackVRuler(Track &t)
Definition: TrackPanel.cpp:957

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

942{
943 for (auto t : GetTracks()->Any<WaveTrack>())
945
947}

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

996{
997 auto trackRange = GetTracks()->Any();
998 if (trackRange) {
999 wxSize s{ 0, 0 };
1000 // Find maximum width over all channels
1001 for (auto t : trackRange)
1002 for (auto pChannel : t->Channels()) {
1003 const auto &size = ChannelView::Get(*pChannel).vrulerSize;
1004 s.IncTo({ size.first, size.second });
1005 }
1006
1007 if (mViewInfo->GetVRulerWidth() != s.GetWidth()) {
1008 mViewInfo->SetVRulerWidth(s.GetWidth());
1010 mViewInfo->GetLeftOffset()); // bevel on AdornedRuler
1011 mRuler->Refresh();
1012 }
1013 }
1014 Refresh(false);
1015}
void Refresh(bool eraseBackground=true, const wxRect *rect=(const wxRect *) NULL) override
void SetLeftOffset(int offset)
std::pair< int, int > vrulerSize
Definition: ChannelView.h:129
void SetVRulerWidth(int width)
Definition: ZoomInfo.h:92

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

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

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

Member Data Documentation

◆ mAudioIOSubscription

Observer::Subscription TrackPanel::mAudioIOSubscription
protected

Definition at line 182 of file TrackPanel.h.

Referenced by TrackPanel().

◆ mFocusChangeSubscription

Observer::Subscription TrackPanel::mFocusChangeSubscription
protected

Definition at line 184 of file TrackPanel.h.

Referenced by TrackPanel().

◆ mLastDrawnSelectedRegion

SelectedRegion TrackPanel::mLastDrawnSelectedRegion {}
protected

Definition at line 220 of file TrackPanel.h.

Referenced by OnPaint(), and OnTimer().

◆ mpBackground

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

Definition at line 224 of file TrackPanel.h.

Referenced by GetBackgroundCell(), and SetBackgroundCell().

◆ mProjectRulerInvalidatedSubscription

Observer::Subscription TrackPanel::mProjectRulerInvalidatedSubscription
protected

Definition at line 187 of file TrackPanel.h.

Referenced by TrackPanel().

◆ mRealtimeEffectManagerSubscription

Observer::Subscription TrackPanel::mRealtimeEffectManagerSubscription
protected

Definition at line 185 of file TrackPanel.h.

Referenced by TrackPanel().

◆ mRefreshBacking

bool TrackPanel::mRefreshBacking
protected

Definition at line 215 of file TrackPanel.h.

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

◆ mRuler

AdornedRulerPanel* TrackPanel::mRuler
protected

◆ mSelectionSubscription

Observer::Subscription TrackPanel::mSelectionSubscription
protected

Definition at line 188 of file TrackPanel.h.

Referenced by TrackPanel().

◆ mSyncLockSubscription

Observer::Subscription TrackPanel::mSyncLockSubscription
protected

Definition at line 186 of file TrackPanel.h.

Referenced by TrackPanel().

◆ mTimeCount

int TrackPanel::mTimeCount
protected

Definition at line 213 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 195 of file TrackPanel.h.

Referenced by DrawTracks(), and TrackPanel().

◆ mTrackListSubscription

Observer::Subscription TrackPanel::mTrackListSubscription
protected

Definition at line 181 of file TrackPanel.h.

Referenced by TrackPanel().

◆ mTracks

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

Definition at line 191 of file TrackPanel.h.

Referenced by UpdateViewIfNoTracks().

◆ mUndoSubscription

Observer::Subscription TrackPanel::mUndoSubscription
protected

Definition at line 183 of file TrackPanel.h.

Referenced by TrackPanel().


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