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)
 
 ~PlaybackScroller ()
 
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 789 of file Project.h.

Member Enumeration Documentation

Enumerator
Off 
Refresh 
Centered 
Right 

Definition at line 795 of file Project.h.

795  {
796  Off,
797  Refresh,
798  Centered,
799  Right,
800  };

Constructor & Destructor Documentation

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

Definition at line 6002 of file Project.cpp.

References mProject, and OnTimer().

6003 : mProject(project)
6004 {
6005  mProject->Connect(EVT_TRACK_PANEL_TIMER,
6006  wxCommandEventHandler(PlaybackScroller::OnTimer),
6007  NULL,
6008  this);
6009 }
AudacityProject * mProject
Definition: Project.h:811
void OnTimer(wxCommandEvent &event)
Definition: Project.cpp:6019
AudacityProject::PlaybackScroller::~PlaybackScroller ( )

Definition at line 6011 of file Project.cpp.

References OnTimer().

6012 {
6013  mProject->Disconnect(EVT_TRACK_PANEL_TIMER,
6014  wxCommandEventHandler(PlaybackScroller::OnTimer),
6015  NULL,
6016  this);
6017 }
AudacityProject * mProject
Definition: Project.h:811
void OnTimer(wxCommandEvent &event)
Definition: Project.cpp:6019

Member Function Documentation

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

Definition at line 803 of file Project.h.

Referenced by ControlToolBar::StartScrollingIfPreferred().

804  {
805  mMode = mode;
806  }
Mode AudacityProject::PlaybackScroller::GetMode ( ) const
inline

Definition at line 802 of file Project.h.

Referenced by PlayIndicatorOverlay::OnTimer().

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

Definition at line 6019 of file Project.cpp.

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

Referenced by PlaybackScroller(), and ~PlaybackScroller().

6020 {
6021  // Let other listeners get the notification
6022  event.Skip();
6023 
6024  if(!mProject->IsAudioActive())
6025  return;
6026  else if (mMode == Mode::Refresh) {
6027  // PRL: see comments in Scrubbing.cpp for why this is sometimes needed.
6028  // These unnecessary refreshes cause wheel rotation events to be delivered more uniformly
6029  // to the application, so scrub speed control is smoother.
6030  // (So I see at least with OS 10.10 and wxWidgets 3.0.2.)
6031  // Is there another way to ensure that than by refreshing?
6032  const auto trackPanel = mProject->GetTrackPanel();
6033  trackPanel->Refresh(false);
6034  }
6035  else if (mMode != Mode::Off) {
6036  // Pan the view, so that we center the play indicator.
6037 
6038  ViewInfo &viewInfo = mProject->GetViewInfo();
6039  TrackPanel *const trackPanel = mProject->GetTrackPanel();
6040  const int posX = viewInfo.TimeToPosition(viewInfo.mRecentStreamTime);
6041  int width;
6042  trackPanel->GetTracksUsableArea(&width, NULL);
6043  int deltaX;
6044  switch (mMode)
6045  {
6046  default:
6047  wxASSERT(false);
6048  /* fallthru */
6049  case Mode::Centered:
6050  deltaX = posX - width / 2; break;
6051  case Mode::Right:
6052  deltaX = posX - width; break;
6053  }
6054  viewInfo.h =
6055  viewInfo.OffsetTimeByPixels(viewInfo.h, deltaX, true);
6056  if (!mProject->MayScrollBeyondZero())
6057  // Can't scroll too far left
6058  viewInfo.h = std::max(0.0, viewInfo.h);
6059  trackPanel->Refresh(false);
6060  }
6061 }
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:438
The TrackPanel class coordinates updates and operations on the main part of the screen which contains...
Definition: TrackPanel.h:257
AudacityProject * mProject
Definition: Project.h:811
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:1432
bool MayScrollBeyondZero() const
Definition: Project.cpp:1775
double mRecentStreamTime
Definition: ViewInfo.h:189
TrackPanel * GetTrackPanel()
Definition: Project.h:292
const ViewInfo & GetViewInfo() const
Definition: Project.h:192

Member Data Documentation

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

Definition at line 812 of file Project.h.

AudacityProject* AudacityProject::PlaybackScroller::mProject
private

Definition at line 811 of file Project.h.

Referenced by PlaybackScroller().


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