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

Method MouseMoved

Source/SamplePlayer.cpp:842–892  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

840}
841
842bool SamplePlayer::MouseMoved(float x, float y)
843{
844 IDrawableModule::MouseMoved(x, y);
845 if (mScrubbingSample && mSample != nullptr)
846 {
847 mSwitchAndRamp.StartSwitch();
848 mSample->SetPlayPosition(int(GetPlayPositionForMouse(x)));
849 mAdsr.Clear();
850 mAdsr.Start(NextBufferTime(false), 1);
851
852 if (mSetCuePoint)
853 SetCuePointForX(x);
854 }
855
856 if (gHoveredUIControl == nullptr) //make sure we don't update our hover while dragging a slider
857 {
858 mHoveredCuePointIndex = -1;
859 if (y > 60 && y < mHeight - 20 && mSample != nullptr)
860 {
861 float seconds = GetSecondsForMouse(x);
862
863 // find cue point closest to but not exceeding the cursor position
864 int bestCuePointIndex = -1;
865 float bestCuePointStart = 0.;
866 for (int i = 0; i < (int)mSampleCuePoints.size(); ++i)
867 {
868 float startSeconds = mSampleCuePoints[i].startSeconds;
869 float lengthSeconds = mSampleCuePoints[i].lengthSeconds;
870
871 if (lengthSeconds > 0.)
872 {
873 if (seconds >= startSeconds && seconds <= startSeconds + lengthSeconds &&
874 startSeconds > bestCuePointStart)
875 {
876 bestCuePointIndex = i;
877 bestCuePointStart = startSeconds;
878 }
879 }
880 }
881
882 if (bestCuePointIndex != -1)
883 {
884 mHoveredCuePointIndex = bestCuePointIndex;
885 //mActiveCuePointIndex = bestCuePointIndex;
886 //UpdateActiveCuePoint();
887 }
888 }
889 }
890
891 return true;
892}
893
894void SamplePlayer::SetCuePointForX(float mouseX)
895{

Callers

nothing calls this directly

Calls 6

NextBufferTimeFunction · 0.85
StartSwitchMethod · 0.80
SetPlayPositionMethod · 0.80
sizeMethod · 0.80
ClearMethod · 0.45
StartMethod · 0.45

Tested by

no test coverage detected