| 567 | } |
| 568 | |
| 569 | void CFrameEditor::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) |
| 570 | { |
| 571 | const int PAGE_SIZE = 4; |
| 572 | |
| 573 | if (m_bInputEnable) { |
| 574 | // Keyboard input is active |
| 575 | bool bShift = (::GetKeyState(VK_SHIFT) & 0x80) == 0x80; |
| 576 | |
| 577 | CSongView *pSongView = m_pView->GetSongView(); // // // |
| 578 | |
| 579 | const int MaxChannel = GetSongChannelCount() - 1; // // // |
| 580 | const int FrameCount = GetSongFrameCount(); |
| 581 | const int Channel = model_->GetCurrentChannel(); |
| 582 | const int Frame = GetEditFrame(); // // // |
| 583 | const int MaxFrame = FrameCount - (IsSelecting() ? 1 : 0); |
| 584 | |
| 585 | switch (nChar) { |
| 586 | case VK_RETURN: |
| 587 | m_pView->SetFocus(); |
| 588 | break; |
| 589 | case VK_INSERT: |
| 590 | OnModuleInsertFrame(); |
| 591 | break; |
| 592 | case VK_DELETE: |
| 593 | OnModuleRemoveFrame(); |
| 594 | break; |
| 595 | case VK_UP: |
| 596 | case VK_DOWN: |
| 597 | case VK_LEFT: |
| 598 | case VK_RIGHT: |
| 599 | case VK_NEXT: |
| 600 | case VK_PRIOR: |
| 601 | case VK_HOME: |
| 602 | case VK_END: |
| 603 | if (bShift && !m_bLastRow) { // // // |
| 604 | if (!model_->IsSelecting()) |
| 605 | model_->StartSelection(CFrameCursorPos {GetEditFrame(), Channel}); |
| 606 | } |
| 607 | else |
| 608 | CancelSelection(); |
| 609 | |
| 610 | switch (nChar) { |
| 611 | case VK_LEFT: |
| 612 | m_pView->SelectChannel(Channel ? Channel - 1 : MaxChannel); |
| 613 | break; |
| 614 | case VK_RIGHT: |
| 615 | m_pView->SelectChannel(Channel == MaxChannel ? 0 : Channel + 1); |
| 616 | break; |
| 617 | case VK_UP: |
| 618 | SetEditFrame(Frame ? Frame - 1 : MaxFrame); // // // |
| 619 | break; |
| 620 | case VK_DOWN: |
| 621 | SetEditFrame(Frame == MaxFrame ? 0 : Frame + 1); // // // |
| 622 | break; |
| 623 | case VK_NEXT: |
| 624 | SetEditFrame(std::min(MaxFrame, Frame + PAGE_SIZE)); // // // |
| 625 | break; |
| 626 | case VK_PRIOR: |
nothing calls this directly
no test coverage detected