Audacity 3.2.0
Public Types | Public 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 class  Mode { Off , Refresh , Pinned , Right }
 
- Public Types inherited from Observer::Publisher< PlaybackScrollerMessage >
using message_type = PlaybackScrollerMessage
 
using CallbackReturn = std::conditional_t< true, void, bool >
 
using Callback = std::function< CallbackReturn(const PlaybackScrollerMessage &) >
 Type of functions that can be connected to the Publisher. More...
 

Public Member Functions

 PlaybackScroller (AudacityProject *project)
 
Mode GetMode () const
 
void Activate (Mode mode)
 
double GetRecentStreamTime () const
 
void OnTimer ()
 
- Public Member Functions inherited from Observer::Publisher< PlaybackScrollerMessage >
 Publisher (ExceptionPolicy *pPolicy=nullptr, Alloc a={})
 Constructor supporting type-erased custom allocation/deletion. More...
 
 Publisher (Publisher &&)=default
 
Publisheroperator= (Publisher &&)=default
 
Subscription Subscribe (Callback callback)
 Connect a callback to the Publisher; later-connected are called earlier. More...
 
Subscription Subscribe (Object &obj, Return(Object::*callback)(Args...))
 Overload of Subscribe takes an object and pointer-to-member-function. More...
 

Private Attributes

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

Additional Inherited Members

- Static Public Attributes inherited from Observer::Publisher< PlaybackScrollerMessage >
static constexpr bool notifies_all
 
- Protected Member Functions inherited from Observer::Publisher< PlaybackScrollerMessage >
CallbackReturn Publish (const PlaybackScrollerMessage &message)
 Send a message to connected callbacks. More...
 

Detailed Description

Definition at line 80 of file ProjectWindow.h.

Member Enumeration Documentation

◆ Mode

Enumerator
Off 
Refresh 
Pinned 
Right 

Definition at line 86 of file ProjectWindow.h.

86 {
87 Off,
88 Refresh,
89 Pinned,
90 Right,
91 };

Constructor & Destructor Documentation

◆ PlaybackScroller()

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

Definition at line 1237 of file ProjectWindow.cpp.

1239{
1240}
const auto project

Member Function Documentation

◆ Activate()

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

Definition at line 94 of file ProjectWindow.h.

95 {
96 mMode = mode;
97 }

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 93 of file ProjectWindow.h.

93{ return mMode; }

◆ GetRecentStreamTime()

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

Definition at line 99 of file ProjectWindow.h.

◆ OnTimer()

void ProjectWindow::PlaybackScroller::OnTimer ( )

Definition at line 1242 of file ProjectWindow.cpp.

1243{
1244 auto gAudioIO = AudioIO::Get();
1245 mRecentStreamTime = gAudioIO->GetStreamTime();
1246
1247 auto cleanup = finally([&]{
1248 // Propagate the message to other listeners bound to this
1249 this->Publish({});
1250 });
1251
1252 if(!ProjectAudioIO::Get( *mProject ).IsAudioActive())
1253 return;
1254 else if (mMode == Mode::Refresh) {
1255 // PRL: see comments in Scrubbing.cpp for why this is sometimes needed.
1256 // These unnecessary refreshes cause wheel rotation events to be delivered more uniformly
1257 // to the application, so scrub speed control is smoother.
1258 // (So I see at least with OS 10.10 and wxWidgets 3.0.2.)
1259 // Is there another way to ensure that than by refreshing?
1260 auto &trackPanel = GetProjectPanel( *mProject );
1261 trackPanel.Refresh(false);
1262 }
1263 else if (mMode != Mode::Off) {
1264 // Pan the view, so that we put the play indicator at some fixed
1265 // fraction of the window width.
1266
1267 auto &viewInfo = ViewInfo::Get( *mProject );
1268 auto &trackPanel = GetProjectPanel( *mProject );
1269 const int posX = viewInfo.TimeToPosition(mRecentStreamTime);
1270 auto width = viewInfo.GetTracksUsableWidth();
1271 int deltaX;
1272 switch (mMode)
1273 {
1274 default:
1275 wxASSERT(false);
1276 /* fallthru */
1277 case Mode::Pinned:
1278 deltaX =
1280 break;
1281 case Mode::Right:
1282 deltaX = posX - width; break;
1283 }
1284 viewInfo.hpos =
1285 viewInfo.OffsetTimeByPixels(viewInfo.hpos, deltaX, true);
1286 // Can't scroll too far left
1287 viewInfo.hpos = std::max(0.0, viewInfo.hpos);
1288 trackPanel.Refresh(false);
1289 }
1290}
AUDACITY_DLL_API wxWindow & GetProjectPanel(AudacityProject &project)
Get the main sub-window of the project frame that displays track data.
static AudioIO * Get()
Definition: AudioIO.cpp:126
CallbackReturn Publish(const PlaybackScrollerMessage &message)
Send a message to connected callbacks.
Definition: Observer.h:207
bool IsAudioActive() const
static ProjectAudioIO & Get(AudacityProject &project)
static double GetPinnedHeadPositionPreference()
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:235

References AudioIO::Get(), ProjectAudioIO::Get(), ViewInfo::Get(), TracksPrefs::GetPinnedHeadPositionPreference(), GetProjectPanel(), ProjectAudioIO::IsAudioActive(), and Observer::Publisher< ProjectWindowDestroyedMessage >::Publish().

Here is the call graph for this function:

Member Data Documentation

◆ mMode

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

Definition at line 105 of file ProjectWindow.h.

◆ mProject

AudacityProject* ProjectWindow::PlaybackScroller::mProject
private

Definition at line 104 of file ProjectWindow.h.

◆ mRecentStreamTime

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

Definition at line 109 of file ProjectWindow.h.


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