| 529 | } |
| 530 | |
| 531 | void Canvas::KeyPressed(int key, bool isRepeat) |
| 532 | { |
| 533 | if (TheSynth->GetLastClickedModule() == GetParent() && gHoveredUIControl == this) |
| 534 | { |
| 535 | if (key == juce::KeyPress::backspaceKey || key == juce::KeyPress::deleteKey) |
| 536 | { |
| 537 | if (mControls) |
| 538 | mControls->SetElement(nullptr); |
| 539 | |
| 540 | std::vector<CanvasElement*> toRemove; |
| 541 | for (auto element : mElements) |
| 542 | { |
| 543 | if (element->GetHighlighted()) |
| 544 | toRemove.push_back(element); |
| 545 | } |
| 546 | for (auto element : toRemove) |
| 547 | { |
| 548 | RemoveElement(element); |
| 549 | } |
| 550 | } |
| 551 | if (key == 'a' && GetKeyModifiers() & kModifier_Command) |
| 552 | { |
| 553 | for (auto* element : mElements) |
| 554 | element->SetHighlight(true); |
| 555 | } |
| 556 | if (key == OF_KEY_LEFT || key == OF_KEY_RIGHT) |
| 557 | { |
| 558 | int direction = (key == OF_KEY_LEFT) ? -1 : 1; |
| 559 | for (auto* element : mElements) |
| 560 | { |
| 561 | if (element->GetHighlighted()) |
| 562 | element->mCol += direction; |
| 563 | } |
| 564 | } |
| 565 | if (key == OF_KEY_UP || key == OF_KEY_DOWN) |
| 566 | { |
| 567 | int direction = (key == OF_KEY_UP) ? -1 : 1; |
| 568 | |
| 569 | if (GetKeyModifiers() == kModifier_Shift) |
| 570 | direction *= 12; //octave |
| 571 | |
| 572 | for (auto* element : mElements) |
| 573 | { |
| 574 | if (element->GetHighlighted()) |
| 575 | element->mRow += direction; |
| 576 | } |
| 577 | } |
| 578 | } |
| 579 | } |
| 580 | |
| 581 | void Canvas::RescaleNumCols(int cols) |
| 582 | { |
no test coverage detected