hydrogen 1.2.6
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-2025 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;
305 __pRange->fromVal = __from;
306 __pRange->toVal = __to;
308 }
309
310 virtual void redo()
311 {
312 //qDebug() << "fill/remove range of redo";
314 __pRange->bInsert = __bInsert;
315 __pRange->fromVal = __from;
316 __pRange->toVal = __to;
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 }
863private:
864 std::list< H2Core::Note* > __noteList;
867};
868
870class SE_pasteNotesPatternEditorAction : public QUndoCommand
871{
872public:
873 explicit SE_pasteNotesPatternEditorAction(const std::list<H2Core::Pattern*> & patternList)
874 {
875 //qDebug() << "paste note sequence Create ";
876 setText( QObject::tr( "Paste instrument notes" ) );
877
878 std::list < H2Core::Pattern *>::const_iterator pos;
879 for ( pos = patternList.begin(); pos != patternList.end(); ++pos)
880 {
881 H2Core::Pattern *pPattern = *pos;
882 assert( pPattern );
883 __patternList.push_back(pPattern);
884 }
885 }
886
888 {
889 //qDebug() << "paste note sequence Destroy ";
890 while ( __patternList.size() > 0)
891 {
892 delete __patternList.front();
893 __patternList.pop_front();
894 }
895 while ( __appliedList.size() > 0)
896 {
897 delete __appliedList.front();
898 __appliedList.pop_front();
899 }
900 }
901
902 virtual void undo()
903 {
904 //qDebug() << "paste note sequence Undo ";
907 }
908
909 virtual void redo()
910 {
911 //qDebug() << "paste note sequence Redo " ;
914 }
915
916private:
917 std::list< H2Core::Pattern* > __patternList;
918 std::list< H2Core::Pattern* > __appliedList;
919};
920
921
923class SE_fillNotesRightClickAction : public QUndoCommand
924{
925public:
926 SE_fillNotesRightClickAction( QStringList notePositions, int nSelectedInstrument, int selectedPatternNumber ){
927 setText( QObject::tr( "Fill notes" ) );
928 __notePositions = notePositions;
929 __nSelectedInstrument= nSelectedInstrument;
930 __selectedPatternNumber = selectedPatternNumber;
931 }
932 virtual void undo()
933 {
934 //qDebug() << "fill notes Undo ";
937 }
938 virtual void redo()
939 {
940 //qDebug() << "fill notes Redo " ;
943 }
944private:
945 QStringList __notePositions;
948};
949
950
952class SE_randomVelocityRightClickAction : public QUndoCommand
953{
954public:
955 SE_randomVelocityRightClickAction( QStringList noteVeloValue, QStringList oldNoteVeloValue, int nSelectedInstrument, int selectedPatternNumber ){
956 setText( QObject::tr( "Random velocity" ) );
957 __noteVeloValue = noteVeloValue;
958 __oldNoteVeloValue = oldNoteVeloValue;
959 __nSelectedInstrument= nSelectedInstrument;
960 __selectedPatternNumber = selectedPatternNumber;
961 }
962 virtual void undo()
963 {
964 //qDebug() << "Random velocity Undo ";
967 }
968 virtual void redo()
969 {
970 //qDebug() << "Random velocity Redo " ;
973 }
974private:
975 QStringList __noteVeloValue;
979};
980
981
982
984class SE_moveInstrumentAction : public QUndoCommand
985{
986public:
987 SE_moveInstrumentAction( int nSourceInstrument, int nTargetInstrument ){
988 setText( QObject::tr( "Move instrument" ) );
989 __nSourceInstrument = nSourceInstrument;
990 __nTargetInstrument = nTargetInstrument;
991 }
992 virtual void undo()
993 {
994 //qDebug() << "move Instrument Undo ";
997 }
998 virtual void redo()
999 {
1000 //qDebug() << "move Instrument Redo " ;
1003 }
1004private:
1007};
1008
1010class SE_dragInstrumentAction : public QUndoCommand
1011{
1012public:
1013 SE_dragInstrumentAction( QString sDrumkitPath, QString sInstrumentName, int nTargetInstrument ){
1014 setText( QObject::tr( "Drop instrument" ) );
1015 __sDrumkitPath = sDrumkitPath;
1016 __sInstrumentName = sInstrumentName;
1017 __nTargetInstrument = nTargetInstrument;
1018 __addedComponents = new std::vector<int>();
1019 }
1020
1022 {
1023 delete __addedComponents;
1024 }
1025
1026 virtual void undo()
1027 {
1028 //qDebug() << "drop Instrument Undo ";
1031 }
1032
1033 virtual void redo()
1034 {
1035 //qDebug() << "drop Instrument Redo " ;
1038 }
1039
1040private:
1044 std::vector<int>* __addedComponents;
1045};
1046
1047
1049class SE_deleteInstrumentAction : public QUndoCommand
1050{
1051public:
1052 SE_deleteInstrumentAction( std::list< H2Core::Note* > noteList, QString sDrumkitPath, QString sInstrumentName, int nSelectedInstrument ){
1053 setText( QObject::tr( "Delete instrument " ) );
1054
1055 std::list < H2Core::Note *>::iterator pos;
1056 for ( pos = noteList.begin(); pos != noteList.end(); ++pos){
1057 H2Core::Note *pNote;
1058 pNote = new H2Core::Note(*pos);
1059 assert( pNote );
1060 __noteList.push_back( pNote );
1061 }
1062 __drumkitPath = sDrumkitPath;
1063 __instrumentName = sInstrumentName;
1064 __nSelectedInstrument = nSelectedInstrument;
1065 }
1066
1068 //qDebug() << "delete left notes ";
1069 while ( __noteList.size() ) {
1070 delete __noteList.front();
1071 __noteList.pop_front();
1072 }
1073
1074 }
1075
1076 virtual void undo()
1077 {
1078 //qDebug() << "delete Instrument Undo ";
1081 }
1082 virtual void redo()
1083 {
1084 //qDebug() << "delete Instrument Redo " ;
1086 //delete an instrument from list
1088 }
1089private:
1090 std::list< H2Core::Note* > __noteList;
1094};
1095
1096
1097
1099class SE_mainMenuAddInstrumentAction : public QUndoCommand
1100{
1101public:
1103 setText( QObject::tr( "Drop instrument" ) );
1104 }
1105 virtual void undo()
1106 {
1107 //qDebug() << "drop Instrument Undo ";
1110 }
1111 virtual void redo()
1112 {
1113 //qDebug() << "drop Instrument Redo " ;
1116 }
1117private:
1118};
1119
1120// ~pattern editor commands
1121//=====================================================================================================================================
1122//piano roll editor commands
1123
1124
1126class SE_addOrDeleteNotePianoRollAction : public QUndoCommand
1127{
1128public:
1130 int pressedLine,
1131 int selectedPatternNumber,
1132 int nSelectedInstrumentnumber,
1133 int oldLength,
1134 float oldVelocity,
1135 float fOldPan,
1136 float oldLeadLag,
1137 int oldNoteKeyVal,
1138 int oldOctaveKeyVal,
1139 float fProbability,
1140 bool isDelete ) {
1141 setText( QObject::tr( "Add piano roll note ( %1, %2 )" ).arg( nColumn ).arg( pressedLine ) );
1142 __nColumn = nColumn;
1143 __pressedLine = pressedLine;
1144 __selectedPatternNumber = selectedPatternNumber;
1145 __nSelectedInstrumentnumber = nSelectedInstrumentnumber;
1146 __oldLength = oldLength;
1147 __oldVelocity = oldVelocity;
1148 m_fOldPan = fOldPan;
1149 __oldLeadLag = oldLeadLag;
1150 __oldNoteKeyVal = oldNoteKeyVal;
1151 __oldOctaveKeyVal = oldOctaveKeyVal;
1152 __probability = fProbability;
1153 __isDelete = isDelete;
1154
1155 }
1156 virtual void undo()
1157 {
1158 //qDebug() << "Add Piano Roll note Undo ";
1166 m_fOldPan,
1171 false,
1172 !__isDelete );
1173 }
1174 virtual void redo()
1175 {
1176 //qDebug() << "Add Piano Roll Note Redo " ;
1184 m_fOldPan,
1189 false,
1190 __isDelete );
1191 }
1192private:
1205};
1206
1208class SE_addPianoRollNoteOffAction : public QUndoCommand
1209{
1210public:
1211 SE_addPianoRollNoteOffAction( int nColumn, int pressedLine, int selectedPatternNumber, int nSelectedInstrumentnumber ){
1212 setText( QObject::tr( "Add piano roll NOTE_OFF note ( %1, %2 )" ).arg( nColumn ).arg( pressedLine ) );
1213 __nColumn = nColumn;
1214 __pressedLine = pressedLine;
1215 __selectedPatternNumber = selectedPatternNumber;
1216 __nSelectedInstrumentnumber = nSelectedInstrumentnumber;
1217 }
1218 virtual void undo()
1219 {
1220 //qDebug() << "Add off note Note Undo ";
1223 }
1224 virtual void redo()
1225 {
1226 //qDebug() << "Add off note Note Redo " ;
1229
1230 }
1231private:
1236};
1237
1239class SE_moveNotePianoRollAction : public QUndoCommand
1240{
1241 public:
1242 SE_moveNotePianoRollAction( int nOldPosition, H2Core::Note::Octave oldOctave, H2Core::Note::Key oldKey, int nPattern,
1243 int nNewPosition, H2Core::Note::Octave newOctave, H2Core::Note::Key newKey,
1244 H2Core::Note *pNote )
1245 {
1246 m_nOldPosition = nOldPosition;
1247 m_oldOctave = oldOctave;
1248 m_oldKey = oldKey;
1249 m_nPattern = nPattern;
1250 m_nNewPosition = nNewPosition;
1251 m_newOctave = newOctave;
1252 m_newKey = newKey;
1253 m_pNote = new H2Core::Note( pNote );
1254 }
1255
1256 private:
1265
1267 {
1268 delete m_pNote;
1269 }
1270
1277
1284
1285};
1286
1287// ~piano roll editor commands
1288//=====================================================================================================================================
1289//Note Properties Ruler commands
1290
1292class SE_editNotePropertiesVolumeAction : public QUndoCommand
1293{
1294public:
1295
1298 int nSelectedPatternNumber,
1299 int nSelectedInstrument,
1300 float velocity,
1301 float oldVelocity,
1302 float pan,
1303 float oldPan,
1304 float leadLag,
1305 float oldLeadLag,
1306 float probability,
1307 float oldProbability,
1308 int noteKeyVal,
1309 int oldNoteKeyVal,
1310 int octaveKeyVal,
1311 int oldOctaveKeyVal)
1312 {
1313 setText( QObject::tr( "Edit note property %1" )
1314 .arg( NotePropertiesRuler::modeToQString( mode ) ) );
1315 __undoColumn = undoColumn;
1316 __mode = mode;
1317 __nSelectedPatternNumber = nSelectedPatternNumber;
1318 __nSelectedInstrument = nSelectedInstrument;
1319 __velocity = velocity;
1320 __oldVelocity = oldVelocity;
1321 m_fPan = pan;
1322 m_fOldPan = oldPan;
1323 __leadLag = leadLag;
1324 __oldLeadLag = oldLeadLag;
1325 __probability = probability;
1326 __oldProbability = oldProbability;
1327 __noteKeyVal = noteKeyVal;
1328 __oldNoteKeyVal = oldNoteKeyVal;
1329 __octaveKeyVal = octaveKeyVal;
1330 __oldOctaveKeyVal = oldOctaveKeyVal;
1331 }
1332
1333 virtual void undo()
1334 {
1335 //qDebug() << "edit note property Undo ";
1337
1339 __mode,
1343 m_fOldPan,
1348 }
1349 virtual void redo()
1350 {
1351 //qDebug() << "edit note property Redo " ;
1354 __mode,
1357 __velocity,
1358 m_fPan,
1359 __leadLag,
1363 }
1364private:
1365
1366
1373 float m_fPan;
1383};
1384
1385// ~Note Properties Ruler commands
1386//=====================================================================================================================================
1387
1388
1389
1391class SE_automationPathAddPointAction : public QUndoCommand
1392{
1393public:
1395 {
1396 setText( QObject::tr( "Add point" ) );
1397 __path = path;
1398 __x = x;
1399 __y = y;
1400 }
1401
1402 virtual void undo()
1403 {
1404 __path->remove_point( __x );
1405
1407 h2app->getSongEditorPanel()->getAutomationPathView()->update();
1408 }
1409
1410 virtual void redo()
1411 {
1412 __path->add_point( __x, __y );
1413
1415 h2app->getSongEditorPanel()->getAutomationPathView()->update();
1416 }
1417private:
1419 float __x;
1420 float __y;
1421};
1422
1423
1425class SE_automationPathRemovePointAction : public QUndoCommand
1426{
1427public:
1429 {
1430 setText( QObject::tr( "Remove point" ) );
1431 __path = path;
1432 __x = x;
1433 __y = y;
1434 }
1435
1436 virtual void redo()
1437 {
1438 __path->remove_point( __x );
1439
1441 h2app->getSongEditorPanel()->getAutomationPathView()->update();
1442 }
1443
1444 virtual void undo()
1445 {
1446 __path->add_point( __x, __y );
1447
1449 h2app->getSongEditorPanel()->getAutomationPathView()->update();
1450 }
1451private:
1453 float __x;
1454 float __y;
1455};
1456
1457
1459class SE_automationPathMovePointAction : public QUndoCommand
1460{
1461public:
1462 SE_automationPathMovePointAction( H2Core::AutomationPath *path, float ox, float oy, float tx, float ty)
1463 {
1464 setText( QObject::tr( "Move point" ) );
1465 __path = path;
1466 __ox = ox;
1467 __oy = oy;
1468 __tx = tx;
1469 __ty = ty;
1470 }
1471
1472 virtual void redo()
1473 {
1474 __path->remove_point( __ox );
1475 __path->add_point( __tx, __ty );
1476
1478 h2app->getSongEditorPanel()->getAutomationPathView()->update();
1479 }
1480
1481 virtual void undo()
1482 {
1483 __path->remove_point( __tx );
1484 __path->add_point( __ox, __oy );
1485
1487 h2app->getSongEditorPanel()->getAutomationPathView()->update();
1488 }
1489private:
1491 float __ox;
1492 float __oy;
1493 float __tx;
1494 float __ty;
1495};
1496
1497#endif // UNDOACTIONS_H
void functionClearNotesUndoAction(std::list< H2Core::Note * > noteList, int nSelectedInstrument, int patternNumber)
========================================================== undo / redo actions from pattern editor in...
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 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)
bool setPattern(Pattern *pPattern, int nPatternNumber)
Opens a pattern to the current pattern list.
bool clearInstrumentInPattern(int nInstrumentNumber, int nPatternNumber=-1)
Deletes all notes for instrument pInstrument in a specified pattern.
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:84
CoreActionController * getCoreActionController() const
Definition Hydrogen.h:653
A note plays an associated instrument with a velocity left and right pan.
Definition Note.h:101
Key
possible keys
Definition Note.h:105
Octave
possible octaves
Definition Note.h:109
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)