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

Method OnMouseEvent

src/TrackPanel.cpp:734–777  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

732}
733
734void TrackPanel::OnMouseEvent(wxMouseEvent & event)
735{
736 if (event.LeftDown()) {
737 // wxTimers seem to be a little unreliable, so this
738 // "primes" it to make sure it keeps going for a while...
739
740 // When this timer fires, we call TrackPanel::OnTimer and
741 // possibly update the screen for offscreen scrolling.
742 mTimer.Stop();
743 mTimer.Start(std::chrono::milliseconds{kTimerInterval}.count(), FALSE);
744 }
745
746 if (event.MiddleDown()) {
747 mIsPanning = true;
748 mLastPanX = event.GetX();
749 CaptureMouse();
750 }
751 else if (event.MiddleUp()) {
752 mIsPanning = false;
753 ReleaseMouse();
754 }
755 else if (event.Dragging() && mIsPanning) {
756 int dx = event.GetX() - mLastPanX;
757 mLastPanX = event.GetX();
758
759 Viewport::Get(*GetProject()).ScrollHorizontalByPixels(-dx);
760 }
761
762 if (event.ButtonUp()) {
763 //ShowTrack should be called after processing the up-click.
764 this->CallAfter( [this, event]{
765 const auto foundCell = FindCell(event.m_x, event.m_y);
766 const auto t = FindTrack( foundCell.pCell.get() );
767 if (t) {
768 auto &focus = TrackFocus::Get(*GetProject());
769 focus.Set(t.get());
770 Viewport::Get(*GetProject()).ShowTrack(*t);
771 }
772 } );
773 }
774
775 // Must also fall through to base class handler
776 event.Skip();
777}
778
779double TrackPanel::GetMostRecentXPos()
780{

Callers

nothing calls this directly

Calls 9

GetFunction · 0.85
ShowTrackMethod · 0.80
SkipMethod · 0.80
FindTrackFunction · 0.70
StopMethod · 0.45
StartMethod · 0.45
getMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected