14#include "../../widgets/Overlay.h"
16#include "../../AdornedRulerPanel.h"
18#include "../../ProjectWindow.h"
19#include "../../ProjectWindows.h"
20#include "../../TrackPanel.h"
22#include <wx/dcclient.h>
23#include <wx/windowptr.h>
58 , mLastScrubSpeedText()
59 , mNextScrubSpeedText()
77 return std::make_pair(
92 static const wxFont labelFont(24, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
93 dc.SetFont(labelFont);
100 static const wxColour clrNoScroll(215, 162, 0), clrScroll(0, 204, 153);
102 dc.SetTextForeground(clrScroll);
104 dc.SetTextForeground(clrNoScroll);
114 auto position = ::wxGetMousePosition();
121 auto xx =
ruler.ScreenToClient(position).x;
122 ruler.UpdateQuickPlayPos( xx );
134 ruler.DrawBothOverlays();
143 int panelWidth, panelHeight;
144 trackPanel.GetSize(&panelWidth, &panelHeight);
147 position = trackPanel.ScreenToClient(position);
157 .PositionToTime(position.x, viewInfo.GetLeftOffset()))
170 wxCoord width, height;
172 wxClientDC dc( &trackPanel );
173 static const wxFont labelFont(24, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
174 dc.SetFont(labelFont);
178 std::max(0,
std::min(panelWidth - width, position.x - width / 2));
181 enum { offset = 20 };
182 auto yy = position.y - height + offset;
184 yy += height + 2 * offset;
185 yy = std::max(0,
std::min(panelHeight - height, yy));
203 auto result = std::make_shared< ScrubbingOverlay >( &parent );
215 :
public wxEvtHandler
223 mWindow->PushEventHandler(
this );
239 void OnMouse(wxMouseEvent &event);
240 DECLARE_EVENT_TABLE()
246 if ( !pScrubber || !
mRuler ) {
251 auto &scrubber = *pScrubber;
254 const auto &state = ::wxGetMouseState();
255 const auto &position = state.GetPosition();
256 scrubber.SetMayDragToSeek(
257 ruler.GetScreenRect().Contains(position) );
267 auto isScrubbing = scrubber.IsScrubbing();
268 if (isScrubbing && !event.HasAnyModifiers()) {
269 if(event.LeftDown() && scrubber.MayDragToSeek()) {
272 scrubber.SetSeekPress(
true );
274 else if (event.m_wheelRotation) {
275 double steps =
event.m_wheelRotation /
276 (
event.m_wheelDelta > 0 ? (double)event.m_wheelDelta : 120.0);
277 scrubber.HandleScrollWheel(steps);
292 return std::make_shared< ScrubForwarder >( parent );
Utility ClientData::Site to register hooks into a host class that attach client data.
AUDACITY_DLL_API wxWindow & GetProjectPanel(AudacityProject &project)
Get the main sub-window of the project frame that displays track data.
static const AudacityProject::AttachedObjects::RegisteredFactory sForwarderKey
static const AudacityProject::AttachedObjects::RegisteredFactory sOverlayKey
static AdornedRulerPanel & Get(AudacityProject &project)
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Client code makes static instance from a factory of attachments; passes it to Get or Find as a retrie...
Subscription Subscribe(Callback callback)
Connect a callback to the Publisher; later-connected are called earlier.
A move-only handle representing a connection to a Publisher.
void AddOverlay(const std::weak_ptr< Overlay > &pOverlay)
PlaybackScroller & GetPlaybackScroller()
static ProjectWindow & Get(AudacityProject &project)
bool ShouldDrawScrubSpeed()
bool IsKeyboardScrubbing() const
bool MaybeStartScrubbing(wxCoord xx)
double GetMaxScrubSpeed() const
bool IsScrollScrubbing() const
bool TemporarilySeeks() const
static Scrubber & Get(AudacityProject &project)
bool IsSpeedPlaying() const
double FindScrubSpeed(bool seeking, double time) const
ScrubbingOverlay(AudacityProject *project)
wxString mLastScrubSpeedText
wxString mNextScrubSpeedText
const Scrubber & GetScrubber() const
unsigned SequenceNumber() const override
This number determines an ordering of overlays, so that those with higher numbers overpaint those wit...
std::pair< wxRect, bool > DoGetRectangle(wxSize size) override
void OnTimer(Observer::Message)
AudacityProject * mProject
Observer::Subscription mSubscription
void Draw(OverlayPanel &panel, wxDC &dc) override
static TrackPanel & Get(AudacityProject &project)
static ViewInfo & Get(AudacityProject &project)
A convenient default parameter for class template Site.
Default message type for Publisher.
AudacityProject & mProject
wxWindowPtr< wxWindow > mWindow
wxWeakRef< AdornedRulerPanel > mRuler
std::weak_ptr< Scrubber > mScrubber
void OnMouse(wxMouseEvent &event)
ScrubForwarder(AudacityProject &project)