MCPcopy Create free account
hub / github.com/audacity/audacity / OnTimer

Method OnTimer

src/tracks/ui/SelectHandle.cpp:1091–1160  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1089};
1090
1091void SelectHandle::TimerHandler::OnTimer(Observer::Message)
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
1096 /// We check on each timer tick to see if we need to scroll.
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.

Callers

nothing calls this directly

Calls 7

GetFunction · 0.85
OnScrollRightMethod · 0.80
OnScrollLeftMethod · 0.80
FindChannelMethod · 0.45
GetSizeMethod · 0.45
DragMethod · 0.45
RefreshMethod · 0.45

Tested by

no test coverage detected