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

Method DropdownUpdated

Source/StepSequencer.cpp:898–949  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

896}
897
898void StepSequencer::DropdownUpdated(DropdownList* list, int oldVal, double time)
899{
900 if (list == mRepeatRateDropdown)
901 {
902 for (int i = 0; i < NUM_STEPSEQ_ROWS; ++i)
903 mNoteRepeats[i]->SetInterval(mRepeatRate);
904 }
905 if (list == mStepIntervalDropdown)
906 {
907 UIGrid* oldGrid = new UIGrid(*mGrid);
908 int oldNumSteps = GetNumSteps((NoteInterval)oldVal, mNumMeasures);
909 int newNumSteps = GetNumSteps(mStepInterval, mNumMeasures);
910 for (int i = 0; i < mGrid->GetRows(); ++i)
911 {
912 for (int j = 0; j < newNumSteps; ++j)
913 {
914 float div = j * ((float)oldNumSteps / newNumSteps);
915 int col = (int)div;
916 if (div == col)
917 mGrid->SetVal(j, i, oldGrid->GetVal(col, i));
918 else
919 mGrid->SetVal(j, i, 0);
920 }
921 }
922 oldGrid->Delete();
923 TransportListenerInfo* transportListenerInfo = TheTransport->GetListenerInfo(this);
924 if (transportListenerInfo != nullptr)
925 transportListenerInfo->mInterval = mStepInterval;
926 mFlusher.SetInterval(mStepInterval);
927 mGrid->SetMajorColSize(TheTransport->CountInStandardMeasure(mStepInterval) / 4);
928 for (int i = 0; i < NUM_STEPSEQ_ROWS; ++i)
929 mRows[i]->UpdateTimeListener();
930 }
931 if (list == mVelocityTypeDropdown)
932 {
933 switch (mVelocityType)
934 {
935 case StepVelocityType::Normal:
936 mStrength = gStepVelocityLevels[(int)StepVelocityType::Normal];
937 break;
938 case StepVelocityType::Accent:
939 mStrength = gStepVelocityLevels[(int)StepVelocityType::Accent];
940 break;
941 case StepVelocityType::Ghost:
942 mStrength = gStepVelocityLevels[(int)StepVelocityType::Ghost];
943 break;
944 default:
945 break;
946 }
947 mGrid->SetStrength(mStrength);
948 }
949}
950
951void StepSequencer::KeyPressed(int key, bool isRepeat)
952{

Callers

nothing calls this directly

Calls 10

SetIntervalMethod · 0.80
SetValMethod · 0.80
GetValMethod · 0.80
GetListenerInfoMethod · 0.80
UpdateTimeListenerMethod · 0.80
SetStrengthMethod · 0.80
GetRowsMethod · 0.45
DeleteMethod · 0.45
SetMajorColSizeMethod · 0.45

Tested by

no test coverage detected