# HG changeset patch # User Chris Cannam # Date 1296829893 0 # Node ID b96d90975f7cf5779fa120ea8f80bc633dd79498 # Parent 15057cf59da506731d0a4a4808ce269f327a530a * Add Paste at Playback Position function diff -r 15057cf59da5 -r b96d90975f7c framework/MainWindowBase.cpp --- 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(); } diff -r 15057cf59da5 -r b96d90975f7c framework/MainWindowBase.h --- a/framework/MainWindowBase.h Mon Oct 25 21:15:24 2010 +0200 +++ b/framework/MainWindowBase.h Fri Feb 04 14:31:33 2011 +0000 @@ -221,6 +221,8 @@ virtual void cut(); virtual void copy(); virtual void paste(); + virtual void pasteAtPlaybackPosition(); + virtual void pasteRelative(int offset); virtual void deleteSelected(); virtual void insertInstant();