|
I've written a copy paste in the popup of the instrumentlist. I know that there is a undo branche, maybe can someone help me out to apply it to that branche? Ciao, Dave |
Index: gui/src/PatternEditor/PatternEditorInstrumentList.h
===================================================================
--- gui/src/PatternEditor/PatternEditorInstrumentList.h (revision 1608)
+++ gui/src/PatternEditor/PatternEditorInstrumentList.h (working copy)
@@ -56,6 +56,8 @@
private slots:
void functionClearNotes();
+ void functionCopyNotes(); //added copy
+ void functionPasteNotes(); //added paste
void functionFillAllNotes();
void functionFillEveryTwoNotes();
Index: gui/src/PatternEditor/DrumPatternEditor.h
===================================================================
--- gui/src/PatternEditor/DrumPatternEditor.h (revision 1608)
+++ gui/src/PatternEditor/DrumPatternEditor.h (working copy)
@@ -67,7 +67,9 @@
static QColor computeNoteColor( float );
+ std::multimap <int, H2Core::Note*> tmpPattern;//for remembering copy/paste
+
public slots:
void updateEditor();
Index: gui/src/PatternEditor/PatternEditorInstrumentList.cpp
===================================================================
--- gui/src/PatternEditor/PatternEditorInstrumentList.cpp (revision 1608)
+++ gui/src/PatternEditor/PatternEditorInstrumentList.cpp (working copy)
@@ -88,23 +88,25 @@
- // Popup menu
- m_pFunctionPopup = new QMenu( this );
- m_pFunctionPopup->addAction( trUtf8( "Clear notes" ), this, SLOT( functionClearNotes() ) );
- m_pFunctionPopupSub = new QMenu( trUtf8( "Fill notes ..." ), m_pFunctionPopup );
- m_pFunctionPopupSub->addAction( trUtf8( "Fill all notes" ), this, SLOT( functionFillAllNotes() ) );
- m_pFunctionPopupSub->addAction( trUtf8( "Fill 1/2 notes" ), this, SLOT( functionFillEveryTwoNotes() ) );
- m_pFunctionPopupSub->addAction( trUtf8( "Fill 1/3 notes" ), this, SLOT( functionFillEveryThreeNotes() ) );
- m_pFunctionPopupSub->addAction( trUtf8( "Fill 1/4 notes" ), this, SLOT( functionFillEveryFourNotes() ) );
- m_pFunctionPopupSub->addAction( trUtf8( "Fill 1/6 notes" ), this, SLOT( functionFillEverySixNotes() ) );
- m_pFunctionPopupSub->addAction( trUtf8( "Fill 1/8 notes" ), this, SLOT( functionFillEveryEightNotes() ) );
- m_pFunctionPopup->addMenu( m_pFunctionPopupSub );
- m_pFunctionPopup->addAction( trUtf8( "Randomize velocity" ), this, SLOT( functionRandomizeVelocity() ) );
- m_pFunctionPopup->addSeparator();
- m_pFunctionPopup->addAction( trUtf8( "Delete instrument" ), this, SLOT( functionDeleteInstrument() ) );
+ // Popup menu
+ m_pFunctionPopup = new QMenu( this );
+ m_pFunctionPopup->addAction( trUtf8( "Clear notes" ), this, SLOT( functionClearNotes() ) );
+ m_pFunctionPopup->addAction( trUtf8( "Copy notes" ), this, SLOT( functionCopyNotes() ) );
+ m_pFunctionPopup->addAction( trUtf8( "Paste notes" ), this, SLOT( functionPasteNotes() ) );
+ m_pFunctionPopupSub = new QMenu( trUtf8( "Fill notes ..." ), m_pFunctionPopup );
+ m_pFunctionPopupSub->addAction( trUtf8( "Fill all notes" ), this, SLOT( functionFillAllNotes() ) );
+ m_pFunctionPopupSub->addAction( trUtf8( "Fill 1/2 notes" ), this, SLOT( functionFillEveryTwoNotes() ) );
+ m_pFunctionPopupSub->addAction( trUtf8( "Fill 1/3 notes" ), this, SLOT( functionFillEveryThreeNotes() ) );
+ m_pFunctionPopupSub->addAction( trUtf8( "Fill 1/4 notes" ), this, SLOT( functionFillEveryFourNotes() ) );
+ m_pFunctionPopupSub->addAction( trUtf8( "Fill 1/6 notes" ), this, SLOT( functionFillEverySixNotes() ) );
+ m_pFunctionPopupSub->addAction( trUtf8( "Fill 1/8 notes" ), this, SLOT( functionFillEveryEightNotes() ) );
+ m_pFunctionPopup->addMenu( m_pFunctionPopupSub );
+ m_pFunctionPopup->addAction( trUtf8( "Randomize velocity" ), this, SLOT( functionRandomizeVelocity() ) );
+ m_pFunctionPopup->addSeparator();
+ m_pFunctionPopup->addAction( trUtf8( "Delete instrument" ), this, SLOT( functionDeleteInstrument() ) );
- m_bIsSelected = true;
- setSelected(false);
+ m_bIsSelected = true;
+ setSelected(false);
}
@@ -244,8 +246,53 @@
EventQueue::get_instance()->push_event( EVENT_SELECTED_INSTRUMENT_CHANGED, -1 );
}
+void InstrumentLine::functionCopyNotes()
+{
+ Hydrogen *pEngine = Hydrogen::get_instance();
+ Pattern *pCurrentPattern = getCurrentPattern();
+ int nSelectedInstrument = pEngine->getSelectedInstrumentNumber();
+ Song *pSong = pEngine->getSong();
+ Instrument *instrRef = (pSong->get_instrument_list())->get( nSelectedInstrument );
+
+ for(std::multimap<int, Note*>::iterator i=pCurrentPattern->note_map.begin();i!=pCurrentPattern->note_map.end();++i){
+ if(i->second->get_instrument()==instrRef){
+ HydrogenApp::get_instance()->getPatternEditorPanel()->getDrumPatternEditor()->tmpPattern.insert(std::make_pair( i->first,i->second ));
+ }
+ }
+}
+
+void InstrumentLine::functionPasteNotes()
+{
+ Hydrogen *pEngine = Hydrogen::get_instance();
+ Pattern *pCurrentPattern = getCurrentPattern();
+ int nSelectedInstrument = pEngine->getSelectedInstrumentNumber();
+
+ AudioEngine::get_instance()->lock( RIGHT_HERE ); // lock the audio engine
+
+ Song *pSong = pEngine->getSong();
+ Instrument *instrRef = (pSong->get_instrument_list())->get( nSelectedInstrument );
+
+ for(std::multimap<int, Note*>::iterator j=HydrogenApp::get_instance()->getPatternEditorPanel()->getDrumPatternEditor()->tmpPattern.begin();j!=HydrogenApp::get_instance()->getPatternEditorPanel()->getDrumPatternEditor()->tmpPattern.end();++j){
+ Note *pNote = new Note(j->second);
+ j->second=pNote;
+ j->second->set_instrument(instrRef);
+ }
+
+ std::multimap<int, Note*>::iterator i=pCurrentPattern->note_map.end();
+ for(std::multimap<int, Note*>::iterator j=HydrogenApp::get_instance()->getPatternEditorPanel()->getDrumPatternEditor()->tmpPattern.begin();j!=HydrogenApp::get_instance()->getPatternEditorPanel()->getDrumPatternEditor()->tmpPattern.end();++j){
+ pCurrentPattern->note_map.insert(i,std::make_pair( j->first,j->second ));
+ i++;
+ }
+
+ AudioEngine::get_instance()->unlock(); // unlock the audio engine
+
+ // this will force an update...
+ EventQueue::get_instance()->push_event( EVENT_SELECTED_INSTRUMENT_CHANGED, -1 );
+
+}
+
void InstrumentLine::functionFillAllNotes(){ functionFillNotes(1); }
void InstrumentLine::functionFillEveryTwoNotes(){ functionFillNotes(2); }
void InstrumentLine::functionFillEveryThreeNotes(){ functionFillNotes(3); }
------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev
_______________________________________________ Hydrogen-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/hydrogen-devel
