Audacity  3.0.3
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
ProjectWindow::PlaybackScroller Class Referencefinal

#include <ProjectWindow.h>

Inheritance diagram for ProjectWindow::PlaybackScroller:
[legend]
Collaboration diagram for ProjectWindow::PlaybackScroller:
[legend]

Public Types

enum  Mode { Mode::Off, Mode::Refresh, Mode::Pinned, Mode::Right }
 

Public Member Functions

 PlaybackScroller (AudacityProject *project)
 
Mode GetMode () const
 
void Activate (Mode mode)
 
double GetRecentStreamTime () const
 

Private Member Functions

void OnTimer (wxCommandEvent &event)
 

Private Attributes

AudacityProjectmProject
 
Mode mMode { Mode::Off }
 
double mRecentStreamTime { -1.0 }
 

Detailed Description

Definition at line 60 of file ProjectWindow.h.

Member Enumeration Documentation

◆ Mode

Enumerator
Off 
Refresh 
Pinned 
Right 

Definition at line 65 of file ProjectWindow.h.

65  {
66  Off,
67  Refresh,
68  Pinned,
69  Right,
70  };

Constructor & Destructor Documentation

◆ PlaybackScroller()

ProjectWindow::PlaybackScroller::PlaybackScroller ( AudacityProject project)
explicit

Definition at line 1664 of file ProjectWindow.cpp.

1665 : mProject(project)
1666 {
1667  mProject->Bind(EVT_TRACK_PANEL_TIMER,
1669  this);
1670 }

References mProject, and OnTimer().

Here is the call graph for this function:

Member Function Documentation

◆ Activate()

void ProjectWindow::PlaybackScroller::Activate ( Mode  mode)
inline

Definition at line 73 of file ProjectWindow.h.

74  {
75  mMode = mode;
76  }

Referenced by ControlToolBar::StartScrolling(), ControlToolBar::StartScrollingIfPreferred(), and ControlToolBar::StopScrolling().

Here is the caller graph for this function:

◆ GetMode()

Mode ProjectWindow::PlaybackScroller::GetMode ( ) const
inline

Definition at line 72 of file ProjectWindow.h.

72 { return mMode; }

◆ GetRecentStreamTime()

double ProjectWindow::PlaybackScroller::GetRecentStreamTime ( ) const
inline

Definition at line 78 of file ProjectWindow.h.

78 { return mRecentStreamTime; }

◆ OnTimer()

void ProjectWindow::PlaybackScroller::OnTimer ( wxCommandEvent &  event)
private

Definition at line 1672 of file ProjectWindow.cpp.

1673 {
1674  // Let other listeners get the notification
1675  event.Skip();
1676 
1677  auto gAudioIO = AudioIO::Get();
1678  mRecentStreamTime = gAudioIO->GetStreamTime();
1679 
1680  auto cleanup = finally([&]{
1681  // Propagate the message to other listeners bound to this
1682  this->SafelyProcessEvent( event );
1683  });
1684 
1685  if(!ProjectAudioIO::Get( *mProject ).IsAudioActive())
1686  return;
1687  else if (mMode == Mode::Refresh) {
1688  // PRL: see comments in Scrubbing.cpp for why this is sometimes needed.
1689  // These unnecessary refreshes cause wheel rotation events to be delivered more uniformly
1690  // to the application, so scrub speed control is smoother.
1691  // (So I see at least with OS 10.10 and wxWidgets 3.0.2.)
1692  // Is there another way to ensure that than by refreshing?
1693  auto &trackPanel = GetProjectPanel( *mProject );
1694  trackPanel.Refresh(false);
1695  }
1696  else if (mMode != Mode::Off) {
1697  // Pan the view, so that we put the play indicator at some fixed
1698  // fraction of the window width.
1699 
1700  auto &viewInfo = ViewInfo::Get( *mProject );
1701  auto &trackPanel = GetProjectPanel( *mProject );
1702  const int posX = viewInfo.TimeToPosition(mRecentStreamTime);
1703  auto width = viewInfo.GetTracksUsableWidth();
1704  int deltaX;
1705  switch (mMode)
1706  {
1707  default:
1708  wxASSERT(false);
1709  /* fallthru */
1710  case Mode::Pinned:
1711  deltaX =
1713  break;
1714  case Mode::Right:
1715  deltaX = posX - width; break;
1716  }
1717  viewInfo.h =
1718  viewInfo.OffsetTimeByPixels(viewInfo.h, deltaX, true);
1719  if (!ProjectWindow::Get( *mProject ).MayScrollBeyondZero())
1720  // Can't scroll too far left
1721  viewInfo.h = std::max(0.0, viewInfo.h);
1722  trackPanel.Refresh(false);
1723  }
1724 }

References AudioIO::Get(), ViewInfo::Get(), ProjectAudioIO::Get(), ProjectWindow::Get(), TracksPrefs::GetPinnedHeadPositionPreference(), GetProjectPanel(), ProjectAudioIO::IsAudioActive(), ProjectWindow::MayScrollBeyondZero(), and ProjectWindowBase::mProject.

Referenced by PlaybackScroller().

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

Member Data Documentation

◆ mMode

Mode ProjectWindow::PlaybackScroller::mMode { Mode::Off }
private

Definition at line 84 of file ProjectWindow.h.

◆ mProject

AudacityProject* ProjectWindow::PlaybackScroller::mProject
private

Definition at line 83 of file ProjectWindow.h.

Referenced by PlaybackScroller().

◆ mRecentStreamTime

double ProjectWindow::PlaybackScroller::mRecentStreamTime { -1.0 }
private

Definition at line 88 of file ProjectWindow.h.


The documentation for this class was generated from the following files:
ViewInfo::Get
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:259
ProjectWindow::PlaybackScroller::mProject
AudacityProject * mProject
Definition: ProjectWindow.h:83
ProjectWindow::PlaybackScroller::Mode::Off
@ Off
ProjectWindow::PlaybackScroller::mRecentStreamTime
double mRecentStreamTime
Definition: ProjectWindow.h:88
ProjectWindow::Get
static ProjectWindow & Get(AudacityProject &project)
Definition: ProjectWindow.cpp:535
ProjectAudioIO::Get
static ProjectAudioIO & Get(AudacityProject &project)
Definition: ProjectAudioIO.cpp:22
ProjectAudioIO::IsAudioActive
bool IsAudioActive() const
Definition: ProjectAudioIO.cpp:51
TracksPrefs::GetPinnedHeadPositionPreference
static double GetPinnedHeadPositionPreference()
Definition: TracksPrefs.cpp:406
ProjectWindow::PlaybackScroller::Mode::Right
@ Right
ProjectWindow::PlaybackScroller::Mode::Pinned
@ Pinned
ProjectWindow::PlaybackScroller::OnTimer
void OnTimer(wxCommandEvent &event)
Definition: ProjectWindow.cpp:1672
ProjectWindow::MayScrollBeyondZero
bool MayScrollBeyondZero() const
Definition: ProjectWindow.cpp:902
ProjectWindow::PlaybackScroller::mMode
Mode mMode
Definition: ProjectWindow.h:84
ProjectWindow::PlaybackScroller::Mode::Refresh
@ Refresh
GetProjectPanel
AUDACITY_DLL_API wxWindow & GetProjectPanel(AudacityProject &project)
Get the main sub-window of the project frame that displays track data.
Definition: ProjectWindows.cpp:49
AudioIO::Get
static AudioIO * Get()
Definition: AudioIO.cpp:142