Mercurial > hg > svapp
comparison 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 |
comparison
equal
deleted
inserted
replaced
214:15057cf59da5 | 215:b96d90975f7c |
---|---|
674 } | 674 } |
675 | 675 |
676 void | 676 void |
677 MainWindowBase::paste() | 677 MainWindowBase::paste() |
678 { | 678 { |
679 pasteRelative(0); | |
680 } | |
681 | |
682 void | |
683 MainWindowBase::pasteAtPlaybackPosition() | |
684 { | |
685 unsigned long pos = getFrame(); | |
686 Clipboard &clipboard = m_viewManager->getClipboard(); | |
687 if (!clipboard.empty()) { | |
688 long firstEventFrame = clipboard.getPoints()[0].getFrame(); | |
689 long offset = 0; | |
690 if (firstEventFrame < 0) { | |
691 offset = long(pos) - firstEventFrame; | |
692 } else if (firstEventFrame < pos) { | |
693 offset = pos - firstEventFrame; | |
694 } else { | |
695 offset = -(firstEventFrame - pos); | |
696 } | |
697 pasteRelative(offset); | |
698 } | |
699 } | |
700 | |
701 void | |
702 MainWindowBase::pasteRelative(int offset) | |
703 { | |
679 Pane *currentPane = m_paneStack->getCurrentPane(); | 704 Pane *currentPane = m_paneStack->getCurrentPane(); |
680 if (!currentPane) return; | 705 if (!currentPane) return; |
681 | 706 |
682 Layer *layer = currentPane->getSelectedLayer(); | 707 Layer *layer = currentPane->getSelectedLayer(); |
683 | 708 |
684 Clipboard &clipboard = m_viewManager->getClipboard(); | 709 Clipboard &clipboard = m_viewManager->getClipboard(); |
685 // Clipboard::PointList contents = clipboard.getPoints(); | |
686 | 710 |
687 bool inCompound = false; | 711 bool inCompound = false; |
688 | 712 |
689 if (!layer || !layer->isLayerEditable()) { | 713 if (!layer || !layer->isLayerEditable()) { |
690 | 714 |
706 m_paneStack->setCurrentLayer(currentPane, layer); | 730 m_paneStack->setCurrentLayer(currentPane, layer); |
707 | 731 |
708 inCompound = true; | 732 inCompound = true; |
709 } | 733 } |
710 | 734 |
711 layer->paste(currentPane, clipboard, 0, true); | 735 layer->paste(currentPane, clipboard, offset, true); |
712 | 736 |
713 if (inCompound) CommandHistory::getInstance()->endCompoundOperation(); | 737 if (inCompound) CommandHistory::getInstance()->endCompoundOperation(); |
714 } | 738 } |
715 | 739 |
716 void | 740 void |