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

257 : CellularPanel(parent, id, pos, size, viewInfo,
258 wxWANTS_CHARS | wxNO_BORDER),
259 mListener( &ProjectWindow::Get( *project ) ),
260 mTracks(tracks),
261 mRuler(ruler),
262 mTrackArtist(nullptr),
263 mRefreshBacking(false)
264#ifndef __WXGTK__ //Get rid if this pragma for gtk
265#pragma warning( default: 4355 )
266#endif
267{
268 SetLayoutDirection(wxLayout_LeftToRight);
269 SetLabel(XO("Track Panel"));
270 SetName(XO("Track Panel"));
271 SetBackgroundStyle(wxBG_STYLE_PAINT);
272
273 {
274 auto pAx = std::make_unique <TrackPanelAx>( *project );
275 pAx->SetWindow( this );
276 wxWeakRef< TrackPanel > weakThis{ this };
277 pAx->SetFinder(
278 [weakThis]( const Track &track ) -> wxRect {
279 if (weakThis)
280 return weakThis->FindTrackRect( &track );
281 return {};
282 }
283 );
284 TrackFocus::Get( *GetProject() ).SetAccessible(
285 *this, std::move( pAx ) );
286 }
287
288 mTrackArtist = std::make_unique<TrackArtist>( this );
289
290 mTimeCount = 0;
291 mTimer.parent = this;
292 // Timer is started after the window is visible
293 ProjectWindow::Get( *GetProject() ).Bind(wxEVT_IDLE,
294 &TrackPanel::OnIdle, this);
295
296 // Register for tracklist updates
298 mTracks->Subscribe([this](const TrackListEvent &event){
299 switch (event.mType) {
300 case TrackListEvent::RESIZING:
301 case TrackListEvent::ADDITION:
302 OnTrackListResizing(event); break;
303 case TrackListEvent::DELETION:
304 OnTrackListDeletion(); break;
305 case TrackListEvent::TRACK_REQUEST_VISIBLE:
306 OnEnsureVisible(event); break;
307 default:
308 break;
309 }
310 });
311
312 auto theProject = GetProject();
313 theProject->Bind(
314 EVT_PROJECT_SETTINGS_CHANGE, &TrackPanel::OnProjectSettingsChange, this);
315 theProject->Bind(
316 EVT_TRACK_FOCUS_CHANGE, &TrackPanel::OnTrackFocusChange, this );
317
320
323 UpdatePrefs();
324}
#define XO(s)
Definition: Internat.h:31
static AudioIO * Get()
Definition: AudioIO.cpp:140
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)
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:337
AdornedRulerPanel * mRuler
Definition: TrackPanel.h:196
TrackPanelListener * mListener
Definition: TrackPanel.h:192
std::shared_ptr< TrackList > mTracks
Definition: TrackPanel.h:194
void OnProjectSettingsChange(wxCommandEvent &event)
Definition: TrackPanel.cpp:443
Observer::Subscription mAudioIOSubscription
Definition: TrackPanel.h:189
AudacityProject * GetProject() const override
Definition: TrackPanel.cpp:348
Observer::Subscription mTrackListSubscription
Definition: TrackPanel.h:188
bool mRefreshBacking
Definition: TrackPanel.h:218
void OnTrackFocusChange(wxCommandEvent &event)
TrackPanel::AudacityTimer mTimer
void OnUndoReset(struct UndoRedoMessage)
Definition: TrackPanel.cpp:455
Observer::Subscription mUndoSubscription
Definition: TrackPanel.h:190
int mTimeCount
Definition: TrackPanel.h:216
void OnAudioIO(AudioIOEvent)
Definition: TrackPanel.cpp:802
void OnIdle(wxIdleEvent &event)
Definition: TrackPanel.cpp:370
std::unique_ptr< TrackArtist > mTrackArtist
Definition: TrackPanel.h:198
static UndoManager & Get(AudacityProject &project)
Definition: UndoManager.cpp:67
void SetLabel(const TranslatableString &label)
Notification of changes in individual tracks of TrackList, or of TrackList's composition.
Definition: Track.h:1282
const Type mType
Definition: Track.h:1317

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

