MCPcopy Create free account
hub / github.com/TypesettingTools/Aegisub / OnMouseEvent

Method OnMouseEvent

src/audio_display.cpp:1045–1122  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1043}
1044
1045void AudioDisplay::OnMouseEvent(wxMouseEvent& event)
1046{
1047 // If we have focus, we get mouse move events on Mac even when the mouse is
1048 // outside our client rectangle, we don't want those.
1049 if (event.Moving() && !GetClientRect().Contains(event.GetPosition()))
1050 {
1051 event.Skip();
1052 return;
1053 }
1054
1055 if (event.IsButton())
1056 SetFocus();
1057
1058 const int mouse_x = event.GetPosition().x;
1059
1060 // Scroll the display after a mouse-up near one of the edges
1061 if ((event.LeftUp() || event.RightUp()) && OPT_GET("Audio/Auto/Scroll")->GetBool())
1062 {
1063 const int width = GetClientSize().GetWidth();
1064 if (mouse_x < width / 20) {
1065 ScrollBy(-width / 3);
1066 }
1067 else if (width - mouse_x < width / 20) {
1068 ScrollBy(width / 3);
1069 }
1070 }
1071
1072 if (ForwardMouseEvent(event))
1073 return;
1074
1075 if (event.MiddleIsDown())
1076 {
1077 context->videoController->JumpToTime(TimeFromRelativeX(mouse_x), agi::vfr::EXACT);
1078 return;
1079 }
1080
1081 if (event.Moving() && !controller->IsPlaying())
1082 {
1083 SetTrackCursor(scroll_left + mouse_x, OPT_GET("Audio/Display/Draw/Cursor Time")->GetBool());
1084 }
1085
1086 AudioTimingController *timing = controller->GetTimingController();
1087 if (!timing) return;
1088 const int drag_sensitivity = int(OPT_GET("Audio/Start Drag Sensitivity")->GetInt() * ms_per_pixel);
1089 const int snap_sensitivity = OPT_GET("Audio/Snap/Enable")->GetBool() != event.ShiftDown() ? int(OPT_GET("Audio/Snap/Distance")->GetInt() * ms_per_pixel) : 0;
1090
1091 // Not scrollbar, not timeline, no button action
1092 if (event.Moving())
1093 {
1094 const int timepos = TimeFromRelativeX(mouse_x);
1095
1096 if (timing->IsNearbyMarker(timepos, drag_sensitivity, event.AltDown()))
1097 SetCursor(wxCursor(wxCURSOR_SIZEWE));
1098 else
1099 SetCursor(wxNullCursor);
1100 return;
1101 }
1102

Callers 1

ForwardMouseEventMethod · 0.45

Calls 10

JumpToTimeMethod · 0.80
GetTimingControllerMethod · 0.80
GetPositionMethod · 0.45
GetWidthMethod · 0.45
IsPlayingMethod · 0.45
IsNearbyMarkerMethod · 0.45
OnLeftClickMethod · 0.45
OnRightClickMethod · 0.45
sizeMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected