Mercurial > hg > svapp
diff framework/MainWindowBase.cpp @ 215:b96d90975f7c
* Add Paste at Playback Position function
author | Chris Cannam |
---|---|
date | Fri, 04 Feb 2011 14:31:33 +0000 |
parents | eed79c69be61 |
children | 64dfa7d6171d |
line wrap: on
line diff
--- a/framework/MainWindowBase.cpp Mon Oct 25 21:15:24 2010 +0200 +++ b/framework/MainWindowBase.cpp Fri Feb 04 14:31:33 2011 +0000 @@ -676,13 +676,37 @@ void MainWindowBase::paste() { + pasteRelative(0); +} + +void +MainWindowBase::pasteAtPlaybackPosition() +{ + unsigned long pos = getFrame(); + Clipboard &clipboard = m_viewManager->getClipboard(); + if (!clipboard.empty()) { + long firstEventFrame = clipboard.getPoints()[0].getFrame(); + long offset = 0; + if (firstEventFrame < 0) { + offset = long(pos) - firstEventFrame; + } else if (firstEventFrame < pos) { + offset = pos - firstEventFrame; + } else { + offset = -(firstEventFrame - pos); + } + pasteRelative(offset); + } +} + +void +MainWindowBase::pasteRelative(int offset) +{ Pane *currentPane = m_paneStack->getCurrentPane(); if (!currentPane) return; Layer *layer = currentPane->getSelectedLayer(); Clipboard &clipboard = m_viewManager->getClipboard(); -// Clipboard::PointList contents = clipboard.getPoints(); bool inCompound = false; @@ -708,7 +732,7 @@ inCompound = true; } - layer->paste(currentPane, clipboard, 0, true); + layer->paste(currentPane, clipboard, offset, true); if (inCompound) CommandHistory::getInstance()->endCompoundOperation(); }