328{
329 mTimer.Stop();
330
331 // This can happen if a label is being edited and the user presses
332 // ALT+F4 or Command+Q
333 if (HasCapture())
334 ReleaseMouse();
335}

References mTimer.

Member Function Documentation

◆ Destroy()

void TrackPanel::Destroy ( AudacityProject project)
static

Definition at line 237 of file TrackPanel.cpp.

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

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

Referenced by ProjectManager::OnCloseWindow().

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

◆ DrawTracks()

void TrackPanel::DrawTracks ( wxDC *  dc)
protected

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

Definition at line 815 of file TrackPanel.cpp.

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

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

References FindTrackRect(), kBottomMargin, and kTopMargin.

Referenced by ScreenshotCommand::GetTrackRect().

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

◆ FindRulerRects()

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

Definition at line 1691 of file TrackPanel.cpp.

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

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

Here is the call graph for this function:

◆ FindTrackRect()

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

Definition at line 1649 of file TrackPanel.cpp.

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

228{
229 return GetAttachedWindows(project).Get< TrackPanel >( sKey );
230}
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 232 of file TrackPanel.cpp.

233{
234 return Get( const_cast< AudacityProject & >( project ) );
235}
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:227

References Get().

Here is the call graph for this function:

◆ GetBackgroundCell()

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

Definition at line 865 of file TrackPanel.cpp.

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

References mpBackground.

Referenced by GetFocusedCell().

Here is the caller graph for this function:

◆ GetFocusedCell()

TrackPanelCell * TrackPanel::GetFocusedCell ( )
overridevirtual

Implements CellularPanel.

Definition at line 1703 of file TrackPanel.cpp.

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

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

Referenced by OnTrackFocusChange().

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

◆ GetListener()

TrackPanelListener * TrackPanel::GetListener ( )
inline

Definition at line 171 of file TrackPanel.h.

171{ return mListener;}

◆ GetMostRecentXPos()

double TrackPanel::GetMostRecentXPos ( )

Definition at line 737 of file TrackPanel.cpp.

738{
741}
wxCoord MostRecentXCoord() const
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 348 of file TrackPanel.cpp.

349{
350 auto window = GetParent();
351
352 while(window != nullptr)
353 {
354 if(const auto projectWindow = dynamic_cast<ProjectWindow*>(window))
355 return &projectWindow->GetProject();
356
357 window = window->GetParent();
358 }
359 return nullptr;
360}
A top-level window associated with a project, and handling scrollbars and zooming.
Definition: ProjectWindow.h:35

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

Here is the caller graph for this function:

◆ GetRuler()

AdornedRulerPanel * TrackPanel::GetRuler ( )
inline

Definition at line 172 of file TrackPanel.h.

172{ return mRuler;}

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

Here is the caller graph for this function:

◆ GetSelectedTrackCount()

size_t TrackPanel::GetSelectedTrackCount ( ) const

Definition at line 631 of file TrackPanel.cpp.

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

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

Here is the call graph for this function:

◆ GetTracks() [1/2]

TrackList * TrackPanel::GetTracks ( )
inline

Definition at line 169 of file TrackPanel.h.

169{ return mTracks.get(); }

◆ GetTracks() [2/2]

const TrackList * TrackPanel::GetTracks ( ) const
inline

Definition at line 168 of file TrackPanel.h.

168{ return mTracks.get(); }

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

Here is the caller graph for this function:

◆ GetViewInfo()

ViewInfo * TrackPanel::GetViewInfo ( )
inline

Definition at line 170 of file TrackPanel.h.

170{ return mViewInfo;}

References CellularPanel::mViewInfo.

◆ HandlePageDownKey()

void TrackPanel::HandlePageDownKey ( )

Definition at line 600 of file TrackPanel.cpp.

601{
603}
virtual void TP_ScrollWindow(double scrollto)=0
double GetScreenEndTime() const
Definition: ZoomInfo.h: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 595 of file TrackPanel.cpp.

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

Referenced by OnKeyDown().

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

◆ IsAudioActive()

bool TrackPanel::IsAudioActive ( )
protected

Definition at line 605 of file TrackPanel.cpp.

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

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

