Audacity 3.2.0
Public Member Functions | Private Attributes | List of all members
SelectHandle::TimerHandler Class Reference
Collaboration diagram for SelectHandle::TimerHandler:
[legend]

Public Member Functions

 TimerHandler (SelectHandle *pParent, AudacityProject *pProject)
 
void OnTimer (Observer::Message)
 

Private Attributes

SelectHandlemParent
 
AudacityProjectmConnectedProject
 
Observer::Subscription mSubscription
 

Detailed Description

Definition at line 1069 of file SelectHandle.cpp.

Constructor & Destructor Documentation

◆ TimerHandler()

SelectHandle::TimerHandler::TimerHandler ( SelectHandle pParent,
AudacityProject pProject 
)
inline

Definition at line 1072 of file SelectHandle.cpp.

1073 : mParent{ pParent }
1074 , mConnectedProject{ pProject }
1075 {
1079 }
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)
void OnTimer(Observer::Message)
AudacityProject * mConnectedProject
Observer::Subscription mSubscription

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

Here is the call graph for this function:

Member Function Documentation

◆ OnTimer()

void SelectHandle::TimerHandler::OnTimer ( Observer::Message  )

We check on each timer tick to see if we need to scroll.

Definition at line 1090 of file SelectHandle.cpp.

1091{
1092 // AS: If the user is dragging the mouse and there is a track that
1093 // has captured the mouse, then scroll the screen, as necessary.
1094
1096
1097 // DM: If we're "autoscrolling" (which means that we're scrolling
1098 // because the user dragged from inside to outside the window,
1099 // not because the user clicked in the scroll bar), then
1100 // the selection code needs to be handled slightly differently.
1101 // We set this flag ("mAutoScrolling") to tell the selecting
1102 // code that we didn't get here as a result of a mouse event,
1103 // and therefore it should ignore the event,
1104 // and instead use the last known mouse position. Setting
1105 // this flag also causes the Mac to redraw immediately rather
1106 // than waiting for the next update event; this makes scrolling
1107 // smoother on MacOS 9.
1108
1109 const auto project = mConnectedProject;
1110 const auto &trackPanel = TrackPanel::Get( *project );
1111 auto &viewport = Viewport::Get(*project);
1112 if (mParent->mMostRecentX >= mParent->mRect.x + mParent->mRect.width) {
1113 mParent->mAutoScrolling = true;
1114 viewport.OnScrollRight();
1115 }
1116 else if (mParent->mMostRecentX < mParent->mRect.x) {
1117 mParent->mAutoScrolling = true;
1118 viewport.OnScrollLeft();
1119 }
1120 else {
1121 // Bug1387: enable autoscroll during drag, if the pointer is at either
1122 // extreme x coordinate of the screen, even if that is still within the
1123 // track area.
1124
1125 int xx = mParent->mMostRecentX, yy = 0;
1126 trackPanel.ClientToScreen(&xx, &yy);
1127 if (xx == 0) {
1128 mParent->mAutoScrolling = true;
1129 viewport.OnScrollLeft();
1130 }
1131 else {
1132 int width, height;
1133 ::wxDisplaySize(&width, &height);
1134 if (xx == width - 1) {
1135 mParent->mAutoScrolling = true;
1136 viewport.OnScrollRight();
1137 }
1138 }
1139 }
1140
1141 auto pTrack = mParent->FindTrack().lock(); // TrackList::Lock() ?
1142 if (mParent->mAutoScrolling && pTrack) {
1143 // AS: To keep the selection working properly as we scroll,
1144 // we fake a mouse event (remember, this method is called
1145 // from a timer tick).
1146
1147 // AS: For some reason, GCC won't let us pass this directly.
1148 wxMouseEvent evt(wxEVT_MOTION);
1149 const auto size = trackPanel.GetSize();
1150 mParent->Drag(
1152 evt, mParent->mRect, size,
1153 ChannelView::Get(*pTrack->GetChannel(0)).shared_from_this() },
1154 project
1155 );
1156 mParent->mAutoScrolling = false;
1157 TrackPanel::Get( *mConnectedProject ).Refresh(false);
1158 }
1159}
const auto project
static ChannelView & Get(Channel &channel)
bool mAutoScrolling
Definition: SelectHandle.h:169
std::weak_ptr< Track > FindTrack()
Result Drag(const TrackPanelMouseEvent &event, AudacityProject *pProject) override
void Refresh(bool eraseBackground=true, const wxRect *rect=(const wxRect *) NULL) override
Definition: TrackPanel.cpp:801
static TrackPanel & Get(AudacityProject &project)
Definition: TrackPanel.cpp:233
static Viewport & Get(AudacityProject &project)
Definition: Viewport.cpp:32

References SelectHandle::Drag(), SelectHandle::FindTrack(), Viewport::Get(), TrackPanel::Get(), ChannelView::Get(), SelectHandle::mAutoScrolling, mConnectedProject, SelectHandle::mMostRecentX, mParent, SelectHandle::mRect, project, TrackPanel::Refresh(), and size.

Referenced by TimerHandler().

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

Member Data Documentation

◆ mConnectedProject

AudacityProject* SelectHandle::TimerHandler::mConnectedProject
private

Definition at line 1086 of file SelectHandle.cpp.

Referenced by OnTimer(), and TimerHandler().

◆ mParent

SelectHandle* SelectHandle::TimerHandler::mParent
private

Definition at line 1085 of file SelectHandle.cpp.

Referenced by OnTimer().

◆ mSubscription

Observer::Subscription SelectHandle::TimerHandler::mSubscription
private

Definition at line 1087 of file SelectHandle.cpp.

Referenced by TimerHandler().


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