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 1070 of file SelectHandle.cpp.

Constructor & Destructor Documentation

◆ TimerHandler()

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

Definition at line 1073 of file SelectHandle.cpp.

1074 : mParent{ pParent }
1075 , mConnectedProject{ pProject }
1076 {
1080 }
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 1091 of file SelectHandle.cpp.

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

References SelectHandle::Drag(), SelectHandle::FindChannel(), 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 1087 of file SelectHandle.cpp.

Referenced by OnTimer(), and TimerHandler().

◆ mParent

SelectHandle* SelectHandle::TimerHandler::mParent
private

Definition at line 1086 of file SelectHandle.cpp.

Referenced by OnTimer().

◆ mSubscription

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

Definition at line 1088 of file SelectHandle.cpp.

Referenced by TimerHandler().


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