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

Member Enumeration Documentation

◆ Mode

Enumerator
Off 
Refresh 
Pinned 
Right 

Definition at line 94 of file ProjectWindow.h.

94 {
95 Off,
96 Refresh,
97 Pinned,
98 Right,
99 };

Constructor & Destructor Documentation

◆ PlaybackScroller()

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

Definition at line 1782 of file ProjectWindow.cpp.

1783: mProject(project)
1784{
1785}

Member Function Documentation

◆ Activate()

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

Definition at line 102 of file ProjectWindow.h.

103 {
104 mMode = mode;
105 }

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

101{ return mMode; }

◆ GetRecentStreamTime()

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

Definition at line 107 of file ProjectWindow.h.

◆ OnTimer()

void ProjectWindow::PlaybackScroller::OnTimer ( )

Definition at line 1787 of file ProjectWindow.cpp.

1788{
1789 auto gAudioIO = AudioIO::Get();
1790 mRecentStreamTime = gAudioIO->GetStreamTime();
1791
1792 auto cleanup = finally([&]{
1793 // Propagate the message to other listeners bound to this
1794 this->Publish({});
1795 });
1796
1797 if(!ProjectAudioIO::Get( *mProject ).IsAudioActive())
1798 return;
1799 else if (mMode == Mode::Refresh) {
1800 // PRL: see comments in Scrubbing.cpp for why this is sometimes needed.
1801 // These unnecessary refreshes cause wheel rotation events to be delivered more uniformly
1802 // to the application, so scrub speed control is smoother.
1803 // (So I see at least with OS 10.10 and wxWidgets 3.0.2.)
1804 // Is there another way to ensure that than by refreshing?
1805 auto &trackPanel = GetProjectPanel( *mProject );
1806 trackPanel.Refresh(false);
1807 }
1808 else if (mMode != Mode::Off) {
1809 // Pan the view, so that we put the play indicator at some fixed
1810 // fraction of the window width.
1811
1812 auto &viewInfo = ViewInfo::Get( *mProject );
1813 auto &trackPanel = GetProjectPanel( *mProject );
1814 const int posX = viewInfo.TimeToPosition(mRecentStreamTime);
1815 auto width = viewInfo.GetTracksUsableWidth();
1816 int deltaX;
1817 switch (mMode)
1818 {
1819 default:
1820 wxASSERT(false);
1821 /* fallthru */
1822 case Mode::Pinned:
1823 deltaX =
1825 break;
1826 case Mode::Right:
1827 deltaX = posX - width; break;
1828 }
1829 viewInfo.h =
1830 viewInfo.OffsetTimeByPixels(viewInfo.h, deltaX, true);
1831 if (!ProjectWindow::Get( *mProject ).MayScrollBeyondZero())
1832 // Can't scroll too far left
1833 viewInfo.h = std::max(0.0, viewInfo.h);
1834 trackPanel.Refresh(false);
1835 }
1836}
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:133
CallbackReturn Publish(const PlaybackScrollerMessage &message)
Send a message to connected callbacks.
Definition: Observer.h:207
bool IsAudioActive() const
static ProjectAudioIO & Get(AudacityProject &project)
static ProjectWindow & Get(AudacityProject &project)
bool MayScrollBeyondZero() const
static double GetPinnedHeadPositionPreference()
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:235

References AudioIO::Get(), ViewInfo::Get(), ProjectAudioIO::Get(), ProjectWindow::Get(), TracksPrefs::GetPinnedHeadPositionPreference(), GetProjectPanel(), ProjectAudioIO::IsAudioActive(), ProjectWindow::MayScrollBeyondZero(), 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 113 of file ProjectWindow.h.

◆ mProject

AudacityProject* ProjectWindow::PlaybackScroller::mProject
private

Definition at line 112 of file ProjectWindow.h.

◆ mRecentStreamTime

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

Definition at line 117 of file ProjectWindow.h.


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