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 1239 of file ProjectWindow.cpp.

1241{
1242}
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 1244 of file ProjectWindow.cpp.

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