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::Centered, 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 805 of file Project.h.

Member Enumeration Documentation

Enumerator
Off 
Refresh 
Centered 
Right 

Definition at line 810 of file Project.h.

810  {
811  Off,
812  Refresh,
813  Centered,
814  Right,
815  };

Constructor & Destructor Documentation

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

Definition at line 6110 of file Project.cpp.

References mProject, and OnTimer().

6111 : mProject(project)
6112 {
6113  mProject->Bind(EVT_TRACK_PANEL_TIMER,
6115  this);
6116 }
AudacityProject * mProject
Definition: Project.h:826
void OnTimer(wxCommandEvent &event)
Definition: Project.cpp:6118

Member Function Documentation

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

Definition at line 818 of file Project.h.

Referenced by ControlToolBar::StartScrollingIfPreferred().

819  {
820  mMode = mode;
821  }
Mode AudacityProject::PlaybackScroller::GetMode ( ) const
inline

Definition at line 817 of file Project.h.

Referenced by PlayIndicatorOverlay::OnTimer().

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

Definition at line 6118 of file Project.cpp.

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

Referenced by PlaybackScroller().

6119 {
6120  // Let other listeners get the notification
6121  event.Skip();
6122 
6123  if(!mProject->IsAudioActive())
6124  return;
6125  else if (mMode == Mode::Refresh) {
6126  // PRL: see comments in Scrubbing.cpp for why this is sometimes needed.
6127  // These unnecessary refreshes cause wheel rotation events to be delivered more uniformly
6128  // to the application, so scrub speed control is smoother.
6129  // (So I see at least with OS 10.10 and wxWidgets 3.0.2.)
6130  // Is there another way to ensure that than by refreshing?
6131  const auto trackPanel = mProject->GetTrackPanel();
6132  trackPanel->Refresh(false);
6133  }
6134  else if (mMode != Mode::Off) {
6135  // Pan the view, so that we center the play indicator.
6136 
6137  ViewInfo &viewInfo = mProject->GetViewInfo();
6138  TrackPanel *const trackPanel = mProject->GetTrackPanel();
6139  const int posX = viewInfo.TimeToPosition(viewInfo.mRecentStreamTime);
6140  int width;
6141  trackPanel->GetTracksUsableArea(&width, NULL);
6142  int deltaX;
6143  switch (mMode)
6144  {
6145  default:
6146  wxASSERT(false);
6147  /* fallthru */
6148  case Mode::Centered:
6149  deltaX = posX - width / 2; break;
6150  case Mode::Right:
6151  deltaX = posX - width; break;
6152  }
6153  viewInfo.h =
6154  viewInfo.OffsetTimeByPixels(viewInfo.h, deltaX, true);
6155  if (!mProject->MayScrollBeyondZero())
6156  // Can't scroll too far left
6157  viewInfo.h = std::max(0.0, viewInfo.h);
6158  trackPanel->Refresh(false);
6159  }
6160 }
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:421
The TrackPanel class coordinates updates and operations on the main part of the screen which contains...
Definition: TrackPanel.h:245
AudacityProject * mProject
Definition: Project.h:826
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:1447
bool MayScrollBeyondZero() const
Definition: Project.cpp:1792
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 827 of file Project.h.

AudacityProject* AudacityProject::PlaybackScroller::mProject
private

Definition at line 826 of file Project.h.

Referenced by PlaybackScroller().


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