Referenced by OnTimer().

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

◆ MakeParentRedrawScrollbars()

void TrackPanel::MakeParentRedrawScrollbars ( )

Definition at line 515 of file TrackPanel.cpp.

516{
518}
virtual void TP_RedrawScrollbars()=0

References mListener, and TrackPanelListener::TP_RedrawScrollbars().

Here is the call graph for this function:

◆ OnAudioIO()

void TrackPanel::OnAudioIO ( AudioIOEvent  evt)

Definition at line 802 of file TrackPanel.cpp.

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

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

Referenced by TrackPanel().

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

◆ OnEnsureVisible()

void TrackPanel::OnEnsureVisible ( const TrackListEvent event)

Definition at line 997 of file TrackPanel.cpp.

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

371{
372 event.Skip();
373 // The window must be ready when the timer fires (#1401)
374 if (IsShownOnScreen())
375 {
376 mTimer.Start(std::chrono::milliseconds{kTimerInterval}.count(), FALSE);
377
378 // Timer is started, we don't need the event anymore
379 GetProjectFrame( *GetProject() ).Unbind(wxEVT_IDLE,
380 &TrackPanel::OnIdle, this);
381 }
382 else
383 {
384 // Get another idle event, wx only guarantees we get one
385 // event after "some other normal events occur"
386 event.RequestMore();
387 }
388}
AUDACITY_DLL_API wxFrame & GetProjectFrame(AudacityProject &project)
Get the top-level window associated with the project (as a wxFrame only, when you do not need to use ...
constexpr auto kTimerInterval

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

Referenced by OnIdle(), and TrackPanel().

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

◆ OnKeyDown()

void TrackPanel::OnKeyDown ( wxKeyEvent &  event)

Definition at line 688 of file TrackPanel.cpp.

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

References HandlePageDownKey(), and HandlePageUpKey().

Here is the call graph for this function:

◆ OnMouseEvent()

void TrackPanel::OnMouseEvent ( wxMouseEvent &  event)

Definition at line 708 of file TrackPanel.cpp.

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

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

Here is the call graph for this function:

◆ OnPaint()

void TrackPanel::OnPaint ( wxPaintEvent &  event)

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

Definition at line 465 of file TrackPanel.cpp.

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

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

Here is the call graph for this function:

◆ OnProjectSettingsChange()

void TrackPanel::OnProjectSettingsChange ( wxCommandEvent &  event)

Definition at line 443 of file TrackPanel.cpp.

444{
445 event.Skip();
446 switch ( static_cast<ProjectSettings::EventCode>( event.GetInt() ) ) {
448 Refresh(false);
449 break;
450 default:
451 break;
452 }
453}

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

363{
364 evt.Skip();
365 const auto &size = evt.GetSize();
366 mViewInfo->SetWidth( size.GetWidth() );
367 mViewInfo->SetHeight( size.GetHeight() );
368}
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 391 of file TrackPanel.cpp.

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

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

Here is the call graph for this function:

◆ OnTrackFocusChange()

void TrackPanel::OnTrackFocusChange ( wxCommandEvent &  event)

Definition at line 1717 of file TrackPanel.cpp.

1718{
1719 event.Skip();
1720 auto cell = GetFocusedCell();
1721
1722 if (cell) {
1723 Refresh( false );
1724 }
1725}
TrackPanelCell * GetFocusedCell() override

References GetFocusedCell(), and Refresh().

Referenced by TrackPanel().

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

◆ OnTrackListDeletion()

void TrackPanel::OnTrackListDeletion ( )

Definition at line 673 of file TrackPanel.cpp.

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

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

Here is the call graph for this function:

◆ OnTrackListResizing()

void TrackPanel::OnTrackListResizing ( const TrackListEvent event)

Definition at line 660 of file TrackPanel.cpp.

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

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

Here is the call graph for this function:

◆ OnTrackMenu()

void TrackPanel::OnTrackMenu ( Track t = NULL)

Definition at line 991 of file TrackPanel.cpp.

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

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

Here is the call graph for this function:

◆ OnUndoReset()

void TrackPanel::OnUndoReset ( struct UndoRedoMessage  message)

Definition at line 455 of file TrackPanel.cpp.

456{
457 if (message.type == UndoRedoMessage::Reset) {
458 TrackFocus::Get( *GetProject() ).Set( nullptr );
459 Refresh( false );
460 }
461}
enum UndoRedoMessage::Type type

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

Referenced by TrackPanel().

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

◆ ProcessUIHandleResult()

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

Implements CellularPanel.

Definition at line 529 of file TrackPanel.cpp.

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

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

Here is the call graph for this function:

◆ Refresh()

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

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

Definition at line 781 of file TrackPanel.cpp.

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

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

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

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

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

◆ Root()

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

Implements CellularPanel.

Definition at line 1637 of file TrackPanel.cpp.

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

◆ SetBackgroundCell()

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

Definition at line 859 of file TrackPanel.cpp.

861{
862 mpBackground = pCell;
863}

References mpBackground.

◆ SetFocusedCell()

void TrackPanel::SetFocusedCell ( )
overridevirtual

Implements CellularPanel.

Definition at line 1709 of file TrackPanel.cpp.

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

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

Here is the call graph for this function:

◆ UpdatePrefs()

void TrackPanel::UpdatePrefs ( )
overridevirtual

Implements PrefsListener.

Definition at line 337 of file TrackPanel.cpp.

338{
339 // All vertical rulers must be recalculated since the minimum and maximum
340 // frequencies may have been changed.
342
343 Refresh();
344}
void UpdateVRulers()
Definition: TrackPanel.cpp:916

References Refresh(), and UpdateVRulers().

Referenced by TrackPanel().

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

◆ UpdateSelectionDisplay()

void TrackPanel::UpdateSelectionDisplay ( )
protected

Definition at line 620 of file TrackPanel.cpp.

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

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

Referenced by OnTimer().

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

◆ UpdateStatusMessage()

void TrackPanel::UpdateStatusMessage ( const TranslatableString status)
overrideprotectedvirtual

Implements CellularPanel.

Definition at line 611 of file TrackPanel.cpp.

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

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

Here is the call graph for this function:

◆ UpdateTrackVRuler()

void TrackPanel::UpdateTrackVRuler ( Track t)

Definition at line 932 of file TrackPanel.cpp.

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

References TrackList::Channels(), PackedArray::end(), anonymous_namespace{TrackPanel.cpp}::FindAdjustedChannelHeights(), TrackView::Get(), TrackVRulerControls::Get(), ZoomInfo::GetVRulerOffset(), ZoomInfo::GetVRulerWidth(), CellularPanel::mViewInfo, TrackVRulerControls::UpdateRuler(), and Track::vrulerSize.

Referenced by UpdateVRuler(), and UpdateVRulers().

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

◆ UpdateViewIfNoTracks()

void TrackPanel::UpdateViewIfNoTracks ( )

Definition at line 636 of file TrackPanel.cpp.

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

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

References UpdateTrackVRuler(), and UpdateVRulerSize().

Referenced by OnTrackListResizing().

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

◆ UpdateVRulers()

void TrackPanel::UpdateVRulers ( )

Definition at line 916 of file TrackPanel.cpp.

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

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

Referenced by UpdatePrefs().

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

◆ UpdateVRulerSize()

void TrackPanel::UpdateVRulerSize ( )

Definition at line 973 of file TrackPanel.cpp.

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

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

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

Here is the call graph for this function:

Member Data Documentation

◆ mAudioIOSubscription

Observer::Subscription TrackPanel::mAudioIOSubscription
protected

Definition at line 188 of file TrackPanel.h.

Referenced by TrackPanel().

◆ mLastDrawnSelectedRegion

SelectedRegion TrackPanel::mLastDrawnSelectedRegion {}
protected

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

Referenced by GetBackgroundCell(), and SetBackgroundCell().

◆ mRefreshBacking

bool TrackPanel::mRefreshBacking
protected

Definition at line 218 of file TrackPanel.h.

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

◆ mRuler

AdornedRulerPanel* TrackPanel::mRuler
protected

◆ mTimeCount

int TrackPanel::mTimeCount
protected

Definition at line 216 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 198 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 194 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: