Mercurial > hg > svapp
changeset 215:b96d90975f7c
* Add Paste at Playback Position function
author | Chris Cannam |
---|---|
date | Fri, 04 Feb 2011 14:31:33 +0000 |
parents | 15057cf59da5 |
children | ee31e2f3a0f1 |
files | framework/MainWindowBase.cpp framework/MainWindowBase.h |
diffstat | 2 files changed, 28 insertions(+), 2 deletions(-) [+] |
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(); }
--- 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();