void PasteSelection() { history.AddHistroyAtSelection(); int lines = m_CopyData.GetLength(0); int chns = m_CopyData.GetLength(1); int cols = SongData.SONG_DATA_COUNT; int currLine = patternView.selectedLine; int currChn = patternView.position.channel; int currCol = patternView.position.dataColumn; //offset currCol to same col as copy int colDelta = (currCol % SongData.SONG_DATA_COUNT) - (m_LastCopy.startCol & SongData.SONG_DATA_COUNT); currCol -= colDelta; for (int line = 0; line < lines; line++) { if (currLine + line >= patternView.data.patternLength) { break; } for (int chn = 0; chn < chns; chn++) { if (currChn + chn >= songData.channels) { break; } if (!songData.IsPatternValid(chn)) { continue; } int startCol = chn == 0 ? m_LastCopy.startCol : 0; int endCol = chn == chns - 1 ? m_LastCopy.endCol + 1 : SongData.SONG_DATA_COUNT - startCol; for (int col = startCol; col < endCol; col++) { songData.SetData(currChn + chn, currLine + line, col, m_CopyData[line, chn, col]); } patternView.UpdateSingleRow(currChn + chn, currLine + line); } } patternView.SetSelection(currLine + (m_LastCopy.endLine - m_LastCopy.startLine) + 1); }
public void DoOperation(SelectionDataUpdateDelegate op, bool update = true) { for (int line = m_Selection.startLine; line <= m_Selection.endLine; line++) { for (int chn = m_Selection.startChn; chn <= m_Selection.endChn; chn++) { int startCol = chn == m_Selection.startChn ? m_Selection.startCol : 0; int endCol = chn == m_Selection.endChn ? m_Selection.endCol : SongData.SONG_DATA_COUNT - 1; for (int col = startCol; col <= endCol; col++) { op(line, chn, col); } if (update) { view.UpdateSingleRow(chn, line); } } } }