Audacity 3.2.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
ScrubbingOverlay Class Referencefinal
Inheritance diagram for ScrubbingOverlay:
[legend]
Collaboration diagram for ScrubbingOverlay:
[legend]

Public Member Functions

 ScrubbingOverlay (AudacityProject *project)
 
- Public Member Functions inherited from Overlay
 Overlay ()=default
 
 Overlay (const Overlay &)=delete
 
Overlayoperator= (const Overlay &)=delete
 
virtual ~Overlay ()=0
 
virtual unsigned SequenceNumber () const =0
 This number determines an ordering of overlays, so that those with higher numbers overpaint those with lower numbers that intersect. More...
 
std::pair< wxRect, bool > GetRectangle (wxSize size)
 
virtual std::pair< wxRect, bool > DoGetRectangle (wxSize size)=0
 
virtual void Erase (wxDC &dc, wxDC &src)
 
virtual void Draw (OverlayPanel &panel, wxDC &dc)=0
 
- Public Member Functions inherited from ClientData::Base
virtual ~Base ()
 

Private Member Functions

unsigned SequenceNumber () const override
 This number determines an ordering of overlays, so that those with higher numbers overpaint those with lower numbers that intersect. More...
 
std::pair< wxRect, bool > DoGetRectangle (wxSize size) override
 
void Draw (OverlayPanel &panel, wxDC &dc) override
 
void OnTimer (Observer::Message)
 
const ScrubberGetScrubber () const
 
ScrubberGetScrubber ()
 

Private Attributes

AudacityProjectmProject
 
Observer::Subscription mSubscription
 
wxRect mLastScrubRect
 
wxRect mNextScrubRect
 
wxString mLastScrubSpeedText
 
wxString mNextScrubSpeedText
 

Detailed Description

Definition at line 29 of file ScrubUI.cpp.

Constructor & Destructor Documentation

◆ ScrubbingOverlay()

ScrubbingOverlay::ScrubbingOverlay ( AudacityProject project)
explicit

Definition at line 54 of file ScrubUI.cpp.

60{
63}
const auto project
Subscription Subscribe(Callback callback)
Connect a callback to the Publisher; later-connected are called earlier.
Definition: Observer.h:199
PlaybackScroller & GetPlaybackScroller()
static ProjectWindow & Get(AudacityProject &project)
wxString mLastScrubSpeedText
Definition: ScrubUI.cpp:51
wxString mNextScrubSpeedText
Definition: ScrubUI.cpp:51
void OnTimer(Observer::Message)
Definition: ScrubUI.cpp:109
AudacityProject * mProject
Definition: ScrubUI.cpp:47
Observer::Subscription mSubscription
Definition: ScrubUI.cpp:48
wxRect mNextScrubRect
Definition: ScrubUI.cpp:50
wxRect mLastScrubRect
Definition: ScrubUI.cpp:50

References ProjectWindow::Get(), ProjectWindow::GetPlaybackScroller(), mSubscription, OnTimer(), and Observer::Publisher< Message, NotifyAll >::Subscribe().

Here is the call graph for this function:

Member Function Documentation

◆ DoGetRectangle()

std::pair< wxRect, bool > ScrubbingOverlay::DoGetRectangle ( wxSize  size)
overrideprivatevirtual

Implements Overlay.

Definition at line 70 of file ScrubUI.cpp.

71{
72 wxRect rect(mLastScrubRect);
73 const bool outdated =
75 (!mLastScrubRect.IsEmpty() && !GetScrubber().ShouldDrawScrubSpeed()) ||
77 return std::make_pair(
78 rect,
79 outdated
80 );
81}
bool ShouldDrawScrubSpeed()
Definition: Scrubbing.cpp:812
const Scrubber & GetScrubber() const
Definition: ScrubUI.cpp:191

References GetScrubber(), mLastScrubRect, mLastScrubSpeedText, mNextScrubRect, mNextScrubSpeedText, and Scrubber::ShouldDrawScrubSpeed().

Here is the call graph for this function:

◆ Draw()

void ScrubbingOverlay::Draw ( OverlayPanel panel,
wxDC &  dc 
)
overrideprivatevirtual

Implements Overlay.

