hydrogen 1.2.3
UndoActions.h
Go to the documentation of this file.
1/*
2 * Hydrogen
3 * Copyright(c) 2002-2008 by Alex >Comix< Cominu [comix@users.sourceforge.net]
4 * Copyright(c) 2008-2024 The hydrogen development team [hydrogen-devel@lists.sourceforge.net]
5 *
6 * http://www.hydrogen-music.org
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY, without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see https://www.gnu.org/licenses
20 *
21 */
22
23#ifndef UNDOACTIONS_H
24#define UNDOACTIONS_H
25
26#include <QtGui>
27#include <QtWidgets>
28#include <QDebug>
29#include <QUndoCommand>
30#include <QPoint>
31#include <vector>
32
33#include <core/Basics/Note.h>
34#include <core/Basics/Pattern.h>
37
38#include "HydrogenApp.h"
42
48
49
50//=====================================================================================================================================
51//song editor commands
53class SE_togglePatternAction : public QUndoCommand
54{
55public:
56 SE_togglePatternAction( int nColumn, int nRow ){
57 setText( QObject::tr( "Toggle Pattern ( %1, %2 )" ).arg( nColumn ).arg( nRow ) );
58 m_nColumn = nColumn;
59 m_nRow = nRow;
60 }
67private:
69 int m_nRow;
70};
71
73class SE_movePatternListItemAction : public QUndoCommand
74{
75public:
76 SE_movePatternListItemAction( int nSourcePattern , int nTargetPattern ){
77 setText( QObject::tr( "Move pattern list item ( %1, %2 )" ).arg( nSourcePattern ).arg( nTargetPattern ) );
78 __nSourcePattern = nSourcePattern;
79 __nTargetPattern = nTargetPattern;
80 }
81 virtual void undo()
82 {
83 //qDebug() << "Move Pattern List Item Undo ";
86 }
87 virtual void redo()
88 {
89 //qDebug() << "Move Pattern List Item redo " ;
92 }
93private:
96};
97
98
100class SE_deletePatternSequenceAction : public QUndoCommand
101{
102public:
103 explicit SE_deletePatternSequenceAction( QString pFilename ){
104 setText( QObject::tr( "Delete complete pattern-sequence" ) );
105 __pFilename = pFilename ;
106 }
107 virtual void undo()
108 {
109 //qDebug() << "Delete complete pattern-sequence undo";
112 }
113
114 virtual void redo()
115 {
116 //qDebug() << "Delete complete pattern-sequence redo " ;
119 }
120private:
121 QString __pFilename;
122};
123
125class SE_deletePatternFromListAction : public QUndoCommand
126{
127public:
128 SE_deletePatternFromListAction( QString sPatternFilename,
129 QString sSequenceFilename,
130 int nPatternPosition ){
131 setText( QObject::tr( "Delete pattern from list" ) );
132 m_sPatternFilename = sPatternFilename;
133 m_sSequenceFilename = sSequenceFilename;
134 m_nPatternPosition = nPatternPosition;
135 }
142
146private:
150};
151
153class SE_modifyPatternPropertiesAction : public QUndoCommand
154{
155public:
156 SE_modifyPatternPropertiesAction( QString oldPatternName ,QString oldPatternInfo, QString oldPatternCategory, QString newPatternName , QString newPatternInfo, QString newPatternCategory, int patternNr ){
157 setText( QObject::tr( "Modify pattern properties" ) );
158 __oldPatternName = oldPatternName;
159 __oldPatternCategory = oldPatternCategory;
160 __oldPatternInfo = oldPatternInfo;
161 __newPatternName = newPatternName;
162 __newPatternInfo = newPatternInfo;
163 __newPatternCategory = newPatternCategory;
164 __patternNr = patternNr;
165 }
166 virtual void undo()
167 {
168 //qDebug() << "Modify pattern properties undo";
171 }
172
173 virtual void redo()
174 {
175 //qDebug() << "Modify pattern properties redo" ;
178 }
179private:
183
188};
189
190
192class SE_duplicatePatternAction : public QUndoCommand
193{
194public:
195 SE_duplicatePatternAction( QString patternFilename, int patternPosition ){
196 setText( QObject::tr( "Duplicate pattern" ) );
197 m_sPatternFilename = patternFilename;
198 m_nPatternPosition = patternPosition;
199 }
203
207private:
210};
211
213class SE_insertPatternAction : public QUndoCommand
214{
215public:
216 SE_insertPatternAction( int patternPosition, H2Core::Pattern* pPattern )
217 {
218 setText( QObject::tr( "Add pattern" ) );
219 m_nPatternPosition = patternPosition;
220 m_pNewPattern = pPattern;
221 }
223 {
224 delete m_pNewPattern;
225 }
233private:
235
237};
238
240class SE_loadPatternAction : public QUndoCommand
241{
242public:
243 SE_loadPatternAction( QString sPatternName, QString sOldPatternName,
244 QString sSequenceFilename, int nPatternPosition,
245 bool bDragFromList){
246 setText( QObject::tr( "Load/drag pattern" ) );
247 m_sPatternName = sPatternName;
248 m_sOldPatternName = sOldPatternName;
249 m_sSequenceFilename = sSequenceFilename;
250 m_nPatternPosition = nPatternPosition;
251 m_bDragFromList = bDragFromList;
252 }
253 virtual void undo() {
254 auto pCoreActionController = H2Core::Hydrogen::get_instance()->getCoreActionController();
256 if( m_bDragFromList ){
257 pCoreActionController->removePattern( m_nPatternPosition );
258 } else {
259 pCoreActionController->removePattern( m_nPatternPosition );
260 pCoreActionController->openPattern( m_sOldPatternName, m_nPatternPosition );
261 }
263 }
264
265 virtual void redo() {
266 auto pCoreActionController = H2Core::Hydrogen::get_instance()->getCoreActionController();
267 if( ! m_bDragFromList ){
268 pCoreActionController->removePattern( m_nPatternPosition );
269 }
270 pCoreActionController->openPattern( m_sPatternName, m_nPatternPosition );
271 }
272private:
278};
279
280
282class SE_fillRangePatternAction : public QUndoCommand
283{
284public:
285 SE_fillRangePatternAction( FillRange* pRange, int nPattern ){
286 setText( QObject::tr( "Fill/remove range of pattern" ) );
287 __pRange = pRange;
288 __from = pRange->fromVal;
289 __to = pRange->toVal;
290 __bInsert = pRange->bInsert;
291 __nPattern = nPattern;
292 }
293 virtual void undo()
294 {
295 //qDebug() << "fill/remove range of undo";
297 bool insert;
298 if( __bInsert ){
299 insert = false;
300 }else
301 {
302 insert = true;
303 }
304 __pRange->bInsert = insert;
308 }
309
310 virtual void redo()
311 {
312 //qDebug() << "fill/remove range of redo";
318 }
319private:
322 int __to;
325};
326
327
329class SE_modifyPatternCellsAction : public QUndoCommand
330{
331public:
332 SE_modifyPatternCellsAction( std::vector< QPoint > & addCells, std::vector< QPoint > & deleteCells,
333 std::vector< QPoint > & mergeCells, QString sText ) {
334 setText( sText );
335 m_addCells = addCells;
336 m_deleteCells = deleteCells;
337 m_mergeCells = mergeCells;
338 }
344 virtual void undo()
345 {
346 std::vector< QPoint > selectCells;
349 }
350private:
351 std::vector< QPoint > m_addCells;
352 std::vector< QPoint > m_deleteCells;
353 std::vector< QPoint > m_mergeCells;
354};
355
356// ~song editor commands
357//=====================================================================================================================================
358//time line commands
359
361class SE_editTimelineAction : public QUndoCommand
362{
363public:
364 SE_editTimelineAction( int nOldColumn, int nNewColumn, float fOldBpm, float fNewBpm, bool bTempoMarkerPresent ){
365 setText( QObject::tr( "Edit tempo marker" ) );
366 m_nOldColumn = nOldColumn;
367 m_nNewColumn = nNewColumn;
368 m_fOldBpm = fOldBpm;
369 m_fNewBpm = fNewBpm;
370 m_bTempoMarkerPresent = bTempoMarkerPresent;
371 }
372 virtual void undo() {
373 auto pSongEditorPositionRuler = HydrogenApp::get_instance()->getSongEditorPanel()->getSongEditorPositionRuler();
374 auto pCoreActionController = H2Core::Hydrogen::get_instance()->getCoreActionController();
376 pCoreActionController->addTempoMarker( m_nOldColumn, m_fOldBpm );
377 } else {
378 pCoreActionController->deleteTempoMarker( m_nNewColumn );
379 }
380 pSongEditorPositionRuler->createBackground();
381 }
382
383 virtual void redo() {
384 auto pSongEditorPositionRuler = HydrogenApp::get_instance()->getSongEditorPanel()->getSongEditorPositionRuler();
385 auto pCoreActionController = H2Core::Hydrogen::get_instance()->getCoreActionController();
386 pCoreActionController->deleteTempoMarker( m_nOldColumn );
387 pCoreActionController->addTempoMarker( m_nNewColumn, m_fNewBpm );
388 pSongEditorPositionRuler->createBackground();
389 }
390private:
396};
397
399class SE_deleteTimelineAction : public QUndoCommand
400{
401public:
402 SE_deleteTimelineAction( int nColumn, float fBpm ){
403 setText( QObject::tr( "Delete tempo marker" ) );
404 m_nColumn = nColumn;
405 m_fBpm = fBpm;
406 }
407 virtual void undo() {
408 auto pSongEditorPositionRuler = HydrogenApp::get_instance()->getSongEditorPanel()->getSongEditorPositionRuler();
409 auto pCoreActionController = H2Core::Hydrogen::get_instance()->getCoreActionController();
410 pCoreActionController->addTempoMarker( m_nColumn, m_fBpm );
411 pSongEditorPositionRuler->createBackground();
412 }
413
414 virtual void redo() {
415 auto pSongEditorPositionRuler = HydrogenApp::get_instance()->getSongEditorPanel()->getSongEditorPositionRuler();
416 auto pCoreActionController = H2Core::Hydrogen::get_instance()->getCoreActionController();
417 pCoreActionController->deleteTempoMarker( m_nColumn );
418 pSongEditorPositionRuler->createBackground();
419 }
420private:
422 float m_fBpm;
423};
424
426class SE_editTagAction : public QUndoCommand
427{
428public:
429 SE_editTagAction( const QString& sText, const QString& sOldText, int nPosition ){
430 setText( QObject::tr( "Edit timeline tag" ) );
431 m_sText = sText;
432 m_sOldText = sOldText;
433 m_nPosition = nPosition;
434
435 }
436 virtual void undo() {
437 auto pCoreActionController = H2Core::Hydrogen::get_instance()->getCoreActionController();
438 if ( ! m_sOldText.isEmpty() ){
439 pCoreActionController->addTag( m_nPosition, m_sOldText );
440 } else {
441 pCoreActionController->deleteTag( m_nPosition );
442 }
443 }
444
445 virtual void redo() {
446 auto pCoreActionController = H2Core::Hydrogen::get_instance()->getCoreActionController();
447 if ( ! m_sText.isEmpty() ){
448 pCoreActionController->addTag( m_nPosition, m_sText );
449 } else {
450 pCoreActionController->deleteTag( m_nPosition );
451 }
452 }
453private:
454 QString m_sText;
455 QString m_sOldText;
457};
458
459// ~time line commands
460//=====================================================================================================================================
461//pattern editor commands
462
464class SE_addOrDeleteNoteAction : public QUndoCommand
465{
466public:
468 int nRow,
469 int selectedPatternNumber,
470 int oldLength,
471 float oldVelocity,
472 float fOldPan,
473 float oldLeadLag,
474 int oldNoteKeyVal,
475 int oldOctaveKeyVal,
476 float probability,
477 bool isDelete,
478 bool listen,
479 bool isMidi,
480 bool isInstrumentMode,
481 bool isNoteOff ){
482
483 if( isDelete ){
484 setText( QObject::tr( "Delete note ( %1, %2)" ).arg( nColumn ).arg( nRow ) );
485 } else {
486 setText( QObject::tr( "Add note ( %1, %2)" ).arg( nColumn ).arg( nRow ) );
487 }
488 __nColumn = nColumn;
489 __nRow = nRow;
490 __selectedPatternNumber = selectedPatternNumber;
491 __oldLength = oldLength;
492 __oldVelocity = oldVelocity;
493 m_fOldPan = fOldPan;
494 __oldLeadLag = oldLeadLag;
495 __oldNoteKeyVal = oldNoteKeyVal;
496 __oldOctaveKeyVal = oldOctaveKeyVal;
497 __probability = probability;
498 __listen = listen;
499 __isMidi = isMidi;
500 __isInstrumentMode = isInstrumentMode;
501 __isDelete = isDelete;
502 __isNoteOff = isNoteOff;
503 }
504 virtual void undo()
505 {
506 //qDebug() << "Add note Undo ";
508 __isMidi = false; // undo is never a midi event.
510 __nRow,
514 m_fOldPan,
519 __listen,
520 __isMidi,
523 !__isDelete );
524 }
525 virtual void redo()
526 {
527 //qDebug() << "Add Note Redo " ;
530 __nRow,
534 m_fOldPan,
539 __listen,
540 __isMidi,
543 __isDelete );
544 }
545private:
561};
562
563// Deselect some notes and overwrite them
565class SE_patternSizeChangedAction : public QUndoCommand
566{
567public:
568 SE_patternSizeChangedAction( int nNewLength, int nOldLength,
569 double fNewDenominator, double fOldDenominator,
570 int nSelectedPatternNumber ) {
571 setText( QObject::tr( "Altering the length of the current pattern" ) );
572 m_nNewLength = nNewLength;
573 m_nOldLength = nOldLength;
574 m_fNewDenominator = fNewDenominator;
575 m_fOldDenominator = fOldDenominator;
576 m_nSelectedPatternNumber = nSelectedPatternNumber;
577 }
578
584
590
591private:
597};
598
599// Deselect some notes and overwrite them
601class SE_deselectAndOverwriteNotesAction : public QUndoCommand
602{
603public:
604 SE_deselectAndOverwriteNotesAction( std::vector< H2Core::Note *> &selected, std::vector< H2Core::Note *> &overwritten ) {
605 setText( QObject::tr( "Overwrite %1 notes" ).arg( overwritten.size() ) );
606 for ( auto pNote : selected ) {
607 m_selected.push_back( new H2Core::Note ( pNote ) );
608 }
609 for ( auto pNote : overwritten ) {
610 m_overwritten.push_back( new H2Core::Note ( pNote ) );
611 }
612 }
613
615 for ( auto pNote : m_selected ) {
616 delete pNote;
617 }
618 for ( auto pNote : m_overwritten ) {
619 delete pNote;
620 }
621 }
622
627
632
633private:
634 std::vector< H2Core::Note *> m_selected;
635 std::vector< H2Core::Note *> m_overwritten;
636};
637
639class SE_moveNoteAction : public QUndoCommand
640{
641public:
642 SE_moveNoteAction( int nOldPosition, int nOldInstrument, int nPattern, int nNewPosition, int nNewInstrument,
643 H2Core::Note *pNote )
644 {
645 m_nOldPosition = nOldPosition;
646 m_nOldInstrument = nOldInstrument;
647 m_nPattern = nPattern;
648 m_nNewPosition = nNewPosition;
649 m_nNewInstrument = nNewInstrument;
650 m_pNote = new H2Core::Note( pNote );
651 }
652
654 {
655 delete m_pNote;
656 }
657
664
671
672private:
679};
680
682class SE_editNoteLengthAction : public QUndoCommand
683{
684public:
685 SE_editNoteLengthAction( int nColumn, int nRealColumn, int nRow, int nLength,
686 int nOldLength, int nSelectedPatternNumber,
687 int nSelectedInstrumentNumber,
688 PatternEditor::Editor editor ){
689 setText( QObject::tr( "Change note length" ) );
690 m_nColumn = nColumn;
691 m_nRealColumn = nRealColumn;
692 m_nRow = nRow;
693 m_nLength = nLength;
694 m_nOldLength = nOldLength;
695 m_nSelectedPatternNumber = nSelectedPatternNumber;
696 m_nSelectedInstrumentNumber = nSelectedInstrumentNumber;
697 m_editor = editor;
698 }
699 virtual void undo()
700 {
701 // For now it does not matter which derived class of the
702 // PatternEditor will execute the call to
703 // editNoteLengthAction().
708 }
709 virtual void redo()
710 {
711 // For now it does not matter which derived class of the
712 // PatternEditor will execute the call to
713 // editNoteLengthAction().
718 }
719private:
728};
729
730
732class SE_editNotePropertiesAction : public QUndoCommand
733{
734public:
736 int nRealColumn,
737 int nRow,
738 int nSelectedPatternNumber,
739 int nSelectedInstrumentNumber,
742 float fVelocity,
743 float fOldVelocity,
744 float fPan,
745 float fOldPan,
746 float fLeadLag,
747 float fOldLeadLag,
748 float fProbability,
749 float fOldProbability ){
750 setText( QObject::tr( "Change note properties piano roll" )
751 .append( QString( ": [%1" )
752 .arg( PatternEditor::modeToQString( mode ) ) ) );
753 m_nColumn = nColumn;
754 m_nRealColumn = nRealColumn;
755 m_nRow = nRow;
756 m_nSelectedPatternNumber = nSelectedPatternNumber;
757 m_nSelectedInstrumentNumber = nSelectedInstrumentNumber;
758 m_mode = mode;
759 m_editor = editor;
760 m_fVelocity = fVelocity;
761 m_fOldVelocity = fOldVelocity;
762 m_fPan = fPan;
763 m_fOldPan = fOldPan;
764 m_fLeadLag = fLeadLag;
765 m_fOldLeadLag = fOldLeadLag;
766 m_fProbability = fProbability;
767 m_fOldProbability = fOldProbability;
768 }
769 virtual void undo()
770 {
771 // For now it does not matter which derived class of the
772 // PatternEditor will execute the call to
773 // editNoteLengthAction().
775 editNotePropertiesAction( m_nColumn,
777 m_nRow,
780 m_mode,
781 m_editor,
783 m_fOldPan,
786 }
787 virtual void redo()
788 {
789 // For now it does not matter which derived class of the
790 // PatternEditor will execute the call to
791 // editNoteLengthAction().
793 editNotePropertiesAction( m_nColumn,
795 m_nRow,
798 m_mode,
799 m_editor,
801 m_fPan,
804 }
805
806private:
816 float m_fPan;
822};
823
825class SE_clearNotesPatternEditorAction : public QUndoCommand
826{
827public:
828 SE_clearNotesPatternEditorAction( std::list< H2Core::Note* > noteList, int nSelectedInstrument, int selectedPatternNumber ){
829 setText( QObject::tr( "Clear notes" ) );
830
831 std::list < H2Core::Note *>::iterator pos;
832 for ( pos = noteList.begin(); pos != noteList.end(); ++pos){
833 H2Core::Note *pNote;
834 pNote = new H2Core::Note(*pos);
835 assert( pNote );
836 __noteList.push_back( pNote );
837 }
838
839 __nSelectedInstrument = nSelectedInstrument;
840 __selectedPatternNumber = selectedPatternNumber;
841 }
842
844 //qDebug() << "delete left notes ";
845 while ( __noteList.size() ) {
846 delete __noteList.front();
847 __noteList.pop_front();
848 }
849
850 }
851
852 virtual void undo()
853 {
854 //qDebug() << "clear note sequence Undo ";
857 }
858 virtual void redo()
859 {
860 //qDebug() << "clear note sequence Redo " ;
863 }
864private:
865 std::list< H2Core::Note* > __noteList;
868};
869
871class SE_pasteNotesPatternEditorAction : public QUndoCommand
872{
873public:
874 explicit SE_pasteNotesPatternEditorAction(const std::list<H2Core::Pattern*> & patternList)
875 {
876 //qDebug() << "paste note sequence Create ";
877 setText( QObject::tr( "Paste instrument notes" ) );
878
879 std::list < H2Core::Pattern *>::const_iterator pos;
880 for ( pos = patternList.begin(); pos != patternList.end(); ++pos)
881 {
882 H2Core::Pattern *pPattern = *pos;
883 assert( pPattern );
884 __patternList.push_back(pPattern);
885 }
886 }
887
889 {
890 //qDebug() << "paste note sequence Destroy ";
891 while ( __patternList.size() > 0)
892 {
893 delete __patternList.front();
894 __patternList.pop_front();
895 }
896 while ( __appliedList.size() > 0)
897 {
898 delete __appliedList.front();
899 __appliedList.pop_front();
900 }
901 }
902
903 virtual void undo()
904 {
905 //qDebug() << "paste note sequence Undo ";
908 }
909
910 virtual void redo()
911 {
912 //qDebug() << "paste note sequence Redo " ;
915 }
916
917private:
918 std::list< H2Core::Pattern* > __patternList;
919 std::list< H2Core::Pattern* > __appliedList;
920};
921
922
924class SE_fillNotesRightClickAction : public QUndoCommand
925{
926public:
927 SE_fillNotesRightClickAction( QStringList notePositions, int nSelectedInstrument, int selectedPatternNumber ){
928 setText( QObject::tr( "Fill notes" ) );
929 __notePositions = notePositions;
930 __nSelectedInstrument= nSelectedInstrument;
931 __selectedPatternNumber = selectedPatternNumber;
932 }
933 virtual void undo()
934 {
935 //qDebug() << "fill notes Undo ";
938 }
939 virtual void redo()
940 {
941 //qDebug() << "fill notes Redo " ;
944 }
945private:
946 QStringList __notePositions;
949};
950
951
953class SE_randomVelocityRightClickAction : public QUndoCommand
954{
955public:
956 SE_randomVelocityRightClickAction( QStringList noteVeloValue, QStringList oldNoteVeloValue, int nSelectedInstrument, int selectedPatternNumber ){
957 setText( QObject::tr( "Random velocity" ) );
958 __noteVeloValue = noteVeloValue;
959 __oldNoteVeloValue = oldNoteVeloValue;
960 __nSelectedInstrument= nSelectedInstrument;
961 __selectedPatternNumber = selectedPatternNumber;
962 }
963 virtual void undo()
964 {
965 //qDebug() << "Random velocity Undo ";
968 }
969 virtual void redo()
970 {
971 //qDebug() << "Random velocity Redo " ;
974 }
975private:
976 QStringList __noteVeloValue;
980};
981
982
983
985class SE_moveInstrumentAction : public QUndoCommand
986{
987public:
988 SE_moveInstrumentAction( int nSourceInstrument, int nTargetInstrument ){
989 setText( QObject::tr( "Move instrument" ) );
990 __nSourceInstrument = nSourceInstrument;
991 __nTargetInstrument = nTargetInstrument;
992 }
993 virtual void undo()
994 {
995 //qDebug() << "move Instrument Undo ";
998 }
999 virtual void redo()
1000 {
1001 //qDebug() << "move Instrument Redo " ;
1004 }
1005private:
1008};
1009
1011class SE_dragInstrumentAction : public QUndoCommand
1012{
1013public:
1014 SE_dragInstrumentAction( QString sDrumkitPath, QString sInstrumentName, int nTargetInstrument ){
1015 setText( QObject::tr( "Drop instrument" ) );
1016 __sDrumkitPath = sDrumkitPath;
1017 __sInstrumentName = sInstrumentName;
1018 __nTargetInstrument = nTargetInstrument;
1019 __addedComponents = new std::vector<int>();
1020 }
1021
1023 {
1024 delete __addedComponents;
1025 }
1026
1027 virtual void undo()
1028 {
1029 //qDebug() << "drop Instrument Undo ";
1032 }
1033
1034 virtual void redo()
1035 {
1036 //qDebug() << "drop Instrument Redo " ;
1039 }
1040
1041private:
1045 std::vector<int>* __addedComponents;
1046};
1047
1048
1050class SE_deleteInstrumentAction : public QUndoCommand
1051{
1052public:
1053 SE_deleteInstrumentAction( std::list< H2Core::Note* > noteList, QString sDrumkitPath, QString sInstrumentName, int nSelectedInstrument ){
1054 setText( QObject::tr( "Delete instrument " ) );
1055
1056 std::list < H2Core::Note *>::iterator pos;
1057 for ( pos = noteList.begin(); pos != noteList.end(); ++pos){
1058 H2Core::Note *pNote;
1059 pNote = new H2Core::Note(*pos);
1060 assert( pNote );
1061 __noteList.push_back( pNote );
1062 }
1063 __drumkitPath = sDrumkitPath;
1064 __instrumentName = sInstrumentName;
1065 __nSelectedInstrument = nSelectedInstrument;
1066 }
1067
1069 //qDebug() << "delete left notes ";
1070 while ( __noteList.size() ) {
1071 delete __noteList.front();
1072 __noteList.pop_front();
1073 }
1074
1075 }
1076
1077 virtual void undo()
1078 {
1079 //qDebug() << "delete Instrument Undo ";
1082 }
1083 virtual void redo()
1084 {
1085 //qDebug() << "delete Instrument Redo " ;
1087 //delete an instrument from list
1089 }
1090private:
1091 std::list< H2Core::Note* > __noteList;
1095};
1096
1097
1098
1100class SE_mainMenuAddInstrumentAction : public QUndoCommand
1101{
1102public:
1104 setText( QObject::tr( "Drop instrument" ) );
1105 }
1106 virtual void undo()
1107 {
1108 //qDebug() << "drop Instrument Undo ";
1111 }
1112 virtual void redo()
1113 {
1114 //qDebug() << "drop Instrument Redo " ;
1117 }
1118private:
1119};
1120
1121// ~pattern editor commands
1122//=====================================================================================================================================
1123//piano roll editor commands
1124
1125
1127class SE_addOrDeleteNotePianoRollAction : public QUndoCommand
1128{
1129public:
1131 int pressedLine,
1132 int selectedPatternNumber,
1133 int nSelectedInstrumentnumber,
1134 int oldLength,
1135 float oldVelocity,
1136 float fOldPan,
1137 float oldLeadLag,
1138 int oldNoteKeyVal,
1139 int oldOctaveKeyVal,
1140 float fProbability,
1141 bool isDelete ) {
1142 setText( QObject::tr( "Add piano roll note ( %1, %2 )" ).arg( nColumn ).arg( pressedLine ) );
1143 __nColumn = nColumn;
1144 __pressedLine = pressedLine;
1145 __selectedPatternNumber = selectedPatternNumber;
1146 __nSelectedInstrumentnumber = nSelectedInstrumentnumber;
1147 __oldLength = oldLength;
1148 __oldVelocity = oldVelocity;
1149 m_fOldPan = fOldPan;
1150 __oldLeadLag = oldLeadLag;
1151 __oldNoteKeyVal = oldNoteKeyVal;
1152 __oldOctaveKeyVal = oldOctaveKeyVal;
1153 __probability = fProbability;
1154 __isDelete = isDelete;
1155
1156 }
1157 virtual void undo()
1158 {
1159 //qDebug() << "Add Piano Roll note Undo ";
1167 m_fOldPan,
1172 false,
1173 !__isDelete );
1174 }
1175 virtual void redo()
1176 {
1177 //qDebug() << "Add Piano Roll Note Redo " ;
1185 m_fOldPan,
1190 false,
1191 __isDelete );
1192 }
1193private:
1206};
1207
1209class SE_addPianoRollNoteOffAction : public QUndoCommand
1210{
1211public:
1212 SE_addPianoRollNoteOffAction( int nColumn, int pressedLine, int selectedPatternNumber, int nSelectedInstrumentnumber ){
1213 setText( QObject::tr( "Add piano roll NOTE_OFF note ( %1, %2 )" ).arg( nColumn ).arg( pressedLine ) );
1214 __nColumn = nColumn;
1215 __pressedLine = pressedLine;
1216 __selectedPatternNumber = selectedPatternNumber;
1217 __nSelectedInstrumentnumber = nSelectedInstrumentnumber;
1218 }
1219 virtual void undo()
1220 {
1221 //qDebug() << "Add off note Note Undo ";
1224 }
1225 virtual void redo()
1226 {
1227 //qDebug() << "Add off note Note Redo " ;
1230
1231 }
1232private:
1237};
1238
1240class SE_moveNotePianoRollAction : public QUndoCommand
1241{
1242 public:
1243 SE_moveNotePianoRollAction( int nOldPosition, H2Core::Note::Octave oldOctave, H2Core::Note::Key oldKey, int nPattern,
1244 int nNewPosition, H2Core::Note::Octave newOctave, H2Core::Note::Key newKey,
1245 H2Core::Note *pNote )
1246 {
1247 m_nOldPosition = nOldPosition;
1248 m_oldOctave = oldOctave;
1249 m_oldKey = oldKey;
1250 m_nPattern = nPattern;
1251 m_nNewPosition = nNewPosition;
1252 m_newOctave = newOctave;
1253 m_newKey = newKey;
1254 m_pNote = new H2Core::Note( pNote );
1255 }
1256
1257 private:
1266
1268 {
1269 delete m_pNote;
1270 }
1271
1278
1285
1286};
1287
1288// ~piano roll editor commands
1289//=====================================================================================================================================
1290//Note Properties Ruler commands
1291
1293class SE_editNotePropertiesVolumeAction : public QUndoCommand
1294{
1295public:
1296
1299 int nSelectedPatternNumber,
1300 int nSelectedInstrument,
1301 float velocity,
1302 float oldVelocity,
1303 float pan,
1304 float oldPan,
1305 float leadLag,
1306 float oldLeadLag,
1307 float probability,
1308 float oldProbability,
1309 int noteKeyVal,
1310 int oldNoteKeyVal,
1311 int octaveKeyVal,
1312 int oldOctaveKeyVal)
1313 {
1314 setText( QObject::tr( "Edit note property %1" )
1315 .arg( NotePropertiesRuler::modeToQString( mode ) ) );
1316 __undoColumn = undoColumn;
1317 __mode = mode;
1318 __nSelectedPatternNumber = nSelectedPatternNumber;
1319 __nSelectedInstrument = nSelectedInstrument;
1320 __velocity = velocity;
1321 __oldVelocity = oldVelocity;
1322 m_fPan = pan;
1323 m_fOldPan = oldPan;
1324 __leadLag = leadLag;
1325 __oldLeadLag = oldLeadLag;
1326 __probability = probability;
1327 __oldProbability = oldProbability;
1328 __noteKeyVal = noteKeyVal;
1329 __oldNoteKeyVal = oldNoteKeyVal;
1330 __octaveKeyVal = octaveKeyVal;
1331 __oldOctaveKeyVal = oldOctaveKeyVal;
1332 }
1333
1334 virtual void undo()
1335 {
1336 //qDebug() << "edit note property Undo ";
1338
1340 __mode,
1344 m_fOldPan,
1349 }
1350 virtual void redo()
1351 {
1352 //qDebug() << "edit note property Redo " ;
1355 __mode,
1358 __velocity,
1359 m_fPan,
1360 __leadLag,
1364 }
1365private:
1366
1367
1374 float m_fPan;
1384};
1385
1386// ~Note Properties Ruler commands
1387//=====================================================================================================================================
1388
1389
1390
1392class SE_automationPathAddPointAction : public QUndoCommand
1393{
1394public:
1396 {
1397 setText( QObject::tr( "Add point" ) );
1398 __path = path;
1399 __x = x;
1400 __y = y;
1401 }
1402
1403 virtual void undo()
1404 {
1406
1408 h2app->getSongEditorPanel()->getAutomationPathView()->update();
1409 }
1410
1411 virtual void redo()
1412 {
1413 __path->add_point( __x, __y );
1414
1416 h2app->getSongEditorPanel()->getAutomationPathView()->update();
1417 }
1418private:
1420 float __x;
1421 float __y;
1422};
1423
1424
1426class SE_automationPathRemovePointAction : public QUndoCommand
1427{
1428public:
1430 {
1431 setText( QObject::tr( "Remove point" ) );
1432 __path = path;
1433 __x = x;
1434 __y = y;
1435 }
1436
1437 virtual void redo()
1438 {
1440
1442 h2app->getSongEditorPanel()->getAutomationPathView()->update();
1443 }
1444
1445 virtual void undo()
1446 {
1447 __path->add_point( __x, __y );
1448
1450 h2app->getSongEditorPanel()->getAutomationPathView()->update();
1451 }
1452private:
1454 float __x;
1455 float __y;
1456};
1457
1458
1460class SE_automationPathMovePointAction : public QUndoCommand
1461{
1462public:
1463 SE_automationPathMovePointAction( H2Core::AutomationPath *path, float ox, float oy, float tx, float ty)
1464 {
1465 setText( QObject::tr( "Move point" ) );
1466 __path = path;
1467 __ox = ox;
1468 __oy = oy;
1469 __tx = tx;
1470 __ty = ty;
1471 }
1472
1473 virtual void redo()
1474 {
1477
1479 h2app->getSongEditorPanel()->getAutomationPathView()->update();
1480 }
1481
1482 virtual void undo()
1483 {
1486
1488 h2app->getSongEditorPanel()->getAutomationPathView()->update();
1489 }
1490private:
1492 float __ox;
1493 float __oy;
1494 float __tx;
1495 float __ty;
1496};
1497
1498#endif // UNDOACTIONS_H
void functionClearNotesUndoAction(std::list< H2Core::Note * > noteList, int nSelectedInstrument, int patternNumber)
void functionRandomVelocityAction(QStringList noteVeloValue, int nSelectedInstrument, int selectedPatternNumber)
void functionDropInstrumentUndoAction(int nTargetInstrument, std::vector< int > *AddedComponents)
void functionMoveInstrumentAction(int nSourceInstrument, int nTargetInstrument)
void moveNoteAction(int nColumn, int nRow, int nPattern, int nNewColumn, int nNewRow, H2Core::Note *note)
void functionFillNotesRedoAction(QStringList noteList, int nSelectedInstrument, int patternNumber)
void addOrDeleteNoteAction(int nColumn, int row, int selectedPatternNumber, int oldLength, float oldVelocity, float fOldPan, float oldLeadLag, int oldNoteKeyVal, int oldOctaveKeyVal, float probability, bool listen, bool isMidi, bool isInstrumentMode, bool isNoteOff, bool isDelete)
void functionFillNotesUndoAction(QStringList noteList, int nSelectedInstrument, int patternNumber)
void undoRedoAction(int column, NotePropertiesRuler::Mode mode, int nSelectedPatternNumber, int nSelectedInstrument, float velocity, float pan, float leadLag, float probability, int noteKeyVal, int octaveKeyVal)
NotePropertiesRuler undo redo action.
void functionPasteNotesUndoAction(std::list< H2Core::Pattern * > &appliedList)
void functionClearNotesRedoAction(int nSelectedInstrument, int selectedPatternNumber)
========================================================== undo / redo actions from pattern editor in...
void functionDeleteInstrumentUndoAction(std::list< H2Core::Note * > noteList, int nSelectedInstrument, QString instrumentName, QString drumkitName)
void functionPasteNotesRedoAction(std::list< H2Core::Pattern * > &changeList, std::list< H2Core::Pattern * > &appliedList)
void functionDropInstrumentRedoAction(QString sDrumkitPath, QString sInstrumentName, int nTargetInstrument, std::vector< int > *pAddedComponents)
void remove_point(float x)
Remove point from path.
void add_point(float x, float y)
Add a point to path.
bool setPattern(Pattern *pPattern, int nPatternNumber)
Opens a pattern to the current pattern list.
bool addTag(int nPosition, const QString &sText)
Adds a tag to the Timeline.
bool deleteTempoMarker(int nPosition)
Delete a tempo marker from the Timeline.
bool toggleGridCell(int nColumn, int nRow)
Fills or clears a specific grid cell in the SongEditor.
bool removePattern(int nPatternNumber)
Removes a pattern from the pattern list.
bool addTempoMarker(int nPosition, float fBpm)
Adds a tempo marker to the Timeline.
bool openPattern(const QString &sPath, int nPatternNumber=-1)
Opens a pattern from disk and adds it to the pattern list.
static Hydrogen * get_instance()
Returns the current Hydrogen instance __instance.
Definition Hydrogen.h:83
CoreActionController * getCoreActionController() const
Definition Hydrogen.h:639
A note plays an associated instrument with a velocity left and right pan.
Definition Note.h:102
Key
possible keys
Definition Note.h:106
Octave
possible octaves
Definition Note.h:110
Pattern class is a Note container.
Definition Pattern.h:46
static HydrogenApp * get_instance()
Returns the instance of HydrogenApp class.
PatternEditorPanel * getPatternEditorPanel()
SongEditorPanel * getSongEditorPanel()
PianoRollEditor * getPianoRollEditor()
DrumPatternEditor * getDrumPatternEditor()
void patternSizeChangedAction(int nLength, double fDenominator, int nSelectedPatternNumber)
static QString modeToQString(Mode mode)
void editNoteLengthAction(int nColumn, int nRealColumn, int nRow, int nLength, int nSelectedPatternNumber, int nSelectedInstrumentnumber, Editor editor)
void deselectAndOverwriteNotes(std::vector< H2Core::Note * > &selected, std::vector< H2Core::Note * > &overwritten)
Deselect some notes, and "overwrite" some others.
void undoDeselectAndOverwriteNotes(std::vector< H2Core::Note * > &selected, std::vector< H2Core::Note * > &overwritten)
void moveNoteAction(int nColumn, H2Core::Note::Octave octave, H2Core::Note::Key key, int nPattern, int nNewColumn, H2Core::Note::Octave newOctave, H2Core::Note::Key newKey, H2Core::Note *pNote)
void addOrDeleteNoteAction(int nColumn, int pressedLine, int selectedPatternNumber, int selectedinstrument, int oldLength, float oldVelocity, float fOldPan, float oldLeadLag, int oldNoteKeyVal, int oldOctaveKeyVal, float fProbability, bool noteOff, bool isDelete)
SE_addOrDeleteNoteAction(int nColumn, int nRow, int selectedPatternNumber, int oldLength, float oldVelocity, float fOldPan, float oldLeadLag, int oldNoteKeyVal, int oldOctaveKeyVal, float probability, bool isDelete, bool listen, bool isMidi, bool isInstrumentMode, bool isNoteOff)
SE_addOrDeleteNotePianoRollAction(int nColumn, int pressedLine, int selectedPatternNumber, int nSelectedInstrumentnumber, int oldLength, float oldVelocity, float fOldPan, float oldLeadLag, int oldNoteKeyVal, int oldOctaveKeyVal, float fProbability, bool isDelete)
SE_addPianoRollNoteOffAction(int nColumn, int pressedLine, int selectedPatternNumber, int nSelectedInstrumentnumber)
H2Core::AutomationPath * __path
SE_automationPathAddPointAction(H2Core::AutomationPath *path, float x, float y)
SE_automationPathMovePointAction(H2Core::AutomationPath *path, float ox, float oy, float tx, float ty)
H2Core::AutomationPath * __path
H2Core::AutomationPath * __path
SE_automationPathRemovePointAction(H2Core::AutomationPath *path, float x, float y)
std::list< H2Core::Note * > __noteList
SE_clearNotesPatternEditorAction(std::list< H2Core::Note * > noteList, int nSelectedInstrument, int selectedPatternNumber)
std::list< H2Core::Note * > __noteList
SE_deleteInstrumentAction(std::list< H2Core::Note * > noteList, QString sDrumkitPath, QString sInstrumentName, int nSelectedInstrument)
SE_deletePatternFromListAction(QString sPatternFilename, QString sSequenceFilename, int nPatternPosition)
SE_deletePatternSequenceAction(QString pFilename)
SE_deleteTimelineAction(int nColumn, float fBpm)
std::vector< H2Core::Note * > m_selected
SE_deselectAndOverwriteNotesAction(std::vector< H2Core::Note * > &selected, std::vector< H2Core::Note * > &overwritten)
std::vector< H2Core::Note * > m_overwritten
std::vector< int > * __addedComponents
SE_dragInstrumentAction(QString sDrumkitPath, QString sInstrumentName, int nTargetInstrument)
SE_duplicatePatternAction(QString patternFilename, int patternPosition)
PatternEditor::Editor m_editor
SE_editNoteLengthAction(int nColumn, int nRealColumn, int nRow, int nLength, int nOldLength, int nSelectedPatternNumber, int nSelectedInstrumentNumber, PatternEditor::Editor editor)
PatternEditor::Editor m_editor
SE_editNotePropertiesAction(int nColumn, int nRealColumn, int nRow, int nSelectedPatternNumber, int nSelectedInstrumentNumber, PatternEditor::Mode mode, PatternEditor::Editor editor, float fVelocity, float fOldVelocity, float fPan, float fOldPan, float fLeadLag, float fOldLeadLag, float fProbability, float fOldProbability)
PatternEditor::Mode m_mode
SE_editNotePropertiesVolumeAction(int undoColumn, NotePropertiesRuler::Mode mode, int nSelectedPatternNumber, int nSelectedInstrument, float velocity, float oldVelocity, float pan, float oldPan, float leadLag, float oldLeadLag, float probability, float oldProbability, int noteKeyVal, int oldNoteKeyVal, int octaveKeyVal, int oldOctaveKeyVal)
NotePropertiesRuler::Mode __mode
SE_editTagAction(const QString &sText, const QString &sOldText, int nPosition)
virtual void redo()
virtual void undo()
virtual void redo()
virtual void undo()
SE_editTimelineAction(int nOldColumn, int nNewColumn, float fOldBpm, float fNewBpm, bool bTempoMarkerPresent)
SE_fillNotesRightClickAction(QStringList notePositions, int nSelectedInstrument, int selectedPatternNumber)
SE_fillRangePatternAction(FillRange *pRange, int nPattern)
H2Core::Pattern * m_pNewPattern
virtual void redo()
virtual void undo()
SE_insertPatternAction(int patternPosition, H2Core::Pattern *pPattern)
SE_loadPatternAction(QString sPatternName, QString sOldPatternName, QString sSequenceFilename, int nPatternPosition, bool bDragFromList)
virtual void redo()
virtual void undo()
std::vector< QPoint > m_mergeCells
SE_modifyPatternCellsAction(std::vector< QPoint > &addCells, std::vector< QPoint > &deleteCells, std::vector< QPoint > &mergeCells, QString sText)
std::vector< QPoint > m_deleteCells
std::vector< QPoint > m_addCells
SE_modifyPatternPropertiesAction(QString oldPatternName, QString oldPatternInfo, QString oldPatternCategory, QString newPatternName, QString newPatternInfo, QString newPatternCategory, int patternNr)
SE_moveInstrumentAction(int nSourceInstrument, int nTargetInstrument)
H2Core::Note * m_pNote
virtual void redo()
SE_moveNoteAction(int nOldPosition, int nOldInstrument, int nPattern, int nNewPosition, int nNewInstrument, H2Core::Note *pNote)
virtual void undo()
H2Core::Note::Key m_newKey
SE_moveNotePianoRollAction(int nOldPosition, H2Core::Note::Octave oldOctave, H2Core::Note::Key oldKey, int nPattern, int nNewPosition, H2Core::Note::Octave newOctave, H2Core::Note::Key newKey, H2Core::Note *pNote)
H2Core::Note::Octave m_oldOctave
H2Core::Note::Key m_oldKey
H2Core::Note::Octave m_newOctave
SE_movePatternListItemAction(int nSourcePattern, int nTargetPattern)
Definition UndoActions.h:76
std::list< H2Core::Pattern * > __patternList
SE_pasteNotesPatternEditorAction(const std::list< H2Core::Pattern * > &patternList)
std::list< H2Core::Pattern * > __appliedList
SE_patternSizeChangedAction(int nNewLength, int nOldLength, double fNewDenominator, double fOldDenominator, int nSelectedPatternNumber)
SE_randomVelocityRightClickAction(QStringList noteVeloValue, QStringList oldNoteVeloValue, int nSelectedInstrument, int selectedPatternNumber)
SE_togglePatternAction(int nColumn, int nRow)
Definition UndoActions.h:56
virtual void redo()
Definition UndoActions.h:64
virtual void undo()
Definition UndoActions.h:61
SongEditorPositionRuler * getSongEditorPositionRuler() const
void restoreGroupVector(QString filename)
SongEditor * getSongEditor() const
SongEditorPatternList * getSongEditorPatternList() const
AutomationPathView * getAutomationPathView() const
void fillRangeWithPattern(FillRange *r, int nPattern)
void movePatternLine(int, int)
void acceptPatternPropertiesDialogSettings(QString newPatternName, QString newPatternInfo, QString newPatternCategory, int patternNr)
void revertPatternPropertiesDialogSettings(QString oldPatternName, QString oldPatternInfo, QString oldPatternCategory, int patternNr)
void modifyPatternCellsAction(std::vector< QPoint > &addCells, std::vector< QPoint > &deleteCells, std::vector< QPoint > &selectCells)
Modify many pattern cells at once, for use in a single efficient undo/redo action.
void clearThePatternSequenceVector(QString filename)