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

Public Member Functions

 TimerHandler (SelectHandle *pParent, AudacityProject *pProject)
 
void OnTimer (wxCommandEvent &event)
 

Private Attributes

SelectHandlemParent
 
AudacityProjectmConnectedProject
 

Detailed Description

Definition at line 1058 of file SelectHandle.cpp.

Constructor & Destructor Documentation

◆ TimerHandler()

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

Definition at line 1061 of file SelectHandle.cpp.

1062  : mParent{ pParent }
1063  , mConnectedProject{ pProject }
1064  {
1065  if (mConnectedProject)
1066  mConnectedProject->Bind(EVT_TRACK_PANEL_TIMER,
1068  this);
1069  }

Member Function Documentation

◆ OnTimer()

void SelectHandle::TimerHandler::OnTimer ( wxCommandEvent &  event)

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

Definition at line 1079 of file SelectHandle.cpp.

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

References ProjectWindow::Get(), TrackPanel::Get(), TrackView::Get(), TrackPanel::Refresh(), and size.

Here is the call graph for this function:

Member Data Documentation

◆ mConnectedProject

AudacityProject* SelectHandle::TimerHandler::mConnectedProject
private

Definition at line 1076 of file SelectHandle.cpp.

◆ mParent

SelectHandle* SelectHandle::TimerHandler::mParent
private

Definition at line 1075 of file SelectHandle.cpp.


The documentation for this class was generated from the following file:
size
size_t size
Definition: ffmpeg-2.3.6-single-header.h:412
SelectHandle::TimerHandler::mParent
SelectHandle * mParent
Definition: SelectHandle.cpp:1075
SelectHandle::TimerHandler::OnTimer
void OnTimer(wxCommandEvent &event)
Definition: SelectHandle.cpp:1079
TrackView::Get
static TrackView & Get(Track &)
Definition: TrackView.cpp:69
SelectHandle::mMostRecentX
int mMostRecentX
Definition: SelectHandle.h:165
SelectHandle::mAutoScrolling
bool mAutoScrolling
Definition: SelectHandle.h:167
TrackPanel::Get
static TrackPanel & Get(AudacityProject &project)
Definition: TrackPanel.cpp:227
ProjectWindow::Get
static ProjectWindow & Get(AudacityProject &project)
Definition: ProjectWindow.cpp:535
SelectHandle::FindTrack
std::weak_ptr< Track > FindTrack()
Definition: SelectHandle.cpp:1044
SelectHandle::TimerHandler::mConnectedProject
AudacityProject * mConnectedProject
Definition: SelectHandle.cpp:1076
SelectHandle::Drag
Result Drag(const TrackPanelMouseEvent &event, AudacityProject *pProject) override
Definition: SelectHandle.cpp:788
TrackPanel::Refresh
void Refresh(bool eraseBackground=true, const wxRect *rect=(const wxRect *) NULL) override
Definition: TrackPanel.cpp:793
TrackPanelMouseEvent
Definition: TrackPanelMouseEvent.h:46
SelectHandle::mRect
wxRect mRect
Definition: SelectHandle.h:132