| 356 | } |
| 357 | |
| 358 | UIHandlePtr SelectHandle::HitTest |
| 359 | (std::weak_ptr<SelectHandle> &holder, |
| 360 | const TrackPanelMouseState &st, const AudacityProject *pProject, |
| 361 | const std::shared_ptr<ChannelView> &pChannelView) |
| 362 | { |
| 363 | // This handle is a little special because there may be some state to |
| 364 | // preserve during movement before the click. |
| 365 | auto old = holder.lock(); |
| 366 | bool oldUseSnap = true; |
| 367 | if (old) { |
| 368 | // It should not have started listening to timer events |
| 369 | if( old->mTimerHandler ) { |
| 370 | wxASSERT(false); |
| 371 | // Handle this eventuality anyway, don't leave a dangling back-pointer |
| 372 | // in the attached event handler. |
| 373 | old->mTimerHandler.reset(); |
| 374 | } |
| 375 | oldUseSnap = old->mUseSnap; |
| 376 | } |
| 377 | |
| 378 | const auto &viewInfo = ViewInfo::Get( *pProject ); |
| 379 | auto result = std::make_shared<SelectHandle>( |
| 380 | pChannelView, oldUseSnap, TrackList::Get(*pProject), st, viewInfo); |
| 381 | |
| 382 | result = AssignUIHandlePtr(holder, result); |
| 383 | |
| 384 | //Make sure we are within the selected track |
| 385 | auto pTrack = FindTrack(pChannelView->FindChannel().get()); |
| 386 | if (!pTrack->GetSelected()) |
| 387 | { |
| 388 | return result; |
| 389 | } |
| 390 | |
| 391 | { |
| 392 | const wxRect &rect = st.rect; |
| 393 | wxInt64 leftSel = viewInfo.TimeToPosition(viewInfo.selectedRegion.t0(), rect.x); |
| 394 | wxInt64 rightSel = viewInfo.TimeToPosition(viewInfo.selectedRegion.t1(), rect.x); |
| 395 | // Something is wrong if right edge comes before left edge |
| 396 | wxASSERT(!(rightSel < leftSel)); |
| 397 | static_cast<void>(leftSel); // Suppress unused variable warnings if not in debug-mode |
| 398 | static_cast<void>(rightSel); |
| 399 | } |
| 400 | |
| 401 | return result; |
| 402 | } |
| 403 | |
| 404 | UIHandle::Result SelectHandle::NeedChangeHighlight |
| 405 | (const SelectHandle &oldState, const SelectHandle &newState) |
nothing calls this directly
no test coverage detected