MCPcopy Create free account
hub / github.com/BespokeSynth/BespokeSynth / MouseMoved

Method MouseMoved

Source/ModularSynth.cpp:1210–1378  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1208}
1209
1210void ModularSynth::MouseMoved(int intX, int intY)
1211{
1212 bool changed = (mMousePos.x != intX || mMousePos.y != intY);
1213
1214 mMousePos.x = intX;
1215 mMousePos.y = intY;
1216
1217 if (IsKeyHeld(' ') || mIsMousePanning)
1218 {
1219 GetDrawOffset() += (ofVec2f(intX, intY) - mLastMoveMouseScreenPos) / gDrawScale;
1220 mZoomer.CancelMovement();
1221
1222 if (UserPrefs.wrap_mouse_on_pan.Get() &&
1223 (intX <= 0 || intY <= 0 || intX >= ofGetWidth() || intY >= ofGetHeight()))
1224 {
1225 int wrappedX = (intX + (int)ofGetWidth()) % (int)ofGetWidth();
1226 int wrappedY = (intY + (int)ofGetHeight()) % (int)ofGetHeight();
1227
1228 if (intX == 0 && wrappedX == 0)
1229 wrappedX = ofGetWidth() - 1;
1230 if (intY == 0 && wrappedY == 0)
1231 wrappedY = ofGetHeight() - 1;
1232
1233 Desktop::setMousePosition(juce::Point<int>(wrappedX + mMainComponent->getScreenX(),
1234 wrappedY + mMainComponent->getScreenY()));
1235
1236 intX = wrappedX;
1237 intY = wrappedY;
1238 }
1239 }
1240
1241 mLastMoveMouseScreenPos = ofVec2f(intX, intY);
1242
1243 if (changed)
1244 {
1245 for (auto* modal : mModalFocusItemStack)
1246 {
1247 float x = GetMouseX(modal->GetOwningContainer());
1248 float y = GetMouseY(modal->GetOwningContainer());
1249 modal->NotifyMouseMoved(x, y);
1250 }
1251
1252 mHideTooltipsUntilMouseMove = false;
1253 }
1254
1255 if (mMoveModule)
1256 {
1257 float x = GetMouseX(&mModuleContainer);
1258 float y = GetMouseY(&mModuleContainer);
1259
1260 float oldX, oldY;
1261 mMoveModule->GetPosition(oldX, oldY);
1262 float newX = x + mMoveModuleOffsetX;
1263 float newY = y + mMoveModuleOffsetY;
1264
1265 if (ShouldShowGridSnap())
1266 {
1267 newX = round(newX / UserPrefs.grid_snap_size.Get()) * UserPrefs.grid_snap_size.Get();

Callers

nothing calls this directly

Calls 15

IsKeyHeldFunction · 0.85
ofVec2fClass · 0.85
ofGetWidthFunction · 0.85
ofGetHeightFunction · 0.85
GetKeyModifiersFunction · 0.85
CancelMovementMethod · 0.80
GetMethod · 0.80
GetOwningContainerMethod · 0.80
NotifyMouseMovedMethod · 0.80
TitleBarHeightMethod · 0.80
MoveMethod · 0.80
GetPatchCableSourcesMethod · 0.80

Tested by

no test coverage detected