| 949 | } |
| 950 | |
| 951 | void StepSequencer::KeyPressed(int key, bool isRepeat) |
| 952 | { |
| 953 | IDrawableModule::KeyPressed(key, isRepeat); |
| 954 | |
| 955 | ofVec2f mousePos(TheSynth->GetMouseX(GetOwningContainer()), TheSynth->GetMouseY(GetOwningContainer())); |
| 956 | if (mGrid->GetRect().contains(mousePos.x, mousePos.y)) |
| 957 | { |
| 958 | auto cell = mGrid->GetGridCellAt(mousePos.x - mGrid->GetPosition().x, mousePos.y - mGrid->GetPosition().y); |
| 959 | if (key >= '1' && key <= '8') |
| 960 | { |
| 961 | int metaStep = key - '1'; |
| 962 | mMetaStepMasks[GetMetaStepMaskIndex(cell.mCol, cell.mRow)] ^= (1 << metaStep); |
| 963 | } |
| 964 | if (key == OF_KEY_UP || key == OF_KEY_DOWN) |
| 965 | { |
| 966 | float velocity = mGrid->GetVal(cell.mCol, cell.mRow); |
| 967 | if (velocity > 0) |
| 968 | { |
| 969 | if (key == OF_KEY_UP) |
| 970 | { |
| 971 | for (int i = 0; i < (int)gStepVelocityLevels.size(); ++i) |
| 972 | { |
| 973 | if (velocity < gStepVelocityLevels[i]) |
| 974 | { |
| 975 | mGrid->SetVal(cell.mCol, cell.mRow, gStepVelocityLevels[i]); |
| 976 | break; |
| 977 | } |
| 978 | } |
| 979 | } |
| 980 | |
| 981 | if (key == OF_KEY_DOWN) |
| 982 | { |
| 983 | for (int i = (int)gStepVelocityLevels.size() - 1; i >= 0; --i) |
| 984 | { |
| 985 | if (velocity > gStepVelocityLevels[i]) |
| 986 | { |
| 987 | mGrid->SetVal(cell.mCol, cell.mRow, gStepVelocityLevels[i]); |
| 988 | break; |
| 989 | } |
| 990 | } |
| 991 | } |
| 992 | } |
| 993 | } |
| 994 | } |
| 995 | } |
| 996 | |
| 997 | void StepSequencer::SaveLayout(ofxJSONElement& moduleInfo) |
| 998 | { |
nothing calls this directly
no test coverage detected