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

1168{
1169}
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 1171 of file ProjectWindow.cpp.

1172{
1173 auto gAudioIO = AudioIO::Get();
1174 mRecentStreamTime = gAudioIO->GetStreamTime();
1175
1176 auto cleanup = finally([&]{
1177 // Propagate the message to other listeners bound to this
1178 this->Publish({});
1179 });
1180
1181 if(!ProjectAudioIO::Get( *mProject ).IsAudioActive())
1182 return;
1183 else if (mMode == Mode::Refresh) {
1184 // PRL: see comments in Scrubbing.cpp for why this is sometimes needed.
1185 // These unnecessary refreshes cause wheel rotation events to be delivered more uniformly
1186 // to the application, so scrub speed control is smoother.
1187 // (So I see at least with OS 10.10 and wxWidgets 3.0.2.)
1188 // Is there another way to ensure that than by refreshing?
1189 auto &trackPanel = GetProjectPanel( *mProject );
1190 trackPanel.Refresh(false);
1191 }
1192 else if (mMode != Mode::Off) {
1193 // Pan the view, so that we put the play indicator at some fixed
1194 // fraction of the window width.
1195
1196 auto &viewInfo = ViewInfo::Get( *mProject );
1197 auto &trackPanel = GetProjectPanel( *mProject );
1198 const int posX = viewInfo.TimeToPosition(mRecentStreamTime);
1199 auto width = viewInfo.GetTracksUsableWidth();
1200 int deltaX;
1201 switch (mMode)
1202 {
1203 default:
1204 wxASSERT(false);
1205 /* fallthru */
1206 case Mode::Pinned:
1207 deltaX =
1209 break;
1210 case Mode::Right:
1211 deltaX = posX - width; break;
1212 }
1213 viewInfo.hpos =
1214 viewInfo.OffsetTimeByPixels(viewInfo.hpos, deltaX, true);
1215 // Can't scroll too far left
1216 viewInfo.hpos = std::max(0.0, viewInfo.hpos);
1217 trackPanel.Refresh(false);
1218 }
1219}
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: