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

#include <Project.h>

Inheritance diagram for AudacityProject::PlaybackScroller:

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)
 

Private Member Functions

void OnTimer (wxCommandEvent &event)
 

Private Attributes

AudacityProjectmProject
 
Mode mMode { Mode::Off }
 

Detailed Description

Definition at line 808 of file Project.h.

Member Enumeration Documentation

Enumerator
Off 
Refresh 
Pinned 
Right 

Definition at line 813 of file Project.h.

813  {
814  Off,
815  Refresh,
816  Pinned,
817  Right,
818  };

Constructor & Destructor Documentation

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

Definition at line 6269 of file Project.cpp.

References mProject, and OnTimer().

6270 : mProject(project)
6271 {
6272  mProject->Bind(EVT_TRACK_PANEL_TIMER,
6274  this);
6275 }
AudacityProject * mProject
Definition: Project.h:829
void OnTimer(wxCommandEvent &event)
Definition: Project.cpp:6277

Member Function Documentation

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

Definition at line 821 of file Project.h.

Referenced by ControlToolBar::StartScrollingIfPreferred().

822  {
823  mMode = mode;
824  }
Mode AudacityProject::PlaybackScroller::GetMode ( ) const
inline

Definition at line 820 of file Project.h.

Referenced by PlayIndicatorOverlay::OnTimer().

820 { return mMode; }
void AudacityProject::PlaybackScroller::OnTimer ( wxCommandEvent &  event)
private

Definition at line 6277 of file Project.cpp.

References TracksPrefs::GetPinnedHeadPositionPreference(), TrackPanel::GetTracksUsableArea(), ZoomInfo::h, ViewInfo::mRecentStreamTime, ZoomInfo::OffsetTimeByPixels(), TrackPanel::Refresh(), and ZoomInfo::TimeToPosition().

Referenced by PlaybackScroller().

6278 {
6279  // Let other listeners get the notification
6280  event.Skip();
6281 
6282  if(!mProject->IsAudioActive())
6283  return;
6284  else if (mMode == Mode::Refresh) {
6285  // PRL: see comments in Scrubbing.cpp for why this is sometimes needed.
6286  // These unnecessary refreshes cause wheel rotation events to be delivered more uniformly
6287  // to the application, so scrub speed control is smoother.
6288  // (So I see at least with OS 10.10 and wxWidgets 3.0.2.)
6289  // Is there another way to ensure that than by refreshing?
6290  const auto trackPanel = mProject->GetTrackPanel();
6291  trackPanel->Refresh(false);
6292  }
6293  else if (mMode != Mode::Off) {
6294  // Pan the view, so that we put the play indicator at some fixed
6295  // fraction of the window width.
6296 
6297  ViewInfo &viewInfo = mProject->GetViewInfo();
6298  TrackPanel *const trackPanel = mProject->GetTrackPanel();
6299  const int posX = viewInfo.TimeToPosition(viewInfo.mRecentStreamTime);
6300  int width;
6301  trackPanel->GetTracksUsableArea(&width, NULL);
6302  int deltaX;
6303  switch (mMode)
6304  {
6305  default:
6306  wxASSERT(false);
6307  /* fallthru */
6308  case Mode::Pinned:
6309  deltaX =
6311  break;
6312  case Mode::Right:
6313  deltaX = posX - width; break;
6314  }
6315  viewInfo.h =
6316  viewInfo.OffsetTimeByPixels(viewInfo.h, deltaX, true);
6317  if (!mProject->MayScrollBeyondZero())
6318  // Can't scroll too far left
6319  viewInfo.h = std::max(0.0, viewInfo.h);
6320  trackPanel->Refresh(false);
6321  }
6322 }
ViewInfo is used mainly to hold the zooming, selection and scroll information. It also has some statu...
Definition: ViewInfo.h:141
double OffsetTimeByPixels(double time, wxInt64 offset, bool ignoreFisheye=false) const
Definition: ViewInfo.h:77
double h
Definition: ViewInfo.h:47
void GetTracksUsableArea(int *width, int *height) const
Definition: TrackPanel.cpp:414
The TrackPanel class coordinates updates and operations on the main part of the screen which contains...
Definition: TrackPanel.h:237
AudacityProject * mProject
Definition: Project.h:829
wxInt64 TimeToPosition(double time, wxInt64 origin=0, bool ignoreFisheye=false) const
STM: Converts a project time to screen x position.
Definition: ViewInfo.cpp:59
void Refresh(bool eraseBackground=true, const wxRect *rect=(const wxRect *) NULL) override
bool IsAudioActive() const
Definition: Project.cpp:1457
static double GetPinnedHeadPositionPreference()
bool MayScrollBeyondZero() const
Definition: Project.cpp:1802
double mRecentStreamTime
Definition: ViewInfo.h:189
TrackPanel * GetTrackPanel()
Definition: Project.h:307
const ViewInfo & GetViewInfo() const
Definition: Project.h:207

Member Data Documentation

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

Definition at line 830 of file Project.h.

AudacityProject* AudacityProject::PlaybackScroller::mProject
private

Definition at line 829 of file Project.h.

Referenced by PlaybackScroller().


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