Definition at line 83 of file ScrubUI.cpp.

84{
87
88 Scrubber &scrubber = GetScrubber();
89 if (!scrubber.ShouldDrawScrubSpeed())
90 return;
91
92 static const wxFont labelFont(24, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
93 dc.SetFont(labelFont);
94
95 // These two colors were previously saturated red and green. However
96 // we have a rule to try to only use red for reserved purposes of
97 // (a) Recording
98 // (b) Error alerts
99 // So they were changed to 'orange' and 'lime'.
100 static const wxColour clrNoScroll(215, 162, 0), clrScroll(0, 204, 153);
101 if (scrubber.IsScrollScrubbing())
102 dc.SetTextForeground(clrScroll);
103 else
104 dc.SetTextForeground(clrNoScroll);
105
106 dc.DrawText(mLastScrubSpeedText, mLastScrubRect.GetX(), mLastScrubRect.GetY());
107}
bool IsScrollScrubbing() const
Definition: Scrubbing.h:92

References GetScrubber(), Scrubber::IsScrollScrubbing(), mLastScrubRect, mLastScrubSpeedText, mNextScrubRect, mNextScrubSpeedText, and Scrubber::ShouldDrawScrubSpeed().

Here is the call graph for this function:

◆ GetScrubber() [1/2]

Scrubber & ScrubbingOverlay::GetScrubber ( )
private

Definition at line 196 of file ScrubUI.cpp.

197{
198 return Scrubber::Get( *mProject );
199}
static Scrubber & Get(AudacityProject &project)
Definition: Scrubbing.cpp:186

References Scrubber::Get(), and mProject.

Here is the call graph for this function:

◆ GetScrubber() [2/2]

const Scrubber & ScrubbingOverlay::GetScrubber ( ) const
private

Definition at line 191 of file ScrubUI.cpp.

192{
193 return Scrubber::Get( *mProject );
194}

References Scrubber::Get(), and mProject.

Referenced by DoGetRectangle(), Draw(), and OnTimer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnTimer()

void ScrubbingOverlay::OnTimer ( Observer::Message  )
private

Definition at line 109 of file ScrubUI.cpp.

110{
111 Scrubber &scrubber = GetScrubber();
112 const auto isScrubbing = scrubber.IsScrubbing();
114 auto position = ::wxGetMousePosition();
115
116 if (scrubber.IsSpeedPlaying() || scrubber.IsKeyboardScrubbing())
117 return;
118
119 {
120 if(scrubber.HasMark()) {
121 auto xx = ruler.ScreenToClient(position).x;
122 ruler.UpdateQuickPlayPos( xx );
123
124 if (!isScrubbing)
125 // Really start scrub if motion is far enough
126 scrubber.MaybeStartScrubbing(xx);
127 }
128
129 if (!isScrubbing) {
130 mNextScrubRect = wxRect();
131 return;
132 }
133 else
134 ruler.DrawBothOverlays();
135 }
136
137 if (!scrubber.ShouldDrawScrubSpeed()) {
138 mNextScrubRect = wxRect();
139 }
140 else {
141 auto &trackPanel = GetProjectPanel( *mProject );
142 auto &viewInfo = ViewInfo::Get( *mProject );
143 int panelWidth, panelHeight;
144 trackPanel.GetSize(&panelWidth, &panelHeight);
145
146 // Where's the mouse?
147 position = trackPanel.ScreenToClient(position);
148
149 const bool seeking = scrubber.Seeks() || scrubber.TemporarilySeeks();
150
151 // Find the text
152 const double maxScrubSpeed = GetScrubber().GetMaxScrubSpeed();
153 const double speed =
154 scrubber.IsScrollScrubbing()
155 ? scrubber.FindScrubSpeed( seeking,
157 .PositionToTime(position.x, viewInfo.GetLeftOffset()))
158 : maxScrubSpeed;
159
160 const wxChar *format =
161 scrubber.IsScrollScrubbing()
162 ? seeking
163 ? wxT("%+.2fX")
164 : wxT("%+.2f")
165 : wxT("%.2f");
166
167 mNextScrubSpeedText = wxString::Format(format, speed);
168
169 // Find the origin for drawing text
170 wxCoord width, height;
171 {
172 wxClientDC dc( &trackPanel );
173 static const wxFont labelFont(24, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
174 dc.SetFont(labelFont);
175 dc.GetTextExtent(mNextScrubSpeedText, &width, &height);
176 }
177 const auto xx =
178 std::max(0, std::min(panelWidth - width, position.x - width / 2));
179
180 // Put the text above the cursor, if it fits.
181 enum { offset = 20 };
182 auto yy = position.y - height + offset;
183 if (yy < 0)
184 yy += height + 2 * offset;
185 yy = std::max(0, std::min(panelHeight - height, yy));
186
187 mNextScrubRect = wxRect(xx, yy, width, height);
188 }
189}
wxT("CloseDown"))
int min(int a, int b)
AUDACITY_DLL_API wxWindow & GetProjectPanel(AudacityProject &project)
Get the main sub-window of the project frame that displays track data.
static AdornedRulerPanel & Get(AudacityProject &project)
bool IsKeyboardScrubbing() const
Definition: Scrubbing.h:80
bool Seeks() const
Definition: Scrubbing.cpp:800
bool MaybeStartScrubbing(wxCoord xx)
Definition: Scrubbing.cpp:349
double GetMaxScrubSpeed() const
Definition: Scrubbing.h:110
bool TemporarilySeeks() const
Definition: Scrubbing.cpp:794
bool IsScrubbing() const
Definition: Scrubbing.cpp:768
bool IsSpeedPlaying() const
Definition: Scrubbing.h:76
double FindScrubSpeed(bool seeking, double time) const
Definition: Scrubbing.cpp:823
bool HasMark() const
Definition: Scrubbing.h:88
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:235

References Scrubber::FindScrubSpeed(), anonymous_namespace{ExportPCM.cpp}::format, ViewInfo::Get(), AdornedRulerPanel::Get(), Scrubber::GetMaxScrubSpeed(), GetProjectPanel(), GetScrubber(), Scrubber::HasMark(), Scrubber::IsKeyboardScrubbing(), Scrubber::IsScrollScrubbing(), Scrubber::IsScrubbing(), Scrubber::IsSpeedPlaying(), Scrubber::MaybeStartScrubbing(), min(), mNextScrubRect, mNextScrubSpeedText, mProject, anonymous_namespace{TimeTrackVRulerControls.cpp}::ruler(), Scrubber::Seeks(), Scrubber::ShouldDrawScrubSpeed(), Scrubber::TemporarilySeeks(), and wxT().

Referenced by ScrubbingOverlay().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SequenceNumber()

unsigned ScrubbingOverlay::SequenceNumber ( ) const
overrideprivatevirtual

This number determines an ordering of overlays, so that those with higher numbers overpaint those with lower numbers that intersect.

Implements Overlay.

Definition at line 65 of file ScrubUI.cpp.

66{
67 return 40;
68}

Member Data Documentation

◆ mLastScrubRect

wxRect ScrubbingOverlay::mLastScrubRect
private

Definition at line 50 of file ScrubUI.cpp.

Referenced by DoGetRectangle(), and Draw().

◆ mLastScrubSpeedText

wxString ScrubbingOverlay::mLastScrubSpeedText
private

Definition at line 51 of file ScrubUI.cpp.

Referenced by DoGetRectangle(), and Draw().

◆ mNextScrubRect

wxRect ScrubbingOverlay::mNextScrubRect
private

Definition at line 50 of file ScrubUI.cpp.

Referenced by DoGetRectangle(), Draw(), and OnTimer().

◆ mNextScrubSpeedText

wxString ScrubbingOverlay::mNextScrubSpeedText
private

Definition at line 51 of file ScrubUI.cpp.

Referenced by DoGetRectangle(), Draw(), and OnTimer().

◆ mProject

AudacityProject* ScrubbingOverlay::mProject
private

Definition at line 47 of file ScrubUI.cpp.

Referenced by GetScrubber(), and OnTimer().

◆ mSubscription

Observer::Subscription ScrubbingOverlay::mSubscription
private

Definition at line 48 of file ScrubUI.cpp.

Referenced by ScrubbingOverlay().


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