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

Method KeyPressed

Source/StepSequencer.cpp:951–995  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

949}
950
951void 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
997void StepSequencer::SaveLayout(ofxJSONElement& moduleInfo)
998{

Callers

nothing calls this directly

Calls 9

containsMethod · 0.80
GetValMethod · 0.80
sizeMethod · 0.80
SetValMethod · 0.80
GetMouseXMethod · 0.45
GetMouseYMethod · 0.45
GetRectMethod · 0.45
GetGridCellAtMethod · 0.45
GetPositionMethod · 0.45

Tested by

no test coverage detected