MCPcopy Create free account
hub / github.com/HertzDevil/0CC-FamiTracker / CursorUpdated

Method CursorUpdated

Source/PatternEditor.cpp:677–773  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

675}
676
677bool CPatternEditor::CursorUpdated()
678{
679 // This method must be called after the cursor has changed
680 // Returns true if a new pattern layout is needed
681
682 // No channels visible, create the pattern layout
683 if (m_iChannelsVisible == 0)
684 return true;
685
686 const int Frames = GetFrameCount(); // // //
687 const int ChannelCount = GetChannelCount();
688
689 bool bUpdateNeeded = false;
690
691 // Update pattern lengths
692 UpdatePatternLength();
693
694 // Channel cursor moved left of first visible channel
695 if (m_iFirstChannel > GetChannel()) {
696 m_iFirstChannel = GetChannel();
697 bUpdateNeeded = true;
698 }
699
700 // Channel cursor moved to the right of all visible channels
701 while ((GetChannel() - m_iFirstChannel) > (m_iChannelsFullVisible - 1)) {
702 ++m_iFirstChannel;
703 bUpdateNeeded = true;
704 }
705
706 if (m_iFirstChannel + m_iChannelsVisible > ChannelCount)
707 m_iChannelsVisible = ChannelCount - m_iFirstChannel;
708
709 if (m_iChannelsFullVisible > m_iChannelsVisible)
710 m_iChannelsFullVisible = m_iChannelsVisible;
711
712 for (int i = 0; i < ChannelCount; ++i) {
713 if (i == GetChannel()) {
714 if (GetColumn() > m_iColumns[i])
715 m_cpCursorPos.Xpos.Column = m_iColumns[i];
716 }
717 }
718
719 if (GetRow() > m_iPatternLength - 1)
720 m_cpCursorPos.Ypos.Row = m_iPatternLength - 1;
721
722 // Frame
723 if (GetFrame() >= Frames) // // //
724 m_cpCursorPos.Ypos.Frame = Frames - 1;
725
726 // Ignore user cursor moves if the player is playing
727 if (FTEnv.GetSoundGenerator()->IsPlaying()) {
728
729 const CSoundGen *pSoundGen = FTEnv.GetSoundGenerator();
730 // Store a synchronized copy of frame & row position from player
731 std::tie(m_iPlayFrame, m_iPlayRow) = pSoundGen->GetPlayerPos(); // // //
732
733 if (m_bFollowMode) {
734 m_cpCursorPos.Ypos.Row = m_iPlayRow;

Callers 2

RedrawPatternEditorMethod · 0.80
CalcWindowRectMethod · 0.80

Calls 4

GetPlayerPosMethod · 0.80
IsPlayingMethod · 0.45
GetSoundGeneratorMethod · 0.45
GetSettingsMethod · 0.45

Tested by

no test coverage detected